Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp829838imm; Fri, 12 Oct 2018 07:22:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV61FsazgGl97YgleOi6CZjs8GS0zme2Rwl+nFZCgz0Bp2w79/gGcIsjTlSV38m3A4xMPrnTB X-Received: by 2002:a62:de05:: with SMTP id h5-v6mr6363991pfg.258.1539354168867; Fri, 12 Oct 2018 07:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539354168; cv=none; d=google.com; s=arc-20160816; b=vgN1pLoRdMmAxK/qo4okc5RF2RyTAFX1TWbQYTmE0G/vurtsP4rBX1/htPCtRzHKAv Ja945K8+Z2X1zJunedlkXJpI5KdfXngj6ttYArGK+JnuQI0/AUkRaXRZm7Wphw3DvKBf 0s44GkqbtFd+iV53wO32sMWADLxjSwM67M+YWiz2ag6xPKs4zxZO08/85am9g/DUBG/q ZkwXlCfs0IFYvJs8vJQINRb1DJz9fLFZuCjyEO3HrXeQ/YPnm9oW5NERtaIX9mSuXlk8 PUgXOFH3GGeLCZTrd6Vx7528s5B7eCT/T0F7TtfiUMEIvbpu0YXvAqdkZDNpVBxdFOXV HRTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :dkim-signature; bh=Z8cEINrQVTFAuPifFaWR3cA7/rcOv09k3XgJkaJnlGw=; b=ksXBwJ6NZcE/DVn3+c4Wp8+zhf1nyNE/QrAVSgjDy8yUzjhJJqam6d1dTyqS60Xggy E206PzOUZLBvJUD9cRL6DvyldX8AjNqjWrsjelxvmzVoFyQgnDm/K7bVYPDKpHHIRlkJ yYMaJzSAZkRhsq0zT1US9e2JxZ0hKmeU+7R3TTILKt1XGlrtYJrdAmhab7EcQGaHWn4e +zufoJdPF3yZeRYuyiSxavFaBqKE3nDgtyLGzVS0byNYV7i/6RGd0yPAJcC9SMM0cXqn f6mI8+dvwMwRPLO4U3YQhyMEQT4RMmzAg5FXfn0baSSC72JgMCD3f24A3GH8RtCHUOHo iPtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SB7W7dbu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7-v6si1362833pgb.301.2018.10.12.07.22.33; Fri, 12 Oct 2018 07:22:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SB7W7dbu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728796AbeJLVys (ORCPT + 99 others); Fri, 12 Oct 2018 17:54:48 -0400 Received: from mail-wm1-f41.google.com ([209.85.128.41]:52723 "EHLO mail-wm1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728354AbeJLVys (ORCPT ); Fri, 12 Oct 2018 17:54:48 -0400 Received: by mail-wm1-f41.google.com with SMTP id 189-v6so12501647wmw.2; Fri, 12 Oct 2018 07:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=Z8cEINrQVTFAuPifFaWR3cA7/rcOv09k3XgJkaJnlGw=; b=SB7W7dbuU9S1o7n/64/PlAtuw3ncO0AUmR9D+FUfvRyEe4McoySoq4qa1LJCeJnFUQ 95hCiZxMTyKfOX2gzkoXsPMZzH+jKrJxQSbxW44BK3apzXZ/FOrXsMYiAQ7WLuupMLZM pRBuADrDouDV1rmiB/SWzMhoE6kuDpeWbwLtuS1G62czSG31zUbxMOBiQRosRBRNES3w c0b2OcfisR+j+0B/5+BVgEZqte0L8ILRinuqO0gpiKUJzy4+sJy/JPsmP4j+SaXLcxgU m3Ny6vfHglMnjPszQgA3C4LmNIen6/82bd09EKlZodGYzWe9EPm3m/GX+DrJ9GUz9BJ5 xWLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=Z8cEINrQVTFAuPifFaWR3cA7/rcOv09k3XgJkaJnlGw=; b=t9br4DowNEA0yLJN475Qqf3Hr/l08+kBLwc18vBBxeceVitt0eX8DDLu0n2tRdqjG0 q9WyH4aBRR3O5KkwpzXp27uoVr0nRs+htnzjOkaiczX6sApEh/8XxL4zy99h9ifyLevB hWRNxeXWnpIc83/ShDlThZFXivuI2Z0lomc0/oVfSDlmKmaIWGDOPZNzRbICef6zdfPs CeFKIqyemD1Go0i7gCE+y6m+ZsUHN8Snlah6+TvEGp8QY6U+qcfMCZCWyomW08ruNeiM Pw3gHi5jtrPB4hAJDaUXEZhHis5Ao32MLOqQJP2QVJEXNniyCBEtcjV9CHmOqPQRs8+H puWA== X-Gm-Message-State: ABuFfohQ2GrxbbKQkpdbYZirvlMrcyvRq9yVizziNFulhSgJDx2x9iu/ uIP7MfUqGcgbxvnUg2DOFAk= X-Received: by 2002:a1c:4c16:: with SMTP id z22-v6mr5095020wmf.89.1539354125256; Fri, 12 Oct 2018 07:22:05 -0700 (PDT) Received: from [172.16.1.192] (host-89-243-172-161.as13285.net. [89.243.172.161]) by smtp.gmail.com with ESMTPSA id 143-v6sm1730294wmv.6.2018.10.12.07.22.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 07:22:04 -0700 (PDT) Subject: Re: [PATCH 03/34] teach move_mount(2) to work with OPEN_TREE_CLONE [ver #12] To: David Howells Cc: viro@zeniv.linux.org.uk, torvalds@linux-foundation.org, ebiederm@xmission.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, mszeredi@redhat.com References: <5c6f3d62-4cec-2aea-4693-62928611c526@gmail.com> <153754740781.17872.7869536526927736855.stgit@warthog.procyon.org.uk> <153754743491.17872.12115848333103740766.stgit@warthog.procyon.org.uk> <862e36a2-2a6f-4e26-3228-8cab4b4cf230@gmail.com> <25990.1539174969@warthog.procyon.org.uk> From: Alan Jenkins Message-ID: <02ae06f0-b6af-7f3e-8ccf-b3d80d7e27b0@gmail.com> Date: Fri, 12 Oct 2018 15:22:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <25990.1539174969@warthog.procyon.org.uk> Content-Type: multipart/mixed; boundary="------------F25C7A29E5A46BE6833D0F14" Content-Language: en-GB Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a multi-part message in MIME format. --------------F25C7A29E5A46BE6833D0F14 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 10/10/2018 13:36, David Howells wrote: > Alan Jenkins wrote: > >> + * Copyright (C) 2017 Red Hat, Inc. All Rights Reserved. >> + * Written by David Howells (dhowells@redhat.com) > Do you want to update that and I can take them into my patchset? > > David Sure :).  I've attached a slightly updated version. Thanks Alan --------------F25C7A29E5A46BE6833D0F14 Content-Type: text/x-patch; name="0001-vfs-tiny-sample-programs-for-open_tree-and-move_moun.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-vfs-tiny-sample-programs-for-open_tree-and-move_moun.pa"; filename*1="tch" From d9cbfa3398fe9e6269cc76429220d1fc1990b474 Mon Sep 17 00:00:00 2001 From: Alan Jenkins Date: Fri, 12 Oct 2018 11:11:13 +0100 Subject: [PATCH] vfs: tiny sample programs for open_tree() and move_mount() A couple of utility commands for fd-based mounts. They were useful to reproduce three different issues, in the original implementation of the system calls. Also add .gitignore for all the vfs samples. Signed-off-by: Alan Jenkins --- samples/vfs/.gitignore | 4 +++ samples/vfs/Makefile | 4 +++ samples/vfs/move_mount.c | 42 ++++++++++++++++++++++ samples/vfs/open_tree_clone.c | 65 +++++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 samples/vfs/.gitignore create mode 100644 samples/vfs/move_mount.c create mode 100644 samples/vfs/open_tree_clone.c diff --git a/samples/vfs/.gitignore b/samples/vfs/.gitignore new file mode 100644 index 000000000000..242ed23f90d2 --- /dev/null +++ b/samples/vfs/.gitignore @@ -0,0 +1,4 @@ +open_tree_clone +move_mount +test-fsmount +test-statx diff --git a/samples/vfs/Makefile b/samples/vfs/Makefile index 4ac9690fb3c4..3a5bb48d21a0 100644 --- a/samples/vfs/Makefile +++ b/samples/vfs/Makefile @@ -1,10 +1,14 @@ # List of programs to build hostprogs-$(CONFIG_SAMPLE_VFS) := \ + open_tree_clone \ + move_mount \ test-fsmount \ test-statx # Tell kbuild to always build the programs always := $(hostprogs-y) +HOSTCFLAGS_open_tree_clone.o += -I$(objtree)/usr/include +HOSTCFLAGS_move_mount.o += -I$(objtree)/usr/include HOSTCFLAGS_test-fsmount.o += -I$(objtree)/usr/include HOSTCFLAGS_test-statx.o += -I$(objtree)/usr/include diff --git a/samples/vfs/move_mount.c b/samples/vfs/move_mount.c new file mode 100644 index 000000000000..2cc9d876078a --- /dev/null +++ b/samples/vfs/move_mount.c @@ -0,0 +1,42 @@ +/* fd-based mount utility. + * + * Copyright (C) 2018 Alan Jenkins (alan.christopher.jenkins@gmail.com). + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public Licence + * as published by the Free Software Foundation; either version + * 2 of the Licence, or (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include + +static inline int move_mount(int from_dfd, const char *from_pathname, + int to_dfd, const char *to_pathname, + unsigned int flags) +{ + return syscall(__NR_move_mount, + from_dfd, from_pathname, + to_dfd, to_pathname, flags); +} + +int main(int argc, char *argv[]) +{ + if (argc != 1) { + fprintf(stderr, "Usage: move_mount 3 +#include +#include +#include +#include +#include +#include +#include + +#ifndef AT_RECURSIVE +#define AT_RECURSIVE 0x8000 +#endif + +#define E(x) do { if ((x) == -1) { perror(#x); exit(1); } } while(0) + +static inline int open_tree(int dfd, const char *pathname, unsigned flags) +{ + return syscall(__NR_open_tree, dfd, pathname, flags); +} + +int main(int argc, char *argv[]) +{ + int fd_number; + char **command; + int mfd; + + if (argc < 3 || !isdigit(argv[1][0])) { + fprintf(stderr, "Usage: 3