1 /* Prototypes for openat-style fd-relative functions for operating with 2 extended file attributes. 3 4 Copyright 2012-2021 Free Software Foundation, Inc. 5 6 This program is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 18 19 #ifndef XATTRS_AT_H 20 #define XATTRS_AT_H 21 22 #include <sys/types.h> 23 #if defined(HAVE_SYS_XATTR_H) 24 # include <sys/xattr.h> 25 #elif defined(HAVE_ATTR_XATTR_H) 26 # include <attr/xattr.h> 27 #endif 28 29 #ifndef ENOATTR 30 # define ENOATTR ENODATA /* No such attribute */ 31 #endif 32 33 /* These are the dir-fd-relative variants of the functions without the 34 "at" suffix. For example, setxattrat (AT_FDCWD, path, name, value, size, 35 flags &c) is usually equivalent to setxattr (file, name, value, size, 36 flags). For more info use the setxattr(2), getxattr(2) or listxattr(2) 37 manpages. */ 38 39 /* dir-fd-relative setxattr. Operation sets the VALUE of the extended 40 attribute identified by NAME and associated with the given PATH in the 41 filesystem relatively to directory identified by DIR_FD. See the 42 setxattr(2) manpage for the description of all parameters. */ 43 int setxattrat (int dir_fd, const char *path, const char *name, 44 const void *value, size_t size, int flags); 45 46 /* dir-fd-relative lsetxattr. This function is just like setxattrat, 47 except when DIR_FD and FILE specify a symlink: lsetxattrat operates on the 48 symlink, while the setxattrat operates on the referent of the symlink. */ 49 int lsetxattrat (int dir_fd, const char *path, const char *name, 50 const void *value, size_t size, int flags); 51 52 /* dir-fd-relative getxattr. Operation gets the VALUE of the extended 53 attribute idenfified by NAME and associated with the given PATH in the 54 filesystem relatively to directory identified by DIR_FD. For more info 55 about all parameters see the getxattr(2) manpage. */ 56 ssize_t getxattrat (int dir_fd, const char *path, const char *name, 57 void *value, size_t size); 58 59 /* dir-fd-relative lgetxattr. This function is just like getxattrat, 60 except when DIR_FD and FILE specify a symlink: lgetxattrat operates on the 61 symlink, while the getxattrat operates on the referent of the symlink. */ 62 ssize_t lgetxattrat (int dir_fd, const char *path, const char *name, 63 void *value, size_t size); 64 65 /* dir-fd-relative listxattr. Obtain the list of extended attrubtes names. For 66 more info see the listxattr(2) manpage. */ 67 ssize_t listxattrat (int dir_fd, const char *path, char *list, size_t size); 68 69 /* dir-fd-relative llistxattr. This function is just like listxattrat, 70 except when DIR_FD and FILE specify a symlink: llistxattr operates on the 71 symlink, while the listxattrat operates on the referent of the symlink. */ 72 ssize_t llistxattrat (int dir_fd, const char *path, char *list, size_t size); 73 74 #endif /* XATTRS_AT_H */ 75