aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2023-07-11 05:03:49 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2023-07-13 01:14:20 +0000
commit3905309dfeeb89f03b09c347f7ac0a863faa3975 (patch)
treeae36ae9144f66dc4c06c0ef082108e9ee88b34d0
parent9c3bfe2ad07170cd7d3645a7c24f4d80a509c2b7 (diff)
downloadsrc-3905309dfeeb89f03b09c347f7ac0a863faa3975.tar.gz
src-3905309dfeeb89f03b09c347f7ac0a863faa3975.zip
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
-rw-r--r--sys/fs/fdescfs/fdesc.h1
-rw-r--r--sys/fs/fdescfs/fdesc_vfsops.c2
-rw-r--r--sys/fs/fdescfs/fdesc_vnops.c15
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;