1fgetattr(3C)             Standard C Library Functions             fgetattr(3C)
2
3
4

NAME

6       fgetattr,   fsetattr,   getattrat,  setattrat  -  get  and  set  system
7       attributes
8

SYNOPSIS

10       #include <fcntl.h>
11       #include <sys/types.h>
12       #include <attr.h>
13       #include <sys/nvpair.h>
14
15       int fgetattr(int fildes, xattr_view_t view,nvlist_t **response);
16
17
18       int fsetattr(int fildes, xattr_view_t view,nvlist_t *request)
19
20
21       int getattrat(int fildes, xattr_view_t view, const char *filename,
22            nvlist_t **response);
23
24
25       int setattrat(int fildes, xattr_view_t view, const char *filename,
26            nvlist_t *request);
27
28

DESCRIPTION

30       The fgetattr() function obtains an nvlist of system attribute  informa‐
31       tion about an open file object specified by the file descriptor fildes,
32       obtained from a successful  open(2),  creat(2),  dup(2),  fcntl(2),  or
33       pipe(2) function.
34
35
36       The getattrat() function first opens the extended attribute file speci‐
37       fied by filename in the already opened file directory object  specified
38       by  fildes.  It then retrieves an nvlist of system attributes and their
39       values from filename.
40
41
42       The response argument is allocated by either fgetattr() or getattrat().
43       The  application  must call nvlist_free(3NVPAIR) to deallocate the mem‐
44       ory.
45
46
47       Upon successful completion, the nvlist will contain one nvpair for each
48       of  the  system attributes associated with view.  The list of views and
49       the attributes associated with each view are  listed  below.   Not  all
50       underlying  file  systems  support  all  views  and all attributes. The
51       nvlist will not contain an nvpair for any attribute  not  supported  by
52       the underlying filesystem.
53
54
55       The fsetattr() function uses the nvlist pointed to by request to update
56       one or more of the system attribute's information about  an  open  file
57       object  specified  by  the file descriptor fildes, obtained from a suc‐
58       cessful open(), creat(), dup(), fcntl(), or pipe() function. The setat‐
59       trat()  function  first  opens the extended attribute file specified by
60       filename in the already  opened  file  directory  object  specified  by
61       fildes.  It then uses the nvlist pointed to by request to update one or
62       more of the system attributes of filename.
63
64
65       If completion is not successful then no system attribute information is
66       updated.
67
68
69       The  following  chart  lists the supported views, attributes, and  data
70       types for each view:
71
72
73
74
75               View               Attribute             Data type
76       ────────────────────────────────────────────────────────────────
77       XATTR_VIEW_READONLY    A_FSID               uint64_value
78                              A_OPAQUE             boolean_value
79                              A_AV_SCANSTAMP       uint8_array[]
80       XATTR_VIEW_READWRITE   A_READONLY           boolean_value
81                              A_HIDDEN             boolean_value
82                              A_SYSTEM             boolean_value
83                              A_ARCHIVE            boolean_value
84                              A_CRTIME             uint64_array[2]
85                              A_NOUNLINK           boolean_value
86                              A_IMMUTABLE          boolean_value
87                              A_APPENDONLY         boolean_value
88                              A_NODUMP             boolean_value
89                              A_AV_QUARANTINED     boolean_value
90                              A_AV_MODIFIED        boolean_value
91                              A_OWNERSID           nvlist composed of
92                                                   uint32_value   and
93                                                   string
94                              A_GROUPSID           nvlist composed of
95                                                   uint32_value   and
96                                                   string
97
98

RETURN VALUES

100       Upon successful completion, 0 is returned. Otherwise, -1   is  returned
101       and errno is set to indicate the error.
102

ERRORS

104       The  fgetattr(),  getattrat(),  fsetattr(),  and setattrat(), functions
105       will fail if:
106
107       EBADF     The fildes argument is not a valid open file descriptor.
108
109
110       EINVAL    The underlying file system does  not  support  extended  file
111                 attributes.
112
113
114       EIO       An error occurred while reading from the file system.
115
116
117
118       The getattrat() and setattrat() functions will fail if:
119
120       EACCES    Search permission or write permission for filename is denied.
121
122
123       ENOENT    The  filename  argument does not name an existing file in the
124                 extended attribute directory represented by fildes.
125
126
127       EPERM     There are insufficient privileges to manipulate attributes.
128
129

EXAMPLES

131       Example 1 Obtain an nvlist of readonly system attributes  for  an  open
132       file object.
133
134
135       Use  fgetattr()  to  obtain an nvlist of the readonly system attributes
136       for the open file object represented by file descriptor fildes.
137
138
139         #include <fcntl.h>
140         #include <sys/types.h>
141         #include <attr.h>
142         #include <sys/nvpair.h>
143
144         nvlist_t *response;
145         nvpair_t *pair = NULL;
146
147         if (fgetattr(fildes, XATTR_VIEW_READONLY, &response)) {
148                      exit(1);
149         }
150         while (pair = nvlist_next_nvpair(response, pair)) {
151             .
152             .
153             .
154         }
155         nvlist_free(response);
156
157
158       Example 2 Set the A_READONLY system attribute on an open file object.
159
160
161       Use fsetattr() to set the A_OPAQUE system attribute on  the  open  file
162       object represented by file descriptor fildes.
163
164
165         nvlist_t *request;
166         nvpair_t *pair = NULL;
167
168         if (nvlist_alloc(&request, NV_UNIQUE_NAME, 0) != 0) {
169                     exit(1);
170         }
171         if (nvlist_add_boolean_value(request, A_READONLY, 1) != 0) {
172                     exit(1);
173         }
174         if (fsetattr(fildes, XATTR_VIEW_READWRITE, request)) {
175                     exit(1);
176         }
177
178
179       Example  3  Obtain  an nvlist of the read/write system attributes for a
180       file.
181
182
183       Use getattrat() to obtain an nvlist of the read/write system attributes
184       for the file named xattrfile in the extended attribute directory of the
185       open file represented by file descriptor fildes.
186
187
188         nvlist_t *response;
189         nvpair_t *pair = NULL;
190
191         if (getattrat(fildes, XATTR_VIEW_READWRITE, "file", &response)) {
192                      exit(1);
193         }
194         while (pair = nvlist_next_nvpair(response, pair)) {
195             .
196             .
197             .
198         }
199         nvlist_free(response);
200
201
202       Example 4 Set the A_APPENDONLY system attribute on a file.
203
204
205       Use setattrat() to set the A_APPENDONLY system attribute  on  the  file
206       named  file in the extended attribute directory of the open file repre‐
207       sented by file descriptor fildes.
208
209
210         nvlist_t *request;
211         nvpair_t *pair = NULL;
212
213         if (nvlist_alloc(&request, NV_UNIQUE_NAME, 0) != 0) {
214                     exit(1);
215         }
216         if (nvlist_add_boolean_value(request, A_APPENDONLY, 1) != 0) {
217                     exit(1);
218         }
219         if (setattrat(fildes, XATTR_VIEW_READWRITE, "file", request)) {
220                     exit(1);
221              }
222
223

ATTRIBUTES

225       See attributes(5) for descriptions of the following attributes:
226
227
228
229
230       ┌─────────────────────────────┬─────────────────────────────┐
231       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
232       ├─────────────────────────────┼─────────────────────────────┤
233       │Interface Stability          │Committed                    │
234       ├─────────────────────────────┼─────────────────────────────┤
235       │MT-Level                     │Safe                         │
236       └─────────────────────────────┴─────────────────────────────┘
237

SEE ALSO

239       creat(2), dup(2), fcntl(2),  fstat(2),  fstatat(2),  open(2),  pipe(2),
240       libnvpair(3LIB), attributes(5), fsattr(5)
241
242
243
244SunOS 5.11                        4 Aug 2008                      fgetattr(3C)
Impressum