git: 9ef7a491a423 - main - nmount(MNT_UPDATE): add optional generid fsid parameter
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Oct 2023 16:41:39 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=9ef7a491a4236810e50f0a2ee8d52f5c4bb02c64
commit 9ef7a491a4236810e50f0a2ee8d52f5c4bb02c64
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-09-29 18:42:50 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-10-17 16:40:12 +0000
nmount(MNT_UPDATE): add optional generid fsid parameter
to check looked up path against specific mounted filesystem.
Reviewed by: mjg
Tested by: Andrew Gierth <andrew@tao146.riddles.org.uk>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D42023
---
sys/kern/vfs_mount.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 8364081585f8..aa4642c0ba8c 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -1313,9 +1313,10 @@ vfs_domount_update(
struct vnode *rootvp;
void *bufp;
struct mount *mp;
- int error, export_error, i, len;
+ int error, export_error, i, len, fsid_up_len;
uint64_t flag;
gid_t *grps;
+ fsid_t *fsid_up;
bool vfs_suser_failed;
ASSERT_VOP_ELOCKED(vp, __func__);
@@ -1378,10 +1379,24 @@ vfs_domount_update(
VI_UNLOCK(vp);
VOP_UNLOCK(vp);
+ rootvp = NULL;
+
+ if (vfs_getopt(*optlist, "fsid", (void **)&fsid_up,
+ &fsid_up_len) == 0) {
+ if (fsid_up_len != sizeof(*fsid_up)) {
+ error = EINVAL;
+ goto end;
+ }
+ if (fsidcmp(&fsid_up, &mp->mnt_stat.f_fsid) != 0) {
+ error = ENOENT;
+ goto end;
+ }
+ vfs_deleteopt(*optlist, "fsid");
+ }
+
vfs_op_enter(mp);
vn_seqc_write_begin(vp);
- rootvp = NULL;
MNT_ILOCK(mp);
if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0) {
MNT_IUNLOCK(mp);