The branch main has been updated by sjg:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a02d9cad77c1207eb809ba49fc1595c8ebb2da26

commit a02d9cad77c1207eb809ba49fc1595c8ebb2da26
Author:     Simon J. Gerraty <[email protected]>
AuthorDate: 2023-03-28 17:57:26 +0000
Commit:     Simon J. Gerraty <[email protected]>
CommitDate: 2023-03-28 17:57:26 +0000

    tarfs_mount allow control of vfs_mountedfrom
    
    We default to passing the path of the tar file to vfs_mountedfrom
    so we can tell where a filesystem was mounted from.
    However this can make the output of mount(8) hard to read.
    
    Allow things like:
    
            mount -t tarfs -o as=`basename $tar` $tar /mnt
    
    so "as" is recorded instead of $tar
    
    Reviewed by:    des
    Sponsored by:   Juniper Networks
    Differential Revision:  https://reviews.freebsd.org/D39273
---
 sys/fs/tarfs/tarfs_vfsops.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/sys/fs/tarfs/tarfs_vfsops.c b/sys/fs/tarfs/tarfs_vfsops.c
index 17d6814ba973..4489b41699ec 100644
--- a/sys/fs/tarfs/tarfs_vfsops.c
+++ b/sys/fs/tarfs/tarfs_vfsops.c
@@ -108,7 +108,7 @@ static vfs_statfs_t tarfs_statfs;
 static vfs_fhtovp_t    tarfs_fhtovp;
 
 static const char *tarfs_opts[] = {
-       "from", "gid", "mode", "uid", "verify",
+       "as", "from", "gid", "mode", "uid", "verify",
        NULL
 };
 
@@ -905,11 +905,11 @@ tarfs_mount(struct mount *mp)
        struct tarfs_mount *tmp = NULL;
        struct thread *td = curthread;
        struct vnode *vp;
-       char *from;
+       char *as, *from;
        uid_t root_uid;
        gid_t root_gid;
        mode_t root_mode;
-       int error, flags, len;
+       int error, flags, aslen, len;
 
        if (mp->mnt_flag & MNT_UPDATE)
                return (EOPNOTSUPP);
@@ -936,10 +936,14 @@ tarfs_mount(struct mount *mp)
        error = vfs_getopt(mp->mnt_optnew, "from", (void **)&from, &len);
        if (error != 0 || from[len - 1] != '\0')
                return (EINVAL);
+       error = vfs_getopt(mp->mnt_optnew, "as", (void **)&as, &aslen);
+       if (error != 0 || as[aslen - 1] != '\0')
+               as = from;
 
        /* Find the source tarball */
-       TARFS_DPF(FS, "%s(%s, uid=%u, gid=%u, mode=%o)\n", __func__,
-           from, root_uid, root_gid, root_mode);
+       TARFS_DPF(FS, "%s(%s%s%s, uid=%u, gid=%u, mode=%o)\n", __func__,
+           from, (as != from) ? " as " : "", (as != from) ? as : "",
+           root_uid, root_gid, root_mode);
        flags = FREAD;
        if (vfs_flagopt(mp->mnt_optnew, "verify", NULL, 0)) {
            flags |= O_VERIFY;
@@ -995,7 +999,7 @@ tarfs_mount(struct mount *mp)
        MNT_IUNLOCK(mp);
 
        vfs_getnewfsid(mp);
-       vfs_mountedfrom(mp, from);
+       vfs_mountedfrom(mp, as);
        TARFS_DPF(FS, "%s: success\n", __func__);
 
        return (0);

Reply via email to