mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-03 12:35:02 +00:00
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
This commit is contained in:
parent
ff46fd16e5
commit
b501cc5da6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=327004
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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");
|
||||
|
||||
@ -2405,30 +2404,6 @@ ufsfifo_kqfilter(ap)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user