The branch stable/13 has been updated by kib:

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

commit da56eae4404d4d273cc4a8b7d8f05547bb188599
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2023-07-11 05:03:49 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2023-07-20 12:20:09 +0000

    fdescfs: add a mount option rdlnk
    
    PR:     272127
    
    (cherry picked from commit 3905309dfeeb89f03b09c347f7ac0a863faa3975)
---
 sys/fs/fdescfs/fdesc.h        |  1 +
 sys/fs/fdescfs/fdesc_vfsops.c |  2 ++
 sys/fs/fdescfs/fdesc_vnops.c  | 16 ++++++++++------
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/sys/fs/fdescfs/fdesc.h b/sys/fs/fdescfs/fdesc.h
index 94682f42cdb3..b51ac9f32ac1 100644
--- a/sys/fs/fdescfs/fdesc.h
+++ b/sys/fs/fdescfs/fdesc.h
@@ -43,6 +43,7 @@
 #define FMNT_UNMOUNTF  0x01
 #define FMNT_LINRDLNKF 0x02
 #define        FMNT_NODUP      0x04
+#define FMNT_RDLNKF    0x08
 
 struct fdescmount {
        struct vnode    *f_root;        /* Root node */
diff --git a/sys/fs/fdescfs/fdesc_vfsops.c b/sys/fs/fdescfs/fdesc_vfsops.c
index 2961c3bf6224..d0d518245e92 100644
--- a/sys/fs/fdescfs/fdesc_vfsops.c
+++ b/sys/fs/fdescfs/fdesc_vfsops.c
@@ -100,6 +100,8 @@ fdesc_mount(struct mount *mp)
        fmp->flags = 0;
        if (vfs_getopt(mp->mnt_optnew, "linrdlnk", NULL, NULL) == 0)
                fmp->flags |= FMNT_LINRDLNKF;
+       if (vfs_getopt(mp->mnt_optnew, "rdlnk", NULL, NULL) == 0)
+               fmp->flags |= FMNT_RDLNKF;
        if (vfs_getopt(mp->mnt_optnew, "nodup", NULL, NULL) == 0)
                fmp->flags |= FMNT_NODUP;
        error = fdesc_allocvp(Froot, -1, FD_ROOT, mp, &rvp);
diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c
index 522009550986..13937dcbc6b5 100644
--- a/sys/fs/fdescfs/fdesc_vnops.c
+++ b/sys/fs/fdescfs/fdesc_vnops.c
@@ -204,9 +204,12 @@ loop:
        fd->fd_type = ftype;
        fd->fd_fd = fd_fd;
        fd->fd_ix = ix;
-       /* Cannot set v_type to VCHR */
-       if (ftype == Fdesc && (fmp->flags & FMNT_LINRDLNKF) != 0)
-               vp->v_type = VLNK;
+       if (ftype == Fdesc) {
+               if ((fmp->flags & FMNT_RDLNKF) != 0)
+                       vp->v_type = VLNK;
+               else if ((fmp->flags & FMNT_LINRDLNKF) != 0)
+                       vp->v_vflag |= VV_READLINK;
+       }
        error = insmntque1(vp, mp, fdesc_insmntque_dtr, NULL);
        if (error != 0) {
                *vpp = NULLVP;
@@ -469,7 +472,8 @@ fdesc_getattr(struct vop_getattr_args *ap)
                break;
 
        case Fdesc:
-               vap->va_type = (vp->v_vflag & VV_READLINK) == 0 ? VCHR : VLNK;
+               vap->va_type = (VFSTOFDESC(vp->v_mount)->flags &
+                   (FMNT_RDLNKF | FMNT_LINRDLNKF)) == 0 ? VCHR : VLNK;
                vap->va_nlink = 1;
                vap->va_size = 0;
                vap->va_rdev = makedev(0, vap->va_fileid);
@@ -587,8 +591,8 @@ fdesc_readdir(struct vop_readdir_args *ap)
                                break;
                        dp->d_namlen = sprintf(dp->d_name, "%d", fcnt);
                        dp->d_reclen = UIO_MX;
-                       dp->d_type = (fmp->flags & FMNT_LINRDLNKF) == 0 ?
-                           DT_CHR : DT_LNK;
+                       dp->d_type = (fmp->flags & (FMNT_RDLNKF |
+                           FMNT_LINRDLNKF)) == 0 ? DT_CHR : DT_LNK;
                        dp->d_fileno = i + FD_DESC;
                        dirent_terminate(dp);
                        break;

Reply via email to