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