1*5331Samw /* 2*5331Samw * CDDL HEADER START 3*5331Samw * 4*5331Samw * The contents of this file are subject to the terms of the 5*5331Samw * Common Development and Distribution License (the "License"). 6*5331Samw * You may not use this file except in compliance with the License. 7*5331Samw * 8*5331Samw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*5331Samw * or http://www.opensolaris.org/os/licensing. 10*5331Samw * See the License for the specific language governing permissions 11*5331Samw * and limitations under the License. 12*5331Samw * 13*5331Samw * When distributing Covered Code, include this CDDL HEADER in each 14*5331Samw * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*5331Samw * If applicable, add the following below this CDDL HEADER, with the 16*5331Samw * fields enclosed by brackets "[]" replaced with your own identifying 17*5331Samw * information: Portions Copyright [yyyy] [name of copyright owner] 18*5331Samw * 19*5331Samw * CDDL HEADER END 20*5331Samw */ 21*5331Samw /* 22*5331Samw * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*5331Samw * Use is subject to license terms. 24*5331Samw */ 25*5331Samw 26*5331Samw #ifndef _SYS_ATTR_H 27*5331Samw #define _SYS_ATTR_H 28*5331Samw 29*5331Samw #pragma ident "%Z%%M% %I% %E% SMI" 30*5331Samw 31*5331Samw #ifdef __cplusplus 32*5331Samw extern "C" { 33*5331Samw #endif 34*5331Samw 35*5331Samw #ifdef _KERNEL 36*5331Samw #include <sys/vnode.h> 37*5331Samw #include <sys/vfs.h> 38*5331Samw #include <nfs/nfs.h> 39*5331Samw #endif 40*5331Samw #include <sys/nvpair.h> 41*5331Samw 42*5331Samw /* Attribute names for nvlist's */ 43*5331Samw #define A_CRTIME "crtime" 44*5331Samw #define A_HIDDEN "hidden" 45*5331Samw #define A_SYSTEM "system" 46*5331Samw #define A_READONLY "readonly" 47*5331Samw #define A_ARCHIVE "archive" 48*5331Samw #define A_NOUNLINK "nounlink" 49*5331Samw #define A_IMMUTABLE "immutable" 50*5331Samw #define A_APPENDONLY "appendonly" 51*5331Samw #define A_NODUMP "nodump" 52*5331Samw #define A_OPAQUE "opaque" 53*5331Samw #define A_AV_QUARANTINED "av_quarantined" 54*5331Samw #define A_AV_MODIFIED "av_modified" 55*5331Samw #define A_FSID "fsid" 56*5331Samw #define A_AV_SCANSTAMP "av_scanstamp" 57*5331Samw #define A_MDEV "mdev" 58*5331Samw #define A_OWNERSID "ownersid" 59*5331Samw #define A_GROUPSID "groupsid" 60*5331Samw 61*5331Samw /* Attribute option for utilities */ 62*5331Samw #define O_HIDDEN "H" 63*5331Samw #define O_SYSTEM "S" 64*5331Samw #define O_READONLY "R" 65*5331Samw #define O_ARCHIVE "A" 66*5331Samw #define O_NOUNLINK "u" 67*5331Samw #define O_IMMUTABLE "i" 68*5331Samw #define O_APPENDONLY "a" 69*5331Samw #define O_NODUMP "d" 70*5331Samw #define O_AV_QUARANTINED "q" 71*5331Samw #define O_AV_MODIFIED "m" 72*5331Samw #define O_NONE "" 73*5331Samw 74*5331Samw /* ownersid and groupsid are composed of two nvpairs */ 75*5331Samw #define SID_DOMAIN "domain" 76*5331Samw #define SID_RID "rid" 77*5331Samw 78*5331Samw typedef enum { 79*5331Samw F_ATTR_INVAL = -1, 80*5331Samw F_ARCHIVE, 81*5331Samw F_HIDDEN, 82*5331Samw F_READONLY, 83*5331Samw F_SYSTEM, 84*5331Samw F_APPENDONLY, 85*5331Samw F_NODUMP, 86*5331Samw F_IMMUTABLE, 87*5331Samw F_AV_MODIFIED, 88*5331Samw F_OPAQUE, 89*5331Samw F_AV_SCANSTAMP, 90*5331Samw F_AV_QUARANTINED, 91*5331Samw F_NOUNLINK, 92*5331Samw F_CRTIME, 93*5331Samw F_OWNERSID, 94*5331Samw F_GROUPSID, 95*5331Samw F_FSID, 96*5331Samw F_MDEV, 97*5331Samw F_ATTR_ALL 98*5331Samw } f_attr_t; 99*5331Samw 100*5331Samw #define VIEW_READONLY "SUNWattr_ro" 101*5331Samw #define VIEW_READWRITE "SUNWattr_rw" 102*5331Samw 103*5331Samw /* 104*5331Samw * These are the supported views into the virtual sysattr directory. 105*5331Samw * Additional views should be added before XATTR_VIEW_LAST. 106*5331Samw */ 107*5331Samw typedef enum { 108*5331Samw XATTR_VIEW_INVALID = -1, 109*5331Samw XATTR_VIEW_READONLY, 110*5331Samw XATTR_VIEW_READWRITE, 111*5331Samw XATTR_VIEW_LAST 112*5331Samw } xattr_view_t; 113*5331Samw 114*5331Samw typedef struct { 115*5331Samw char *x_name; 116*5331Samw char *x_option; 117*5331Samw xattr_view_t x_xattr_view; 118*5331Samw data_type_t x_data_type; 119*5331Samw } xattr_entry_t; 120*5331Samw 121*5331Samw #ifdef _KERNEL 122*5331Samw #define XATTR_MAXFIDSZ NFS_FHMAXDATA 123*5331Samw 124*5331Samw typedef struct { 125*5331Samw uint16_t len; 126*5331Samw char parent_fid[XATTR_MAXFIDSZ]; 127*5331Samw uint16_t parent_len; 128*5331Samw uint16_t dir_offset; 129*5331Samw } xattr_fid_t; 130*5331Samw 131*5331Samw #define XATTR_FIDSZ (sizeof (xattr_fid_t) - sizeof (uint16_t)) 132*5331Samw 133*5331Samw int xattr_dir_vget(vfs_t *, vnode_t **, fid_t *); 134*5331Samw #endif 135*5331Samw 136*5331Samw int attr_count(void); 137*5331Samw const char *attr_to_name(f_attr_t); 138*5331Samw const char *attr_to_option(f_attr_t); 139*5331Samw f_attr_t name_to_attr(const char *name); 140*5331Samw f_attr_t option_to_attr(const char *option); 141*5331Samw xattr_view_t attr_to_xattr_view(f_attr_t attr); 142*5331Samw data_type_t attr_to_data_type(f_attr_t attr); 143*5331Samw 144*5331Samw #ifdef __cplusplus 145*5331Samw } 146*5331Samw #endif 147*5331Samw 148*5331Samw #endif /* _SYS_ATTR_H */ 149