aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2017-12-19 22:39:05 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2017-12-19 22:39:05 +0000
commitb501cc5da6f8e10d354ace1befbf59737543eb30 (patch)
treece6caa546b7b98b4b622de74c587481ca0a6b7c4
parentff46fd16e53f4e3b70c7c5e816a8d62892a41e43 (diff)
downloadsrc-b501cc5da6f8e10d354ace1befbf59737543eb30.tar.gz
src-b501cc5da6f8e10d354ace1befbf59737543eb30.zip
Rework pathconf handling for FIFOs.
On the one hand, FIFOs should respect other variables not supported by the fifofs vnode operation (such as _PC_NAME_MAX, _PC_LINK_MAX, etc.). These values are fs-specific and must come from a fs-specific method. On the other hand, filesystems that support FIFOs are required to support _PC_PIPE_BUF on directory vnodes that can contain FIFOs. Given this latter requirement, once the fs-specific VOP_PATHCONF method supports _PC_PIPE_BUF for directories, it is also suitable for FIFOs permitting a single VOP_PATHCONF method to be used for both FIFOs and non-FIFOs. To that end, retire all of the FIFO-specific pathconf methods from filesystems and change FIFO-specific vnode operation switches to use the existing fs-specific VOP_PATHCONF method. For fifofs, set it's VOP_PATHCONF to VOP_PANIC since it should no longer be used. While here, move _PC_PIPE_BUF handling out of vop_stdpathconf() so that only filesystems supporting FIFOs will report a value. In addition, only report a valid _PC_PIPE_BUF for directories and FIFOs. Discussed with: bde Reviewed by: kib (part of a larger patch) MFC after: 1 month Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D12572
Notes
Notes: svn path=/head/; revision=327004
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c28
-rw-r--r--sys/fs/ext2fs/ext2_vnops.c7
-rw-r--r--sys/fs/fifofs/fifo_vnops.c2
-rw-r--r--sys/fs/nandfs/nandfs_vnops.c7
-rw-r--r--sys/fs/nfsclient/nfs_clvnops.c7
-rw-r--r--sys/fs/tmpfs/tmpfs_fifoops.c1
-rw-r--r--sys/fs/tmpfs/tmpfs_vnops.c10
-rw-r--r--sys/fs/tmpfs/tmpfs_vnops.h1
-rw-r--r--sys/fs/udf/udf_vnops.c7
-rw-r--r--sys/kern/vfs_default.c3
-rw-r--r--sys/ufs/ufs/ufs_vnops.c33
11 files changed, 54 insertions, 52 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
index def820a2f138..861469d93a8e 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
@@ -5414,31 +5414,17 @@ zfs_freebsd_pathconf(ap)
case _PC_NAME_MAX:
*ap->a_retval = NAME_MAX;
return (0);
+ case _PC_PIPE_BUF:
+ if (ap->a_vp->v_type == VDIR || ap->a_vp->v_type == VFIFO) {
+ *ap->a_retval = PIPE_BUF;
+ return (0);
+ }
+ return (EINVAL);
default:
return (vop_stdpathconf(ap));
}
}
-static int
-zfs_freebsd_fifo_pathconf(ap)
- struct vop_pathconf_args /* {
- struct vnode *a_vp;
- int a_name;
- register_t *a_retval;
- } */ *ap;
-{
-
- switch (ap->a_name) {
- case _PC_ACL_EXTENDED:
- case _PC_ACL_NFS4:
- case _PC_ACL_PATH_MAX:
- case _PC_MAC_PRESENT:
- return (zfs_freebsd_pathconf(ap));
- default:
- return (fifo_specops.vop_pathconf(ap));
- }
-}
-
/*
* FreeBSD's extended attributes namespace defines file name prefix for ZFS'
* extended attribute name:
@@ -6050,7 +6036,7 @@ struct vop_vector zfs_fifoops = {
.vop_reclaim = zfs_freebsd_reclaim,
.vop_setattr = zfs_freebsd_setattr,
.vop_write = VOP_PANIC,
- .vop_pathconf = zfs_freebsd_fifo_pathconf,
+ .vop_pathconf = zfs_freebsd_pathconf,
.vop_fid = zfs_freebsd_fid,
.vop_getacl = zfs_freebsd_getacl,
.vop_setacl = zfs_freebsd_setacl,
diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c
index 83f0281a083c..5a28c88ced80 100644
--- a/sys/fs/ext2fs/ext2_vnops.c
+++ b/sys/fs/ext2fs/ext2_vnops.c
@@ -180,6 +180,7 @@ struct vop_vector ext2_fifoops = {
.vop_getattr = ext2_getattr,
.vop_inactive = ext2_inactive,
.vop_kqfilter = ext2fifo_kqfilter,
+ .vop_pathconf = ext2_pathconf,
.vop_print = ext2_print,
.vop_read = VOP_PANIC,
.vop_reclaim = ext2_reclaim,
@@ -1636,6 +1637,12 @@ ext2_pathconf(struct vop_pathconf_args *ap)
case _PC_NAME_MAX:
*ap->a_retval = NAME_MAX;
break;
+ case _PC_PIPE_BUF:
+ if (ap->a_vp->v_type == VDIR || ap->a_vp->v_type == VFIFO)
+ *ap->a_retval = PIPE_BUF;
+ else
+ error = EINVAL;
+ break;
case _PC_CHOWN_RESTRICTED:
*ap->a_retval = 1;
break;
diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c
index 8cb1a4062cd4..96dd05a18323 100644
--- a/sys/fs/fifofs/fifo_vnops.c
+++ b/sys/fs/fifofs/fifo_vnops.c
@@ -88,7 +88,7 @@ struct vop_vector fifo_specops = {
.vop_mkdir = VOP_PANIC,
.vop_mknod = VOP_PANIC,
.vop_open = fifo_open,
- .vop_pathconf = vop_stdpathconf,
+ .vop_pathconf = VOP_PANIC,
.vop_print = fifo_print,
.vop_read = VOP_PANIC,
.vop_readdir = VOP_PANIC,
diff --git a/sys/fs/nandfs/nandfs_vnops.c b/sys/fs/nandfs/nandfs_vnops.c
index a8223db19dd2..0e4e5a593896 100644
--- a/sys/fs/nandfs/nandfs_vnops.c
+++ b/sys/fs/nandfs/nandfs_vnops.c
@@ -2244,6 +2244,12 @@ nandfs_pathconf(struct vop_pathconf_args *ap)
case _PC_NAME_MAX:
*ap->a_retval = NANDFS_NAME_LEN;
break;
+ case _PC_PIPE_BUF:
+ if (ap->a_vp->v_type == VDIR || ap->a_vp->v_type == VFIFO)
+ *ap->a_retval = PIPE_BUF;
+ else
+ error = EINVAL;
+ break;
case _PC_CHOWN_RESTRICTED:
*ap->a_retval = 1;
break;
@@ -2414,6 +2420,7 @@ struct vop_vector nandfs_fifoops = {
.vop_close = nandfsfifo_close,
.vop_getattr = nandfs_getattr,
.vop_inactive = nandfs_inactive,
+ .vop_pathconf = nandfs_pathconf,
.vop_print = nandfs_print,
.vop_read = VOP_PANIC,
.vop_reclaim = nandfs_reclaim,
diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index fd9ecb0d210f..27ff9e29470a 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -189,6 +189,7 @@ struct vop_vector newnfs_fifoops = {
.vop_fsync = nfs_fsync,
.vop_getattr = nfs_getattr,
.vop_inactive = ncl_inactive,
+ .vop_pathconf = nfs_pathconf,
.vop_print = nfs_print,
.vop_read = nfsfifo_read,
.vop_reclaim = ncl_reclaim,
@@ -3465,6 +3466,12 @@ nfs_pathconf(struct vop_pathconf_args *ap)
case _PC_NAME_MAX:
*ap->a_retval = pc.pc_namemax;
break;
+ case _PC_PIPE_BUF:
+ if (ap->a_vp->v_type == VDIR || ap->a_vp->v_type == VFIFO)
+ *ap->a_retval = PIPE_BUF;
+ else
+ error = EINVAL;
+ break;
case _PC_CHOWN_RESTRICTED:
*ap->a_retval = pc.pc_chownrestricted;
break;
diff --git a/sys/fs/tmpfs/tmpfs_fifoops.c b/sys/fs/tmpfs/tmpfs_fifoops.c
index eb206ff69068..7719fd38cfb0 100644
--- a/sys/fs/tmpfs/tmpfs_fifoops.c
+++ b/sys/fs/tmpfs/tmpfs_fifoops.c
@@ -71,5 +71,6 @@ struct vop_vector tmpfs_fifoop_entries = {
.vop_access = tmpfs_access,
.vop_getattr = tmpfs_getattr,
.vop_setattr = tmpfs_setattr,
+ .vop_pathconf = tmpfs_pathconf,
.vop_print = tmpfs_print,
};
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c
index 15dc86610ea6..78402f3886b1 100644
--- a/sys/fs/tmpfs/tmpfs_vnops.c
+++ b/sys/fs/tmpfs/tmpfs_vnops.c
@@ -1338,9 +1338,10 @@ tmpfs_print(struct vop_print_args *v)
return 0;
}
-static int
+int
tmpfs_pathconf(struct vop_pathconf_args *v)
{
+ struct vnode *vp = v->a_vp;
int name = v->a_name;
register_t *retval = v->a_retval;
@@ -1357,6 +1358,13 @@ tmpfs_pathconf(struct vop_pathconf_args *v)
*retval = NAME_MAX;
break;
+ case _PC_PIPE_BUF:
+ if (vp->v_type == VDIR || vp->v_type == VFIFO)
+ *retval = PIPE_BUF;
+ else
+ error = EINVAL;
+ break;
+
case _PC_CHOWN_RESTRICTED:
*retval = 1;
break;
diff --git a/sys/fs/tmpfs/tmpfs_vnops.h b/sys/fs/tmpfs/tmpfs_vnops.h
index eac37a1a56e8..2f89e15629dd 100644
--- a/sys/fs/tmpfs/tmpfs_vnops.h
+++ b/sys/fs/tmpfs/tmpfs_vnops.h
@@ -51,6 +51,7 @@ extern struct vop_vector tmpfs_vnodeop_nonc_entries;
vop_access_t tmpfs_access;
vop_getattr_t tmpfs_getattr;
vop_setattr_t tmpfs_setattr;
+vop_pathconf_t tmpfs_pathconf;
vop_print_t tmpfs_print;
vop_reclaim_t tmpfs_reclaim;
diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c
index 0e1a30054614..6e7706c5c7c5 100644
--- a/sys/fs/udf/udf_vnops.c
+++ b/sys/fs/udf/udf_vnops.c
@@ -102,6 +102,7 @@ struct vop_vector udf_fifoops = {
.vop_default = &fifo_specops,
.vop_access = udf_access,
.vop_getattr = udf_getattr,
+ .vop_pathconf = udf_pathconf,
.vop_print = udf_print,
.vop_reclaim = udf_reclaim,
.vop_setattr = udf_setattr,
@@ -400,6 +401,12 @@ udf_pathconf(struct vop_pathconf_args *a)
case _PC_NO_TRUNC:
*a->a_retval = 1;
return (0);
+ case _PC_PIPE_BUF:
+ if (a->a_vp->v_type == VDIR || a->a_vp->v_type == VFIFO) {
+ *a->a_retval = PIPE_BUF;
+ return (0);
+ }
+ return (EINVAL);
default:
return (vop_stdpathconf(a));
}
diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c
index 7f263d364266..734c2f2e6011 100644
--- a/sys/kern/vfs_default.c
+++ b/sys/kern/vfs_default.c
@@ -482,9 +482,6 @@ vop_stdpathconf(ap)
case _PC_PATH_MAX:
*ap->a_retval = PATH_MAX;
return (0);
- case _PC_PIPE_BUF:
- *ap->a_retval = PIPE_BUF;
- return (0);
default:
return (EINVAL);
}
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index f7861fc4aa16..018a6a0e74e9 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -124,7 +124,6 @@ static vop_symlink_t ufs_symlink;
static vop_whiteout_t ufs_whiteout;
static vop_close_t ufsfifo_close;
static vop_kqfilter_t ufsfifo_kqfilter;
-static vop_pathconf_t ufsfifo_pathconf;
SYSCTL_NODE(_vfs, OID_AUTO, ufs, CTLFLAG_RD, 0, "UFS filesystem");
@@ -2406,30 +2405,6 @@ ufsfifo_kqfilter(ap)
}
/*
- * Return POSIX pathconf information applicable to fifos.
- */
-static int
-ufsfifo_pathconf(ap)
- struct vop_pathconf_args /* {
- struct vnode *a_vp;
- int a_name;
- int *a_retval;
- } */ *ap;
-{
-
- switch (ap->a_name) {
- case _PC_ACL_EXTENDED:
- case _PC_ACL_NFS4:
- case _PC_ACL_PATH_MAX:
- case _PC_MAC_PRESENT:
- return (ufs_pathconf(ap));
- default:
- return (fifo_specops.vop_pathconf(ap));
- }
- /* NOTREACHED */
-}
-
-/*
* Return POSIX pathconf information applicable to ufs filesystems.
*/
static int
@@ -2450,6 +2425,12 @@ ufs_pathconf(ap)
case _PC_NAME_MAX:
*ap->a_retval = UFS_MAXNAMLEN;
break;
+ case _PC_PIPE_BUF:
+ if (ap->a_vp->v_type == VDIR || ap->a_vp->v_type == VFIFO)
+ *ap->a_retval = PIPE_BUF;
+ else
+ error = EINVAL;
+ break;
case _PC_CHOWN_RESTRICTED:
*ap->a_retval = 1;
break;
@@ -2803,7 +2784,7 @@ struct vop_vector ufs_fifoops = {
.vop_inactive = ufs_inactive,
.vop_kqfilter = ufsfifo_kqfilter,
.vop_markatime = ufs_markatime,
- .vop_pathconf = ufsfifo_pathconf,
+ .vop_pathconf = ufs_pathconf,
.vop_print = ufs_print,
.vop_read = VOP_PANIC,
.vop_reclaim = ufs_reclaim,