Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Jul 2023 01:18:21 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 3905309dfeeb - main - fdescfs: add a mount option rdlnk
Message-ID:  <202307130118.36D1IL2k005032@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib:

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

commit 3905309dfeeb89f03b09c347f7ac0a863faa3975
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-07-11 05:03:49 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-07-13 01:14:20 +0000

    fdescfs: add a mount option rdlnk
    
    which changes /dev/fd/N files types to symbolic link with the behavior
    of symbolic links.
    
    PR:     272127
    Reported by:    Peter Eriksson <pen@lysator.liu.se>
    Reviewed by:    dchagin
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D40969
---
 sys/fs/fdescfs/fdesc.h        |  1 +
 sys/fs/fdescfs/fdesc_vfsops.c |  2 ++
 sys/fs/fdescfs/fdesc_vnops.c  | 15 ++++++++++-----
 3 files changed, 13 insertions(+), 5 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 1c4b6d0c6cdb..9aa844360256 100644
--- a/sys/fs/fdescfs/fdesc_vnops.c
+++ b/sys/fs/fdescfs/fdesc_vnops.c
@@ -190,8 +190,12 @@ loop:
 	fd->fd_type = ftype;
 	fd->fd_fd = fd_fd;
 	fd->fd_ix = ix;
-	if (ftype == Fdesc && fmp->flags & FMNT_LINRDLNKF)
-		vp->v_vflag |= VV_READLINK;
+	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);
@@ -457,7 +461,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);
@@ -575,8 +580,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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307130118.36D1IL2k005032>