Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3087736ybb; Mon, 6 Apr 2020 01:37:14 -0700 (PDT) X-Google-Smtp-Source: APiQypJQChtX7U7I4/IltENi7x4t47/52PutfHU1mLrDN7Hp4ASKyCZ6sBjcRDzSo4x9ZSuToqaa X-Received: by 2002:a9d:3a62:: with SMTP id j89mr15373523otc.45.1586162234113; Mon, 06 Apr 2020 01:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586162234; cv=none; d=google.com; s=arc-20160816; b=RvxNRjKAlb3fOLjJCZFbKUeFpur2wMu1eIluzn2BS6ZFPNThklNl/dEOxUNtFrL7m2 ShdmvjHD8zvjgxYgPue5Je/jWx8C01jD6zZFryFOTM5R+oHLJpcjmsBpJtJn0Z/YxFPV jNH48L741iVkAUb7Ae1l11nsABYgu6oHNkhdVwprf7KkV/jO0yZTR4bZoS60oAfJeU3z AA02TFx15KgqNDglkmcPJHt+QBsWxAQfojnD6RXJQ36KUBvAMUKhYAcGH4aN5cCLLhvS kVKlCXWcdiU56ZFe2va+otqGotbyVzCpyiYmK6k0lU047zm0YzzNgHunkUCus0Mdln+i E1iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rpWT0MDD1UpkdCBjt4GwmUUuDmZT2CiV8oFjv2FSbJc=; b=kudAuAaS358YhL3jl5HhNeUK7b3baiiokPgSG7kpIDiFgGvvaF7h+tK5aavxkuS+TQ MYYGWtS7e0qsIvNQ9gbKPoUu5qExWUnScSxh3SlfkwywU9gExkJ6oAE7BtACbsRRo/dy S/CekNDvbvoKdgbyAc/OMK9eGsNyWqFTz4sEVuN6biwYYYKA2ZqDRGuH608YHy/wIxJ5 tsIAkmE+En3iHyfl0JOb1d71PJdd3uQ05tZQzE/tNuNklq+GqoEVJtBwxI1zrqdZuH4+ TWJA6k+xZETgwT7yRk58oINLa4URNwP3xesA3BYMOd9tRh7pn6pUj/bYy41jd8XOKHiQ AGpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=FIQ2U20C; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si7195228otc.287.2020.04.06.01.37.02; Mon, 06 Apr 2020 01:37:14 -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=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=FIQ2U20C; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726632AbgDFIgM (ORCPT + 99 others); Mon, 6 Apr 2020 04:36:12 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:34809 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726533AbgDFIgM (ORCPT ); Mon, 6 Apr 2020 04:36:12 -0400 Received: by mail-ed1-f68.google.com with SMTP id o1so18234376edv.1 for ; Mon, 06 Apr 2020 01:36:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rpWT0MDD1UpkdCBjt4GwmUUuDmZT2CiV8oFjv2FSbJc=; b=FIQ2U20CLFrpOgJbE6xj4ai+Rnc4E5kQ/LBDi4blhwf+5onbkwT/M+Gd5RPhR9tnuv zaaYj6J4xLttvLdfS72P9zuIAxhckvPYgRuzZ8VPVpsP7V/K+suG3F4D0oaBg313A6jW uq/Nox6b6glJaYpZBI+S86tXlw5VzZk0oNqH4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rpWT0MDD1UpkdCBjt4GwmUUuDmZT2CiV8oFjv2FSbJc=; b=aB803J8i/0FOCdNJR2DqrN5LmapXJbXftHeabKJNn0b/E2Kjq2Wj3Z+Jdc3iM24lPg IwDeCF7TvTUH7GJRpYUjghU0zh9d7qdp11or9P8/pSRDrfB9VxGJ4RIQRFlH1mijPSfp 7QpVuHaJqg6AfF3mM451rV2I12ZpPPNxAKyDyMR8CK+fIL9ZzDjxnq9lC+sRqQ/sxRq1 GT2Y2386R2WV7+rsLPc1l6+4bHJ6HzYgfUlJk4s0PqdhB2/E5Dl4o0mdYZPVEM0jTe2y lZCkiyvlqH4jBfQvwVInrX4AzDmcCVQ/TcLjc9VIbpG1Yy+WQ0jjeRYPw1JSFCpFFPOH +6kQ== X-Gm-Message-State: AGi0PuaYs8zgsrQEN9lagEJjAmOHP363Yu4GH+sIwpjkqHcNGnhNJB2U FtrkBiF8WuD/srGXbv2QU6lH1mwk2VxBWRt9rjPvHQ== X-Received: by 2002:a05:6402:160e:: with SMTP id f14mr18573307edv.301.1586162167356; Mon, 06 Apr 2020 01:36:07 -0700 (PDT) MIME-Version: 1.0 References: <20200401144109.GA29945@gardel-login> <2590640.1585757211@warthog.procyon.org.uk> <36e45eae8ad78f7b8889d9d03b8846e78d735d28.camel@themaw.net> <27994c53034c8f769ea063a54169317c3ee62c04.camel@themaw.net> <20200403111144.GB34663@gardel-login> <20200403151223.GB34800@gardel-login> <20200403203024.GB27105@fieldses.org> In-Reply-To: <20200403203024.GB27105@fieldses.org> From: Miklos Szeredi Date: Mon, 6 Apr 2020 10:35:55 +0200 Message-ID: Subject: Re: Upcoming: Notifications, FS notifications and fsinfo() To: "J. Bruce Fields" Cc: Lennart Poettering , Ian Kent , David Howells , Christian Brauner , Linus Torvalds , Al Viro , dray@redhat.com, Karel Zak , Miklos Szeredi , Steven Whitehouse , Jeff Layton , andres@anarazel.de, keyrings@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Aleksa Sarai Content-Type: multipart/mixed; boundary="0000000000008acd9805a29b28ff" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0000000000008acd9805a29b28ff Content-Type: text/plain; charset="UTF-8" On Fri, Apr 3, 2020 at 10:30 PM J. Bruce Fields wrote: > > On Fri, Apr 03, 2020 at 05:12:23PM +0200, Lennart Poettering wrote: > > BTW, while we are at it: one more thing I'd love to see exposed by > > statx() is a simple flag whether the inode is a mount point. There's > > plenty code that implements a test like this all over the place, and > > it usually isn't very safe. There's one implementation in util-linux > > for example (in the /usr/bin/mountpoint binary), and another one in > > systemd. Would be awesome to just have a statx() return flag for that, > > that would make things *so* much easier and more robust. because in > > fact most code isn't very good that implements this, as much of it > > just compares st_dev of the specified file and its parent. Better code > > compares the mount ID, but as mentioned that's not as pretty as it > > could be so far... > > nfs-utils/support/misc/mountpoint.c:check_is_mountpoint() stats the file > and ".." and returns true if they have different st_dev or the same > st_ino. Comparing mount ids sounds better. > > So anyway, yes, everybody reinvents the wheel here, and this would be > useful. (And, yes, we want to know for the vfsmount, we don't care > whether the same inode is used as a mountpoint someplace else.) Attaching a patch. There's some ambiguity about what is a "mountpoint" and what these tools are interested in. My guess is that they are not interested in an object being a mount point (something where another object is mounted) but being a mount root (this is the object mounted at the mount point). I.e fd = open("/mnt", O_PATH); mount("/bin", "/mnt", NULL, MS_BIND, NULL); statx(AT_FDCWD, "/mnt", 0, 0, &stx1); statx(fd, "", AT_EMPTY_PATH, 0, &stx2); printf("mount_root(/mnt) = %c, mount_root(fd) = %c\n", stx1.stx_attributes & STATX_ATTR_MOUNT_ROOT ? 'y' : 'n', stx2.stx_attributes & STATX_ATTR_MOUNT_ROOT ? 'y' : 'n'); Would print: mount_root(/mnt) = y, mount_root(fd) = n Thanks, Miklos --0000000000008acd9805a29b28ff Content-Type: text/x-patch; charset="US-ASCII"; name="statx-add-mount_root.patch" Content-Disposition: attachment; filename="statx-add-mount_root.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k8o7ysgp0 RnJvbTogTWlrbG9zIFN6ZXJlZGkgPG1zemVyZWRpQHJlZGhhdC5jb20+ClN1YmplY3Q6IHN0YXR4 OiBhZGQgbW91bnRfcm9vdAoKRGV0ZXJtaW5pbmcgd2hldGhlciBhIHBhdGggb3IgZmlsZSBkZXNj cmlwdG9yIHJlZmVycyB0byBhIG1vdW50cG9pbnQgKG9yCm1vcmUgcHJlY2lzZWx5IGEgbW91bnQg cm9vdCkgaXMgbm90IHRyaXZpYWwgdXNpbmcgY3VycmVudCB0b29scy4KCkFkZCBhIGZsYWcgdG8g c3RhdHggdGhhdCBpbmRpY2F0ZXMgd2hldGhlciB0aGUgcGF0aCBvciBmZCByZWZlcnMgdG8gdGhl CnJvb3Qgb2YgYSBtb3VudCBvciBub3QuCgpSZXBvcnRlZC1ieTogTGVubmFydCBQb2V0dGVyaW5n IDxtenhyZWFyeUAwcG9pbnRlci5kZT4KUmVwb3J0ZWQtYnk6IEouIEJydWNlIEZpZWxkcyA8YmZp ZWxkc0BmaWVsZHNlcy5vcmc+ClNpZ25lZC1vZmYtYnk6IE1pa2xvcyBTemVyZWRpIDxtc3plcmVk aUByZWRoYXQuY29tPgotLS0KIGZzL3N0YXQuYyAgICAgICAgICAgICAgICAgfCAgICAzICsrKwog aW5jbHVkZS91YXBpL2xpbnV4L3N0YXQuaCB8ICAgIDEgKwogMiBmaWxlcyBjaGFuZ2VkLCA0IGlu c2VydGlvbnMoKykKCi0tLSBhL2luY2x1ZGUvdWFwaS9saW51eC9zdGF0LmgKKysrIGIvaW5jbHVk ZS91YXBpL2xpbnV4L3N0YXQua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