blob: dc58026ebe5b49cf3a886f9944600fe0b59b8ff9 [file] [log] [blame]
Stephen Smalley5eb686d2012-01-13 07:45:16 -05001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
Elliott Hughes5470c182016-07-22 11:36:17 -070028
Elliott Hughesb361e682019-11-01 16:47:46 -070029#pragma once
30
31/**
32 * @file sys/xattr.h
33 * @brief Extended attribute functions.
34 */
Stephen Smalley5eb686d2012-01-13 07:45:16 -050035
Elliott Hughes5470c182016-07-22 11:36:17 -070036#include <linux/xattr.h>
Elliott Hughes203e13d2016-07-22 14:56:18 -070037#include <sys/cdefs.h>
Stephen Smalley5eb686d2012-01-13 07:45:16 -050038#include <sys/types.h>
39
40__BEGIN_DECLS
41
Elliott Hughesb361e682019-11-01 16:47:46 -070042/**
43 * [fsetxattr(2)](http://man7.org/linux/man-pages/man2/fsetxattr.2.html)
44 * sets an extended attribute on the file referred to by the given file
45 * descriptor.
46 *
47 * Valid flags are `XATTR_CREATE` and `XATTR_REPLACE`.
48 *
49 * Returns 0 on success and returns -1 and sets `errno` on failure.
50 */
51int fsetxattr(int __fd, const char* __name, const void* __value, size_t __size, int __flags);
Stephen Smalley5eb686d2012-01-13 07:45:16 -050052
Elliott Hughesb361e682019-11-01 16:47:46 -070053/**
54 * [setxattr(2)](http://man7.org/linux/man-pages/man2/setxattr.2.html)
55 * sets an extended attribute on the file referred to by the given path.
56 *
57 * Valid flags are `XATTR_CREATE` and `XATTR_REPLACE`.
58 *
59 * Returns 0 on success and returns -1 and sets `errno` on failure.
60 */
61int setxattr(const char* __path, const char* __name, const void* __value, size_t __size, int __flags);
Stephen Smalley5eb686d2012-01-13 07:45:16 -050062
Elliott Hughesb361e682019-11-01 16:47:46 -070063/**
64 * [lsetxattr(2)](http://man7.org/linux/man-pages/man2/lsetxattr.2.html)
65 * sets an extended attribute on the file referred to by the given path, which
66 * is the link itself rather than its target in the case of a symbolic link.
67 *
68 * Valid flags are `XATTR_CREATE` and `XATTR_REPLACE`.
69 *
70 * Returns 0 on success and returns -1 and sets `errno` on failure.
71 */
72int lsetxattr(const char* __path, const char* __name, const void* __value, size_t __size, int __flags);
Stephen Smalley5eb686d2012-01-13 07:45:16 -050073
Elliott Hughesb361e682019-11-01 16:47:46 -070074/**
75 * [fgetxattr(2)](http://man7.org/linux/man-pages/man2/fgetxattr.2.html)
76 * gets an extended attribute on the file referred to by the given file
77 * descriptor.
78 *
79 * Returns the non-negative length of the value on success, or
80 * returns -1 and sets `errno` on failure.
81 */
82ssize_t fgetxattr(int __fd, const char* __name, void* __value, size_t __size);
83
84/**
85 * [getxattr(2)](http://man7.org/linux/man-pages/man2/getxattr.2.html)
86 * gets an extended attribute on the file referred to by the given path.
87 *
88 * Returns the non-negative length of the value on success, or
89 * returns -1 and sets `errno` on failure.
90 */
91ssize_t getxattr(const char* __path, const char* __name, void* __value, size_t __size);
92
93/**
94 * [lgetxattr(2)](http://man7.org/linux/man-pages/man2/lgetxattr.2.html)
95 * gets an extended attribute on the file referred to by the given path, which
96 * is the link itself rather than its target in the case of a symbolic link.
97 *
98 * Returns the non-negative length of the value on success, or
99 * returns -1 and sets `errno` on failure.
100 */
101ssize_t lgetxattr(const char* __path, const char* __name, void* __value, size_t __size);
102
103/**
104 * [flistxattr(2)](http://man7.org/linux/man-pages/man2/flistxattr.2.html)
105 * lists the extended attributes on the file referred to by the given file
106 * descriptor.
107 *
108 * Returns the non-negative length of the list on success, or
109 * returns -1 and sets `errno` on failure.
110 */
111ssize_t flistxattr(int __fd, char* __list, size_t __size);
112
113/**
114 * [listxattr(2)](http://man7.org/linux/man-pages/man2/listxattr.2.html)
115 * lists the extended attributes on the file referred to by the given path.
116 *
117 * Returns the non-negative length of the list on success, or
118 * returns -1 and sets `errno` on failure.
119 */
120ssize_t listxattr(const char* __path, char* __list, size_t __size);
121
122/**
123 * [llistxattr(2)](http://man7.org/linux/man-pages/man2/llistxattr.2.html)
124 * lists the extended attributes on the file referred to by the given path, which
125 * is the link itself rather than its target in the case of a symbolic link.
126 *
127 * Returns the non-negative length of the list on success, or
128 * returns -1 and sets `errno` on failure.
129 */
130ssize_t llistxattr(const char* __path, char* __list, size_t __size);
131
132/**
133 * [fremovexattr(2)](http://man7.org/linux/man-pages/man2/fremovexattr.2.html)
134 * removes an extended attribute on the file referred to by the given file
135 * descriptor.
136 *
137 * Returns 0 on success and returns -1 and sets `errno` on failure.
138 */
139int fremovexattr(int __fd, const char* __name);
140
141/**
142 * [lremovexattr(2)](http://man7.org/linux/man-pages/man2/lremovexattr.2.html)
143 * removes an extended attribute on the file referred to by the given path, which
144 * is the link itself rather than its target in the case of a symbolic link.
145 *
146 * Returns 0 on success and returns -1 and sets `errno` on failure.
147 */
148int lremovexattr(const char* __path, const char* __name);
149
150/**
151 * [removexattr(2)](http://man7.org/linux/man-pages/man2/removexattr.2.html)
152 * removes an extended attribute on the file referred to by the given path.
153 *
154 * Returns 0 on success and returns -1 and sets `errno` on failure.
155 */
156int removexattr(const char* __path, const char* __name);
Stephen Smalley5eb686d2012-01-13 07:45:16 -0500157
158__END_DECLS