aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/fdescfs/fdesc_vfsops.c
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2017-08-01 03:40:19 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2017-08-01 03:40:19 +0000
commit77d3337c9f2e72cf8c85b0ed8cfa440c459a6bab (patch)
tree2b348035ac1e30ee3671edd13eec403cdb132a32 /sys/fs/fdescfs/fdesc_vfsops.c
parentd2ffc7af304d3e8505006d89239cc9936bd71720 (diff)
downloadsrc-77d3337c9f2e72cf8c85b0ed8cfa440c459a6bab.tar.gz
src-77d3337c9f2e72cf8c85b0ed8cfa440c459a6bab.zip
Implement proper Linux /dev/fd and /proc/self/fd behavior by adding
Linux specific things to the native fdescfs file system. Unlike FreeBSD, the Linux fdescfs is a directory containing a symbolic links to the actual files, which the process has open. A readlink(2) call on this file returns a full path in case of regular file or a string in a special format (type:[inode], anon_inode:<file-type>, etc..). As well as in a FreeBSD, opening the file in the Linux fdescfs directory is equivalent to duplicating the corresponding file descriptor. Here we have mutually exclusive requirements: - in case of readlink(2) call fdescfs lookup() method should return VLNK vnode otherwise our kern_readlink() fail with EINVAL error; - in the other calls fdescfs lookup() method should return non VLNK vnode. For what new vnode v_flag VV_READLINK was added, which is set if fdescfs has beed mounted with linrdlnk option an modified kern_readlinkat() to properly handle it. For now For Linux ABI compatibility mount fdescfs volume with linrdlnk option: mount -t fdescfs -o linrdlnk null /compat/linux/dev/fd Reviewed by: kib@ MFC after: 1 week Relnotes: yes
Notes
Notes: svn path=/head/; revision=321839
Diffstat (limited to 'sys/fs/fdescfs/fdesc_vfsops.c')
-rw-r--r--sys/fs/fdescfs/fdesc_vfsops.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/fs/fdescfs/fdesc_vfsops.c b/sys/fs/fdescfs/fdesc_vfsops.c
index ef5fd5e4afab..f63eea35581c 100644
--- a/sys/fs/fdescfs/fdesc_vfsops.c
+++ b/sys/fs/fdescfs/fdesc_vfsops.c
@@ -101,6 +101,8 @@ fdesc_mount(struct mount *mp)
*/
mp->mnt_data = fmp;
fmp->flags = 0;
+ if (vfs_getopt(mp->mnt_optnew, "linrdlnk", NULL, NULL) == 0)
+ fmp->flags |= FMNT_LINRDLNKF;
error = fdesc_allocvp(Froot, -1, FD_ROOT, mp, &rvp);
if (error) {
free(fmp, M_FDESCMNT);