1 /**
2  * D header file for GNU/Linux.
3  *
4  * Copyright: Copyright Robert Klotzner 2012.
5  * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
6  * Authors:   Robert Klotzner
7  */
8 module core.sys.linux.sys.xattr;
9 
10 import core.sys.posix.sys.types;
11 
12 version (linux):
13 extern (C):
14 nothrow:
15 @nogc:
16 
17 enum {
18     XATTR_CREATE = 1, /* set value, fail if attr already exists.  */
19     XATTR_REPLACE = 2 /* set value, fail if attr does not exist.  */
20 }
21 
22 enum XATTR_OS2_PREFIX = "os2.";
23 enum XATTR_OS2_PREFIX_LEN = XATTR_OS2_PREFIX.length;
24 enum XATTR_SECURITY_PREFIX = "security.";
25 enum XATTR_SECURITY_PREFIX_LEN = XATTR_SECURITY_PREFIX.length;
26 enum XATTR_SYSTEM_PREFIX = "system.";
27 enum XATTR_SYSTEM_PREFIX_LEN = XATTR_SYSTEM_PREFIX.length;
28 enum XATTR_TRUSTED_PREFIX = "trusted.";
29 enum XATTR_TRUSTED_PREFIX_LEN = XATTR_TRUSTED_PREFIX.length;
30 enum XATTR_USER_PREFIX = "user.";
31 enum XATTR_USER_PREFIX_LEN = XATTR_USER_PREFIX.length;
32 
33 /* Security namespace */
34 enum XATTR_SELINUX_SUFFIX = "selinux.";
35 enum XATTR_NAME_SELINUX = XATTR_SECURITY_PREFIX ~ XATTR_SELINUX_SUFFIX;
36 
37 enum XATTR_SMACK_SUFFIX = "SMACK64";
38 enum XATTR_SMACK_IPIN = "SMACK64IPIN";
39 enum XATTR_SMACK_IPOUT = "SMACK64IPOUT";
40 enum XATTR_SMACK_EXEC = "SMACK64EXEC";
41 enum XATTR_SMACK_TRANSMUTE = "SMACK64TRANSMUTE";
42 enum XATTR_SMACK_MMAP = "SMACK64MMAP";
43 
44 enum XATTR_NAME_SMACK = XATTR_SECURITY_PREFIX ~ XATTR_SMACK_SUFFIX;
45 enum XATTR_NAME_SMACKIPIN = XATTR_SECURITY_PREFIX ~ XATTR_SMACK_IPIN;
46 enum XATTR_NAME_SMACKIPOUT = XATTR_SECURITY_PREFIX ~ XATTR_SMACK_IPOUT;
47 enum XATTR_NAME_SMACKEXEC = XATTR_SECURITY_PREFIX ~ XATTR_SMACK_EXEC;
48 enum XATTR_NAME_SMACKTRANSMUTE = XATTR_SECURITY_PREFIX ~ XATTR_SMACK_TRANSMUTE;
49 enum XATTR_NAME_SMACKMMAP = XATTR_SECURITY_PREFIX ~ XATTR_SMACK_MMAP;
50 
51 enum XATTR_CAPS_SUFFIX = "capability";
52 enum XATTR_NAME_CAPS = XATTR_SECURITY_PREFIX ~ XATTR_CAPS_SUFFIX;
53 
54 
55 int setxattr(const scope char* path, const scope char* name, const scope void* value, size_t size, int flags);
56 
57 int lsetxattr(const scope char* path, const scope char* name, const scope void* value, size_t size, int flags);
58 int fsetxattr(int fd, const scope char* name, const scope void* value, size_t size, int flags);
59 ssize_t getxattr(const scope char* path, const scope char* name, void* value, size_t size);
60 ssize_t lgetxattr(const scope char* path, const scope char* name, void* value, size_t size);
61 ssize_t fgetxattr(int fd, const scope char* name, void* value, size_t size);
62 ssize_t listxattr(const scope char* path, char* list, size_t size);
63 ssize_t llistxattr(const scope char* path, char* list, size_t size);
64 ssize_t flistxattr (int __fd, char *list, size_t size);
65 int removexattr (const scope char *path, const scope char *name);
66 int lremovexattr (const scope char *path, const scope char *name);
67 int fremovexattr (int fd, const scope char *name);