Changeset View
Standalone View
sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c
| Show First 20 Lines • Show All 711 Lines • ▼ Show 20 Lines | if ((error = zfs_get_xattrdir(VTOZ(dvp), &zp, cr, flags))) { | ||||
| zfs_exit(zfsvfs, FTAG); | zfs_exit(zfsvfs, FTAG); | ||||
| return (error); | return (error); | ||||
| } | } | ||||
| *vpp = ZTOV(zp); | *vpp = ZTOV(zp); | ||||
| /* | /* | ||||
| * Do we have permission to get into attribute directory? | * Do we have permission to get into attribute directory? | ||||
| */ | */ | ||||
| error = zfs_zaccess(zp, ACE_EXECUTE, 0, B_FALSE, cr, NULL); | if (flags & LOOKUP_NAMED_ATTR) | ||||
| error = zfs_zaccess(zp, ACE_EXECUTE, V_NAMEDATTR, | |||||
| B_FALSE, cr, NULL); | |||||
| else | |||||
| error = zfs_zaccess(zp, ACE_EXECUTE, 0, B_FALSE, cr, | |||||
| NULL); | |||||
| if (error) { | if (error) { | ||||
| vrele(ZTOV(zp)); | vrele(ZTOV(zp)); | ||||
| } | } | ||||
| zfs_exit(zfsvfs, FTAG); | zfs_exit(zfsvfs, FTAG); | ||||
| return (error); | return (error); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 3,746 Lines • ▼ Show 20 Lines | if (ap->a_accmode == VEXEC) { | ||||
| if (zfs_fastaccesschk_execute(zp, ap->a_cred) == 0) | if (zfs_fastaccesschk_execute(zp, ap->a_cred) == 0) | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| /* | /* | ||||
| * ZFS itself only knowns about VREAD, VWRITE, VEXEC and VAPPEND, | * ZFS itself only knowns about VREAD, VWRITE, VEXEC and VAPPEND, | ||||
| */ | */ | ||||
| accmode = ap->a_accmode & (VREAD|VWRITE|VEXEC|VAPPEND); | accmode = ap->a_accmode & (VREAD|VWRITE|VEXEC|VAPPEND); | ||||
| if (accmode != 0) | if (accmode != 0) { | ||||
| #if __FreeBSD_version >= 1500040 | |||||
| /* For named attributes, do the checks. */ | |||||
| if ((vn_irflag_read(vp) & VIRF_NAMEDATTR) != 0) | |||||
| error = zfs_access(zp, accmode, V_NAMEDATTR, | |||||
| ap->a_cred); | |||||
| else | |||||
| #endif | |||||
| error = zfs_access(zp, accmode, 0, ap->a_cred); | error = zfs_access(zp, accmode, 0, ap->a_cred); | ||||
| } | |||||
| /* | /* | ||||
| * VADMIN has to be handled by vaccess(). | * VADMIN has to be handled by vaccess(). | ||||
| */ | */ | ||||
| if (error == 0) { | if (error == 0) { | ||||
| accmode = ap->a_accmode & ~(VREAD|VWRITE|VEXEC|VAPPEND); | accmode = ap->a_accmode & ~(VREAD|VWRITE|VEXEC|VAPPEND); | ||||
| if (accmode != 0) { | if (accmode != 0) { | ||||
| error = vaccess(vp->v_type, zp->z_mode, zp->z_uid, | error = vaccess(vp->v_type, zp->z_mode, zp->z_uid, | ||||
| Show All 15 Lines | |||||
| #ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||
| struct vop_lookup_args { | struct vop_lookup_args { | ||||
| struct vnode *a_dvp; | struct vnode *a_dvp; | ||||
| struct vnode **a_vpp; | struct vnode **a_vpp; | ||||
| struct componentname *a_cnp; | struct componentname *a_cnp; | ||||
| }; | }; | ||||
| #endif | #endif | ||||
| #if __FreeBSD_version >= 1500040 | |||||
| static int | |||||
| zfs_lookup_nameddir(struct vnode *dvp, struct componentname *cnp, | |||||
| struct vnode **vpp) | |||||
| { | |||||
| struct vnode *xvp; | |||||
| int error, flags; | |||||
| *vpp = NULL; | |||||
| flags = LOOKUP_XATTR | LOOKUP_NAMED_ATTR; | |||||
| if ((cnp->cn_flags & CREATENAMED) != 0) | |||||
| flags |= CREATE_XATTR_DIR; | |||||
| error = zfs_lookup(dvp, NULL, &xvp, NULL, 0, cnp->cn_cred, flags, | |||||
| B_FALSE); | |||||
| if (error == 0) { | |||||
| if ((cnp->cn_flags & LOCKLEAF) != 0) | |||||
| error = vn_lock(xvp, cnp->cn_lkflags); | |||||
| if (error == 0) { | |||||
| vn_irflag_set_cond(xvp, VIRF_NAMEDDIR); | |||||
| *vpp = xvp; | |||||
| } else { | |||||
| vrele(xvp); | |||||
| } | |||||
| } | |||||
| return (error); | |||||
| } | |||||
| static ssize_t | |||||
| zfs_readdir_named(struct vnode *vp, char *buf, ssize_t blen, off_t *offp, | |||||
| int *eofflagp, struct ucred *cred, struct thread *td) | |||||
| { | |||||
| struct uio io; | |||||
| struct iovec iv; | |||||
| zfs_uio_t uio; | |||||
| int error; | |||||
| io.uio_offset = *offp; | |||||
| io.uio_segflg = UIO_SYSSPACE; | |||||
| io.uio_rw = UIO_READ; | |||||
| io.uio_td = td; | |||||
| iv.iov_base = buf; | |||||
| iv.iov_len = blen; | |||||
| io.uio_iov = &iv; | |||||
| io.uio_iovcnt = 1; | |||||
| io.uio_resid = blen; | |||||
| zfs_uio_init(&uio, &io); | |||||
| error = zfs_readdir(vp, &uio, cred, eofflagp, NULL, NULL); | |||||
mav: Will this list attributes with "forbidden" prefixes? Should it? | |||||
rmacklemAuthorUnsubmitted Not Done Inline ActionsI think it currently does list them. Should it list them? Since zfs_listextattr_dir() strips out the forbidden ones, What do you think? Good catch, btw. I filtered out the forbidden ones in rmacklem: I think it currently does list them.
However, since they are created via Linux, I don't have… | |||||
rmacklemAuthorUnsubmitted Done Inline ActionsThis version of the patch skips over forbidden names, rmacklem: This version of the patch skips over forbidden names,
which I now believe is correct, since it… | |||||
| if (error != 0) | |||||
| return (-1); | |||||
| *offp = io.uio_offset; | |||||
| return (blen - io.uio_resid); | |||||
| } | |||||
| static bool | |||||
| zfs_has_namedattr(struct vnode *vp, struct ucred *cred) | |||||
| { | |||||
| struct componentname cn; | |||||
| struct vnode *xvp; | |||||
| struct dirent *dp; | |||||
| off_t offs; | |||||
| ssize_t rsize; | |||||
| char *buf, *cp, *endcp; | |||||
| int eofflag, error; | |||||
| bool ret; | |||||
| if ((vp->v_mount->mnt_flag & MNT_NAMEDATTR) == 0) | |||||
| return (false); | |||||
| /* Now see if a named attribute directory exists. */ | |||||
| cn.cn_flags = LOCKLEAF; | |||||
| cn.cn_lkflags = LK_SHARED; | |||||
| cn.cn_cred = cred; | |||||
| error = zfs_lookup_nameddir(vp, &cn, &xvp); | |||||
| if (error != 0) | |||||
| return (false); | |||||
| /* It exists, so see if there is any entry other than "." and "..". */ | |||||
| buf = malloc(DEV_BSIZE, M_TEMP, M_WAITOK); | |||||
| ret = false; | |||||
| offs = 0; | |||||
| do { | |||||
| rsize = zfs_readdir_named(xvp, buf, DEV_BSIZE, &offs, &eofflag, | |||||
| cred, curthread); | |||||
| if (rsize <= 0) | |||||
| break; | |||||
| cp = buf; | |||||
| endcp = &buf[rsize]; | |||||
| while (cp < endcp) { | |||||
| dp = (struct dirent *)cp; | |||||
| if (dp->d_fileno != 0 && (dp->d_type == DT_REG || | |||||
| dp->d_type == DT_UNKNOWN) && | |||||
| !ZFS_XA_NS_PREFIX_FORBIDDEN(dp->d_name) && | |||||
| ((dp->d_namlen == 1 && dp->d_name[0] != '.') || | |||||
| (dp->d_namlen == 2 && (dp->d_name[0] != '.' || | |||||
| dp->d_name[1] != '.')) || dp->d_namlen > 2)) { | |||||
| ret = true; | |||||
| break; | |||||
| } | |||||
| cp += dp->d_reclen; | |||||
| } | |||||
| } while (!ret && rsize > 0 && eofflag == 0); | |||||
| vput(xvp); | |||||
| free(buf, M_TEMP); | |||||
| return (ret); | |||||
| } | |||||
| static int | |||||
| zfs_freebsd_lookup(struct vop_lookup_args *ap, boolean_t cached) | |||||
| { | |||||
| struct componentname *cnp = ap->a_cnp; | |||||
| char nm[NAME_MAX + 1]; | |||||
| int error; | |||||
| struct vnode **vpp = ap->a_vpp, *dvp = ap->a_dvp, *xvp; | |||||
| bool is_nameddir, needs_nameddir, opennamed = false; | |||||
| /* | |||||
| * These variables are used to handle the named attribute cases: | |||||
| * opennamed - Is true when this is a call from open with O_NAMEDATTR | |||||
| * specified and it is the last component. | |||||
| * is_nameddir - Is true when the directory is a named attribute dir. | |||||
| * needs_nameddir - Is set when the lookup needs to look for/create | |||||
| * a named attribute directory. It is only set when is_nameddir | |||||
| * is_nameddir is false and opennamed is true. | |||||
mavUnsubmitted Done Inline Actionsis_nameddir said twice. mav: `is_nameddir` said twice. | |||||
rmacklemAuthorUnsubmitted Done Inline ActionsFor emphasis;-) I'll fix it. rmacklem: For emphasis;-)
I'll fix it.
| |||||
| * xvp - Is the directory that the lookup needs to be done in. | |||||
| * Usually dvp, unless needs_nameddir is true where it is the | |||||
| * result of the first non-named directory lookup. | |||||
| * Note that name caching must be disabled for named attribute | |||||
| * handling. | |||||
| */ | |||||
| needs_nameddir = false; | |||||
| xvp = dvp; | |||||
| opennamed = (cnp->cn_flags & (OPENNAMED | ISLASTCN)) == | |||||
| (OPENNAMED | ISLASTCN); | |||||
| is_nameddir = (vn_irflag_read(dvp) & VIRF_NAMEDDIR) != 0; | |||||
| if (is_nameddir && (cnp->cn_flags & ISLASTCN) == 0) | |||||
| return (ENOATTR); | |||||
| if (opennamed && !is_nameddir && (cnp->cn_flags & ISDOTDOT) != 0) | |||||
| return (ENOATTR); | |||||
| if (opennamed || is_nameddir) | |||||
| cnp->cn_flags &= ~MAKEENTRY; | |||||
| if (opennamed && !is_nameddir) | |||||
| needs_nameddir = true; | |||||
| ASSERT3U(cnp->cn_namelen, <, sizeof (nm)); | |||||
| error = 0; | |||||
| *vpp = NULL; | |||||
| if (needs_nameddir) { | |||||
| error = zfs_lookup_nameddir(dvp, cnp, &xvp); | |||||
| if (error == 0) | |||||
| is_nameddir = true; | |||||
| } | |||||
| if (error == 0) { | |||||
| if (!needs_nameddir || cnp->cn_namelen != 1 || | |||||
| *cnp->cn_nameptr != '.') { | |||||
| strlcpy(nm, cnp->cn_nameptr, MIN(cnp->cn_namelen + 1, | |||||
| sizeof (nm))); | |||||
| error = zfs_lookup(xvp, nm, vpp, cnp, cnp->cn_nameiop, | |||||
| cnp->cn_cred, 0, cached); | |||||
| if (is_nameddir && error == 0 && | |||||
| (cnp->cn_namelen != 1 || *cnp->cn_nameptr != '.') && | |||||
| (cnp->cn_flags & ISDOTDOT) == 0) { | |||||
| if ((*vpp)->v_type == VDIR) | |||||
| vn_irflag_set_cond(*vpp, VIRF_NAMEDDIR); | |||||
| else | |||||
| vn_irflag_set_cond(*vpp, VIRF_NAMEDATTR); | |||||
| } | |||||
| if (needs_nameddir && xvp != *vpp) | |||||
| vput(xvp); | |||||
| } else { | |||||
| /* Lookup of "." when a named attribute dir is needed. */ | |||||
| *vpp = xvp; | |||||
| } | |||||
| } | |||||
| return (error); | |||||
| } | |||||
| #else | |||||
| static int | static int | ||||
| zfs_freebsd_lookup(struct vop_lookup_args *ap, boolean_t cached) | zfs_freebsd_lookup(struct vop_lookup_args *ap, boolean_t cached) | ||||
| { | { | ||||
| struct componentname *cnp = ap->a_cnp; | struct componentname *cnp = ap->a_cnp; | ||||
| char nm[NAME_MAX + 1]; | char nm[NAME_MAX + 1]; | ||||
| ASSERT3U(cnp->cn_namelen, <, sizeof (nm)); | ASSERT3U(cnp->cn_namelen, <, sizeof (nm)); | ||||
| strlcpy(nm, cnp->cn_nameptr, MIN(cnp->cn_namelen + 1, sizeof (nm))); | strlcpy(nm, cnp->cn_nameptr, MIN(cnp->cn_namelen + 1, sizeof (nm))); | ||||
| return (zfs_lookup(ap->a_dvp, nm, ap->a_vpp, cnp, cnp->cn_nameiop, | return (zfs_lookup(ap->a_dvp, nm, ap->a_vpp, cnp, cnp->cn_nameiop, | ||||
| cnp->cn_cred, 0, cached)); | cnp->cn_cred, 0, cached)); | ||||
| } | } | ||||
| #endif | |||||
| static int | static int | ||||
| zfs_freebsd_cachedlookup(struct vop_cachedlookup_args *ap) | zfs_freebsd_cachedlookup(struct vop_cachedlookup_args *ap) | ||||
| { | { | ||||
| return (zfs_freebsd_lookup((struct vop_lookup_args *)ap, B_TRUE)); | return (zfs_freebsd_lookup((struct vop_lookup_args *)ap, B_TRUE)); | ||||
| } | } | ||||
| #ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||
| struct vop_lookup_args { | struct vop_lookup_args { | ||||
| struct vnode *a_dvp; | struct vnode *a_dvp; | ||||
| struct vnode **a_vpp; | struct vnode **a_vpp; | ||||
| struct componentname *a_cnp; | struct componentname *a_cnp; | ||||
| }; | }; | ||||
| #endif | #endif | ||||
| static int | static int | ||||
| zfs_cache_lookup(struct vop_lookup_args *ap) | zfs_cache_lookup(struct vop_lookup_args *ap) | ||||
| { | { | ||||
| zfsvfs_t *zfsvfs; | zfsvfs_t *zfsvfs; | ||||
| zfsvfs = ap->a_dvp->v_mount->mnt_data; | zfsvfs = ap->a_dvp->v_mount->mnt_data; | ||||
| if (zfsvfs->z_use_namecache) | if (zfsvfs->z_use_namecache | ||||
| #if __FreeBSD_version >= 1500040 | |||||
| && (ap->a_cnp->cn_flags & OPENNAMED) == 0 | |||||
| #endif | |||||
| ) | |||||
| return (vfs_cache_lookup(ap)); | return (vfs_cache_lookup(ap)); | ||||
| else | else | ||||
| return (zfs_freebsd_lookup(ap, B_FALSE)); | return (zfs_freebsd_lookup(ap, B_FALSE)); | ||||
| } | } | ||||
| static int | |||||
| zfs_check_attrname(const char *name) | |||||
| { | |||||
| /* We don't allow '/' character in attribute name. */ | |||||
| if (strchr(name, '/') != NULL) | |||||
| return (SET_ERROR(EINVAL)); | |||||
| /* We don't allow attribute names that start with a namespace prefix. */ | |||||
| if (ZFS_XA_NS_PREFIX_FORBIDDEN(name)) | |||||
| return (SET_ERROR(EINVAL)); | |||||
| return (0); | |||||
| } | |||||
| #ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||
| struct vop_create_args { | struct vop_create_args { | ||||
| struct vnode *a_dvp; | struct vnode *a_dvp; | ||||
| struct vnode **a_vpp; | struct vnode **a_vpp; | ||||
| struct componentname *a_cnp; | struct componentname *a_cnp; | ||||
| struct vattr *a_vap; | struct vattr *a_vap; | ||||
| }; | }; | ||||
| #endif | #endif | ||||
| static int | static int | ||||
| zfs_freebsd_create(struct vop_create_args *ap) | zfs_freebsd_create(struct vop_create_args *ap) | ||||
| { | { | ||||
| zfsvfs_t *zfsvfs; | zfsvfs_t *zfsvfs; | ||||
| struct componentname *cnp = ap->a_cnp; | struct componentname *cnp = ap->a_cnp; | ||||
| vattr_t *vap = ap->a_vap; | vattr_t *vap = ap->a_vap; | ||||
| znode_t *zp = NULL; | znode_t *zp = NULL; | ||||
| int rc, mode; | int rc, mode; | ||||
| struct vnode *dvp = ap->a_dvp; | |||||
| #if __FreeBSD_version >= 1500040 | |||||
| struct vnode *xvp; | |||||
| bool is_nameddir; | |||||
| #endif | |||||
| #if __FreeBSD_version < 1400068 | #if __FreeBSD_version < 1400068 | ||||
| ASSERT(cnp->cn_flags & SAVENAME); | ASSERT(cnp->cn_flags & SAVENAME); | ||||
| #endif | #endif | ||||
| vattr_init_mask(vap); | vattr_init_mask(vap); | ||||
| mode = vap->va_mode & ALLPERMS; | mode = vap->va_mode & ALLPERMS; | ||||
| zfsvfs = ap->a_dvp->v_mount->mnt_data; | zfsvfs = ap->a_dvp->v_mount->mnt_data; | ||||
| *ap->a_vpp = NULL; | *ap->a_vpp = NULL; | ||||
| rc = zfs_create(VTOZ(ap->a_dvp), cnp->cn_nameptr, vap, 0, mode, | rc = 0; | ||||
| &zp, cnp->cn_cred, 0 /* flag */, NULL /* vsecattr */, NULL); | #if __FreeBSD_version >= 1500040 | ||||
| xvp = NULL; | |||||
| is_nameddir = (vn_irflag_read(dvp) & VIRF_NAMEDDIR) != 0; | |||||
| if (!is_nameddir && (cnp->cn_flags & OPENNAMED) != 0) { | |||||
| /* Needs a named attribute directory. */ | |||||
| rc = zfs_lookup_nameddir(dvp, cnp, &xvp); | |||||
| if (rc == 0) { | |||||
| dvp = xvp; | |||||
| is_nameddir = true; | |||||
| } | |||||
| } | |||||
| if (is_nameddir && rc == 0) | |||||
| rc = zfs_check_attrname(cnp->cn_nameptr); | |||||
| #endif | |||||
| if (rc == 0) | if (rc == 0) | ||||
| rc = zfs_create(VTOZ(dvp), cnp->cn_nameptr, vap, 0, mode, | |||||
| &zp, cnp->cn_cred, 0 /* flag */, NULL /* vsecattr */, NULL); | |||||
| #if __FreeBSD_version >= 1500040 | |||||
| if (xvp != NULL) | |||||
| vput(xvp); | |||||
| #endif | |||||
| if (rc == 0) { | |||||
| *ap->a_vpp = ZTOV(zp); | *ap->a_vpp = ZTOV(zp); | ||||
| #if __FreeBSD_version >= 1500040 | |||||
| if (is_nameddir) | |||||
| vn_irflag_set_cond(*ap->a_vpp, VIRF_NAMEDATTR); | |||||
| #endif | |||||
| } | |||||
| if (zfsvfs->z_use_namecache && | if (zfsvfs->z_use_namecache && | ||||
| rc == 0 && (cnp->cn_flags & MAKEENTRY) != 0) | rc == 0 && (cnp->cn_flags & MAKEENTRY) != 0) | ||||
| cache_enter(ap->a_dvp, *ap->a_vpp, cnp); | cache_enter(ap->a_dvp, *ap->a_vpp, cnp); | ||||
| return (rc); | return (rc); | ||||
| } | } | ||||
| #ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||
| struct vop_remove_args { | struct vop_remove_args { | ||||
| struct vnode *a_dvp; | struct vnode *a_dvp; | ||||
| struct vnode *a_vp; | struct vnode *a_vp; | ||||
| struct componentname *a_cnp; | struct componentname *a_cnp; | ||||
| }; | }; | ||||
| #endif | #endif | ||||
| static int | static int | ||||
| zfs_freebsd_remove(struct vop_remove_args *ap) | zfs_freebsd_remove(struct vop_remove_args *ap) | ||||
| { | { | ||||
| int error = 0; | |||||
| #if __FreeBSD_version < 1400068 | #if __FreeBSD_version < 1400068 | ||||
| ASSERT(ap->a_cnp->cn_flags & SAVENAME); | ASSERT(ap->a_cnp->cn_flags & SAVENAME); | ||||
| #endif | #endif | ||||
| return (zfs_remove_(ap->a_dvp, ap->a_vp, ap->a_cnp->cn_nameptr, | #if __FreeBSD_version >= 1500040 | ||||
| ap->a_cnp->cn_cred)); | if ((vn_irflag_read(ap->a_dvp) & VIRF_NAMEDDIR) != 0) | ||||
| error = zfs_check_attrname(ap->a_cnp->cn_nameptr); | |||||
| #endif | |||||
| if (error == 0) | |||||
| error = zfs_remove_(ap->a_dvp, ap->a_vp, ap->a_cnp->cn_nameptr, | |||||
| ap->a_cnp->cn_cred); | |||||
| return (error); | |||||
| } | } | ||||
| #ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||
| struct vop_mkdir_args { | struct vop_mkdir_args { | ||||
| struct vnode *a_dvp; | struct vnode *a_dvp; | ||||
| struct vnode **a_vpp; | struct vnode **a_vpp; | ||||
| struct componentname *a_cnp; | struct componentname *a_cnp; | ||||
| struct vattr *a_vap; | struct vattr *a_vap; | ||||
| ▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | #define FLAG_CHECK(fflag, xflag, xfield) do { \ | ||||
| FLAG_CHECK(UF_OFFLINE, XAT_OFFLINE, | FLAG_CHECK(UF_OFFLINE, XAT_OFFLINE, | ||||
| xvap.xva_xoptattrs.xoa_offline); | xvap.xva_xoptattrs.xoa_offline); | ||||
| FLAG_CHECK(UF_SPARSE, XAT_SPARSE, | FLAG_CHECK(UF_SPARSE, XAT_SPARSE, | ||||
| xvap.xva_xoptattrs.xoa_sparse); | xvap.xva_xoptattrs.xoa_sparse); | ||||
| #undef FLAG_CHECK | #undef FLAG_CHECK | ||||
| *vap = xvap.xva_vattr; | *vap = xvap.xva_vattr; | ||||
| vap->va_flags = fflags; | vap->va_flags = fflags; | ||||
| #if __FreeBSD_version >= 1500040 | |||||
| if ((vn_irflag_read(ap->a_vp) & (VIRF_NAMEDDIR | VIRF_NAMEDATTR)) != 0) | |||||
| vap->va_bsdflags |= SFBSD_NAMEDATTR; | |||||
| #endif | |||||
| return (0); | return (0); | ||||
| } | } | ||||
| #ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||
| struct vop_setattr_args { | struct vop_setattr_args { | ||||
| struct vnode *a_vp; | struct vnode *a_vp; | ||||
| struct vattr *a_vap; | struct vattr *a_vap; | ||||
| struct ucred *a_cred; | struct ucred *a_cred; | ||||
| ▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | |||||
| static int | static int | ||||
| zfs_freebsd_rename(struct vop_rename_args *ap) | zfs_freebsd_rename(struct vop_rename_args *ap) | ||||
| { | { | ||||
| vnode_t *fdvp = ap->a_fdvp; | vnode_t *fdvp = ap->a_fdvp; | ||||
| vnode_t *fvp = ap->a_fvp; | vnode_t *fvp = ap->a_fvp; | ||||
| vnode_t *tdvp = ap->a_tdvp; | vnode_t *tdvp = ap->a_tdvp; | ||||
| vnode_t *tvp = ap->a_tvp; | vnode_t *tvp = ap->a_tvp; | ||||
| int error; | int error = 0; | ||||
| #if __FreeBSD_version < 1400068 | #if __FreeBSD_version < 1400068 | ||||
| ASSERT(ap->a_fcnp->cn_flags & (SAVENAME|SAVESTART)); | ASSERT(ap->a_fcnp->cn_flags & (SAVENAME|SAVESTART)); | ||||
| ASSERT(ap->a_tcnp->cn_flags & (SAVENAME|SAVESTART)); | ASSERT(ap->a_tcnp->cn_flags & (SAVENAME|SAVESTART)); | ||||
| #endif | |||||
| #if __FreeBSD_version >= 1500040 | |||||
| if ((vn_irflag_read(fdvp) & VIRF_NAMEDDIR) != 0) { | |||||
| error = zfs_check_attrname(ap->a_fcnp->cn_nameptr); | |||||
| if (error == 0) | |||||
| error = zfs_check_attrname(ap->a_tcnp->cn_nameptr); | |||||
| } | |||||
| #endif | #endif | ||||
| if (error == 0) | |||||
| error = zfs_do_rename(fdvp, &fvp, ap->a_fcnp, tdvp, &tvp, | error = zfs_do_rename(fdvp, &fvp, ap->a_fcnp, tdvp, &tvp, | ||||
| ap->a_tcnp, ap->a_fcnp->cn_cred); | ap->a_tcnp, ap->a_fcnp->cn_cred); | ||||
| vrele(fdvp); | vrele(fdvp); | ||||
| vrele(fvp); | vrele(fvp); | ||||
| vrele(tdvp); | vrele(tdvp); | ||||
| if (tvp != NULL) | if (tvp != NULL) | ||||
| vrele(tvp); | vrele(tvp); | ||||
| return (error); | return (error); | ||||
| ▲ Show 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | case _PC_DEALLOC_PRESENT: | ||||
| return (0); | return (0); | ||||
| #endif | #endif | ||||
| case _PC_PIPE_BUF: | case _PC_PIPE_BUF: | ||||
| if (ap->a_vp->v_type == VDIR || ap->a_vp->v_type == VFIFO) { | if (ap->a_vp->v_type == VDIR || ap->a_vp->v_type == VFIFO) { | ||||
| *ap->a_retval = PIPE_BUF; | *ap->a_retval = PIPE_BUF; | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| return (EINVAL); | return (EINVAL); | ||||
| #if __FreeBSD_version >= 1500040 | |||||
| case _PC_NAMEDATTR_ENABLED: | |||||
| MNT_ILOCK(ap->a_vp->v_mount); | |||||
| if ((ap->a_vp->v_mount->mnt_flag & MNT_NAMEDATTR) != 0) | |||||
| *ap->a_retval = 1; | |||||
| else | |||||
| *ap->a_retval = 0; | |||||
| MNT_IUNLOCK(ap->a_vp->v_mount); | |||||
| return (0); | |||||
| case _PC_HAS_NAMEDATTR: | |||||
| if (zfs_has_namedattr(ap->a_vp, curthread->td_ucred)) | |||||
| *ap->a_retval = 1; | |||||
| else | |||||
| *ap->a_retval = 0; | |||||
| return (0); | |||||
| #endif | |||||
| default: | default: | ||||
| return (vop_stdpathconf(ap)); | return (vop_stdpathconf(ap)); | ||||
| } | } | ||||
| } | } | ||||
| static int zfs_xattr_compat = 1; | int zfs_xattr_compat = 1; | ||||
| static int | |||||
| zfs_check_attrname(const char *name) | |||||
| { | |||||
| /* We don't allow '/' character in attribute name. */ | |||||
| if (strchr(name, '/') != NULL) | |||||
| return (SET_ERROR(EINVAL)); | |||||
| /* We don't allow attribute names that start with a namespace prefix. */ | |||||
| if (ZFS_XA_NS_PREFIX_FORBIDDEN(name)) | |||||
| return (SET_ERROR(EINVAL)); | |||||
| return (0); | |||||
| } | |||||
| /* | /* | ||||
| * FreeBSD's extended attributes namespace defines file name prefix for ZFS' | * FreeBSD's extended attributes namespace defines file name prefix for ZFS' | ||||
| * extended attribute name: | * extended attribute name: | ||||
| * | * | ||||
| * NAMESPACE XATTR_COMPAT PREFIX | * NAMESPACE XATTR_COMPAT PREFIX | ||||
| * system * freebsd:system: | * system * freebsd:system: | ||||
| * user 1 (none, can be used to access ZFS | * user 1 (none, can be used to access ZFS | ||||
| ▲ Show 20 Lines • Show All 1,152 Lines • Show Last 20 Lines | |||||
Will this list attributes with "forbidden" prefixes? Should it?