xattr.c revision 3fece8600e183b5cfc2f2782273c649252a723e8
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * CDDL HEADER START
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * The contents of this file are subject to the terms of the
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Common Development and Distribution License (the "License").
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * You may not use this file except in compliance with the License.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * See the License for the specific language governing permissions
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * and limitations under the License.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * When distributing Covered Code, include this CDDL HEADER in each
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * If applicable, add the following below this CDDL HEADER, with the
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * fields enclosed by brackets "[]" replaced with your own identifying
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * information: Portions Copyright [yyyy] [name of copyright owner]
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * CDDL HEADER END
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewstypedef struct {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewstypedef struct {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews vnode_t *xattr_realvp; /* Only used for VOP_REALVP */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * xattr_realvp is only used for VOP_REALVP, this is so we don't
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * keep an unnecessary hold on the *real* xattr dir unless we have
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * no other choice.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/* ARGSUSED */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsxattr_file_open(vnode_t **vpp, int flags, cred_t *cr, caller_context_t *ct)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if ((np->xattr_view == XATTR_VIEW_READONLY) && (flags & FWRITE))
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/* ARGSUSED */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsxattr_file_access(vnode_t *vp, int mode, int flags, cred_t *cr,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if ((np->xattr_view == XATTR_VIEW_READONLY) && (mode & VWRITE))
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/* ARGSUSED */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsxattr_file_close(vnode_t *vp, int flags, int count, offset_t off,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsxattr_common_fid(vnode_t *vp, fid_t *fidp, caller_context_t *ct)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/* ARGSUSED */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsxattr_fill_nvlist(vnode_t *vp, xattr_view_t xattr_view, nvlist_t *nvlp,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews xoptattr_t *xoap; /* Pointer to optional attributes */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * For detecting ephemeral uid/gid
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * We need to access the real fs object.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * vp points to a GFS file; ppvp points to the real object.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Iterate through the attrs associated with this view
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews fsid = (((uint64_t)vp->v_vfsp->vfs_fsid.val[0] << 32) |
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews 0xffffffff));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews VERIFY(nvlist_add_uint64(nvlp, attr_to_name(attr),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error = VOP_GETATTR(ppvp, &xvattr.xva_vattr, 0, cr, ct);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Process all the optional attributes together here. Notice that
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * xoap was set when the optional attribute bits were set above.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if ((xvattr.xva_vattr.va_mask & AT_XVATTR) && xoap) {
sizeof (uint64_t)) == 0);
return (ENOMEM);
nvl_sid) == 0);
return (ENOMEM);
nvl_sid) == 0);
return (ENOMEM);
return (EFAULT);
int error;
if (error) {
return (error);
return (error);
char *buf;
int error;
return (EINVAL);
return (ENOMEM);
return (EFAULT);
KM_SLEEP) == 0);
return (error);
int error = 0;
char *buf;
char *domain;
return (EINVAL);
return (EINVAL);
if (size == 0)
return (EINVAL);
return (EINVAL);
return (EFAULT);
return (EINVAL);
return (EINVAL);
return (EINVAL);
switch (type) {
case DATA_TYPE_BOOLEAN_VALUE:
return (EINVAL);
case DATA_TYPE_UINT64_ARRAY:
return (EINVAL);
case DATA_TYPE_NVLIST:
return (EINVAL);
case DATA_TYPE_UINT8_ARRAY:
return (EINVAL);
return (EINVAL);
switch (attr) {
case F_READONLY:
case F_HIDDEN:
case F_SYSTEM:
case F_ARCHIVE:
case F_IMMUTABLE:
case F_NOUNLINK:
case F_APPENDONLY:
case F_NODUMP:
case F_AV_QUARANTINED:
case F_AV_MODIFIED:
case F_CRTIME:
case F_OWNERSID:
case F_GROUPSID:
&rid)) {
return (EINVAL);
case F_AV_SCANSTAMP:
return (EINVAL);
case F_REPARSE:
if (error)
return (error);
switch (cmd) {
case _PC_XATTR_EXISTS:
case _PC_SATTR_ENABLED:
case _PC_SATTR_EXISTS:
*valp = 0;
{ NULL }
vnode_t *
return (vp);
vnode_t *
vnode_t *
{ NULL },
is_sattr_name(char *s)
for (i = 0; i < XATTRDIR_NENTS; ++i) {
xattr_sysattr_casechk(char *s)
for (i = 0; i < XATTRDIR_NENTS; ++i) {
int error;
return (EINVAL);
if (error)
return (error);
return (error);
int error;
if (error) {
return (error);
return (error);
return (EACCES);
int error;
if (error == 0) {
if (error) {
return (error);
if (error) {
return (error);
int error;
if (error == 0) {
error = 0;
return (error);
int error;
return (EACCES);
if (realvp)
int error;
if (error == 0) {
return (error);
int flags)
int error;
return (EACCES);
if (error == 0) {
return (error);
int error;
return (EINVAL);
if (error == 0) {
return (error);
int error;
int held_tgt;
if (error) {
return (error);
if (error) {
return (error);
held_tgt = 0;
if (held_tgt) {
return (error);
int *eflags)
int error;
*eflags = 0;
if (error == 0) {
if (error == 0) {
error = 0;
return (error);
int error;
int local_eof;
int reset_off = 0;
int has_xattrs = 0;
*eofp = 0;
if (error == 0) {
if (has_xattrs) {
if (error == 0) {
if (error) {
if (has_xattrs)
return (error);
!*eofp) {
int eflags;
eflags = 0;
if (error)
eflags);
if (error)
if (error) {
if (has_xattrs)
return (error);
if (*eofp == 0)
return (EINVAL);
if (!has_xattrs) {
*eofp = 0;
if (reset_off) {
return (error);
switch (cmd) {
case _PC_XATTR_EXISTS:
case _PC_SATTR_ENABLED:
case _PC_SATTR_EXISTS:
*valp = 0;
int error;
return (error);
int error;
*inop = 0;
if (error) {
return (ENOENT);
return (error);
if (error == 0) {
return (error);
static ino64_t
xattr_init(void)
int error = 0;
return (EINVAL);
return (EINVAL);
sysattrs_allowed = 0;
return (EINVAL);
if (!sysattrs_allowed) {
if (error)
return (error);
return (error);
return (error);
int error;
char *nm;
return (EINVAL);
if (error)
return (error);
if (error) {
return (EINVAL);
if (error)
return (error);
return (EINVAL);
if (error) {
return (EINVAL);
return (error);