diff --git a/share/man/man5/fdescfs.5 b/share/man/man5/fdescfs.5 --- a/share/man/man5/fdescfs.5 +++ b/share/man/man5/fdescfs.5 @@ -40,7 +40,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 17, 2021 +.Dd Jul 11, 2023 .Dt FDESCFS 5 .Os .Sh NAME @@ -94,6 +94,18 @@ volume with the .Cm linrdlnk option. +.It Cm rdlnk +Treat +.Nm +vnodes as symbolic links consistently, in particular, follow +the resolved name for the name lookups. +This option is strictly stronger than the +.Cm linrdlnk +option, it changes not only the type returned by +.Xr stat 2 , +but also causes the +.Nm +files to behave as symlinks. .El .Pp For diff --git a/sys/fs/fdescfs/fdesc.h b/sys/fs/fdescfs/fdesc.h --- 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 --- a/sys/fs/fdescfs/fdesc_vfsops.c +++ b/sys/fs/fdescfs/fdesc_vfsops.c @@ -100,6 +100,8 @@ 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 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -190,9 +190,12 @@ 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); if (error != 0) { vgone(vp); @@ -459,7 +462,7 @@ case Fdesc: vap->va_type = (VFSTOFDESC(vp->v_mount)->flags & - FMNT_LINRDLNKF) == 0 ? VCHR : VLNK; + (FMNT_RDLNKF | FMNT_LINRDLNKF)) == 0 ? VCHR : VLNK; vap->va_nlink = 1; vap->va_size = 0; vap->va_rdev = makedev(0, vap->va_fileid); @@ -577,8 +580,8 @@ 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; diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -4284,9 +4284,11 @@ strlcat(buf, "|VV_MD", sizeof(buf)); if (vp->v_vflag & VV_FORCEINSMQ) strlcat(buf, "|VV_FORCEINSMQ", sizeof(buf)); + if (vp->v_vflag & VV_READLINK) + strlcat(buf, "|VV_READLINK", sizeof(buf)); flags = vp->v_vflag & ~(VV_ROOT | VV_ISTTY | VV_NOSYNC | VV_ETERNALDEV | VV_CACHEDLABEL | VV_VMSIZEVNLOCK | VV_COPYONWRITE | VV_SYSTEM | - VV_PROCDEP | VV_DELETED | VV_MD | VV_FORCEINSMQ); + VV_PROCDEP | VV_DELETED | VV_MD | VV_FORCEINSMQ | VV_READLINK); if (flags != 0) { snprintf(buf2, sizeof(buf2), "|VV(0x%lx)", flags); strlcat(buf, buf2, sizeof(buf)); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -2677,7 +2677,7 @@ if (error != 0) return (error); #endif - if (vp->v_type != VLNK) + if (vp->v_type != VLNK && (vp->v_vflag & VV_READLINK) == 0) return (EINVAL); aiov.iov_base = buf; diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -270,7 +270,7 @@ #define VV_DELETED 0x0400 /* should be removed */ #define VV_MD 0x0800 /* vnode backs the md device */ #define VV_FORCEINSMQ 0x1000 /* force the insmntque to succeed */ -#define VV_UNUSED01 0x2000 /* was: fdescfs linux vnode */ +#define VV_READLINK 0x2000 /* fdescfs linux vnode */ #define VV_UNREF 0x4000 /* vunref, do not drop lock in inactive() */ #define VV_CROSSLOCK 0x8000 /* vnode lock is shared w/ root mounted here */