1*8d741a5dSApple OSS Distributions /* 2*8d741a5dSApple OSS Distributions * Copyright (c) 2004-2012 Apple Inc. All rights reserved. 3*8d741a5dSApple OSS Distributions * 4*8d741a5dSApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*8d741a5dSApple OSS Distributions * 6*8d741a5dSApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*8d741a5dSApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*8d741a5dSApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*8d741a5dSApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*8d741a5dSApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*8d741a5dSApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*8d741a5dSApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*8d741a5dSApple OSS Distributions * terms of an Apple operating system software license agreement. 14*8d741a5dSApple OSS Distributions * 15*8d741a5dSApple OSS Distributions * Please obtain a copy of the License at 16*8d741a5dSApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*8d741a5dSApple OSS Distributions * 18*8d741a5dSApple OSS Distributions * The Original Code and all software distributed under the License are 19*8d741a5dSApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*8d741a5dSApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*8d741a5dSApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*8d741a5dSApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*8d741a5dSApple OSS Distributions * Please see the License for the specific language governing rights and 24*8d741a5dSApple OSS Distributions * limitations under the License. 25*8d741a5dSApple OSS Distributions * 26*8d741a5dSApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*8d741a5dSApple OSS Distributions */ 28*8d741a5dSApple OSS Distributions 29*8d741a5dSApple OSS Distributions #ifndef _SYS_XATTR_H_ 30*8d741a5dSApple OSS Distributions #define _SYS_XATTR_H_ 31*8d741a5dSApple OSS Distributions 32*8d741a5dSApple OSS Distributions #include <sys/types.h> 33*8d741a5dSApple OSS Distributions 34*8d741a5dSApple OSS Distributions /* Options for pathname based xattr calls */ 35*8d741a5dSApple OSS Distributions #define XATTR_NOFOLLOW 0x0001 /* Don't follow symbolic links */ 36*8d741a5dSApple OSS Distributions 37*8d741a5dSApple OSS Distributions /* Options for setxattr calls */ 38*8d741a5dSApple OSS Distributions #define XATTR_CREATE 0x0002 /* set the value, fail if attr already exists */ 39*8d741a5dSApple OSS Distributions #define XATTR_REPLACE 0x0004 /* set the value, fail if attr does not exist */ 40*8d741a5dSApple OSS Distributions 41*8d741a5dSApple OSS Distributions /* Set this to bypass authorization checking (eg. if doing auth-related work) */ 42*8d741a5dSApple OSS Distributions #define XATTR_NOSECURITY 0x0008 43*8d741a5dSApple OSS Distributions 44*8d741a5dSApple OSS Distributions /* Set this to bypass the default extended attribute file (dot-underscore file) */ 45*8d741a5dSApple OSS Distributions #define XATTR_NODEFAULT 0x0010 46*8d741a5dSApple OSS Distributions 47*8d741a5dSApple OSS Distributions /* option for f/getxattr() and f/listxattr() to expose the HFS Compression extended attributes */ 48*8d741a5dSApple OSS Distributions #define XATTR_SHOWCOMPRESSION 0x0020 49*8d741a5dSApple OSS Distributions 50*8d741a5dSApple OSS Distributions /* Options for pathname based xattr calls */ 51*8d741a5dSApple OSS Distributions #define XATTR_NOFOLLOW_ANY 0x0040 /* Don't follow any symbolic links in the path */ 52*8d741a5dSApple OSS Distributions 53*8d741a5dSApple OSS Distributions #define XATTR_MAXNAMELEN 127 54*8d741a5dSApple OSS Distributions 55*8d741a5dSApple OSS Distributions /* See the ATTR_CMN_FNDRINFO section of getattrlist(2) for details on FinderInfo */ 56*8d741a5dSApple OSS Distributions #define XATTR_FINDERINFO_NAME "com.apple.FinderInfo" 57*8d741a5dSApple OSS Distributions 58*8d741a5dSApple OSS Distributions #define XATTR_RESOURCEFORK_NAME "com.apple.ResourceFork" 59*8d741a5dSApple OSS Distributions 60*8d741a5dSApple OSS Distributions 61*8d741a5dSApple OSS Distributions #ifdef KERNEL 62*8d741a5dSApple OSS Distributions 63*8d741a5dSApple OSS Distributions #ifdef KERNEL_PRIVATE 64*8d741a5dSApple OSS Distributions #define XATTR_VNODE_SUPPORTED(vp) \ 65*8d741a5dSApple OSS Distributions ((vp)->v_type == VREG || (vp)->v_type == VDIR || (vp)->v_type == VLNK || (vp)->v_type == VSOCK || (vp)->v_type == VFIFO) 66*8d741a5dSApple OSS Distributions #endif 67*8d741a5dSApple OSS Distributions 68*8d741a5dSApple OSS Distributions __BEGIN_DECLS 69*8d741a5dSApple OSS Distributions int xattr_protected(const char *); 70*8d741a5dSApple OSS Distributions int xattr_validatename(const char *); 71*8d741a5dSApple OSS Distributions 72*8d741a5dSApple OSS Distributions /* Maximum extended attribute size supported by VFS */ 73*8d741a5dSApple OSS Distributions #define XATTR_MAXSIZE INT32_MAX 74*8d741a5dSApple OSS Distributions 75*8d741a5dSApple OSS Distributions #ifdef PRIVATE 76*8d741a5dSApple OSS Distributions /* Maximum extended attribute size in an Apple Double file */ 77*8d741a5dSApple OSS Distributions #define AD_XATTR_MAXSIZE XATTR_MAXSIZE 78*8d741a5dSApple OSS Distributions 79*8d741a5dSApple OSS Distributions /* Number of bits used to represent the maximum size of 80*8d741a5dSApple OSS Distributions * extended attribute stored in an Apple Double file. 81*8d741a5dSApple OSS Distributions */ 82*8d741a5dSApple OSS Distributions #define AD_XATTR_SIZE_BITS 31 83*8d741a5dSApple OSS Distributions #endif /* PRIVATE */ 84*8d741a5dSApple OSS Distributions 85*8d741a5dSApple OSS Distributions __END_DECLS 86*8d741a5dSApple OSS Distributions #endif /* KERNEL */ 87*8d741a5dSApple OSS Distributions 88*8d741a5dSApple OSS Distributions #ifndef KERNEL 89*8d741a5dSApple OSS Distributions __BEGIN_DECLS 90*8d741a5dSApple OSS Distributions 91*8d741a5dSApple OSS Distributions ssize_t getxattr(const char *path, const char *name, void *value, size_t size, u_int32_t position, int options); 92*8d741a5dSApple OSS Distributions 93*8d741a5dSApple OSS Distributions ssize_t fgetxattr(int fd, const char *name, void *value, size_t size, u_int32_t position, int options); 94*8d741a5dSApple OSS Distributions 95*8d741a5dSApple OSS Distributions int setxattr(const char *path, const char *name, const void *value, size_t size, u_int32_t position, int options); 96*8d741a5dSApple OSS Distributions 97*8d741a5dSApple OSS Distributions int fsetxattr(int fd, const char *name, const void *value, size_t size, u_int32_t position, int options); 98*8d741a5dSApple OSS Distributions 99*8d741a5dSApple OSS Distributions int removexattr(const char *path, const char *name, int options); 100*8d741a5dSApple OSS Distributions 101*8d741a5dSApple OSS Distributions int fremovexattr(int fd, const char *name, int options); 102*8d741a5dSApple OSS Distributions 103*8d741a5dSApple OSS Distributions ssize_t listxattr(const char *path, char *namebuff, size_t size, int options); 104*8d741a5dSApple OSS Distributions 105*8d741a5dSApple OSS Distributions ssize_t flistxattr(int fd, char *namebuff, size_t size, int options); 106*8d741a5dSApple OSS Distributions 107*8d741a5dSApple OSS Distributions __END_DECLS 108*8d741a5dSApple OSS Distributions #endif /* KERNEL */ 109*8d741a5dSApple OSS Distributions 110*8d741a5dSApple OSS Distributions #endif /* _SYS_XATTR_H_ */ 111