| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- get and set system attributes
#include <fcntl.h>#include <sys/types.h>#include <attr.h>#include <sys/nvpair.h>intfgetattr(int fildes,xattr_view_t view,nvlist_t **response);
intfsetattr(int fildes,xattr_view_t view,nvlist_t *request)
intgetattrat(int fildes,xattr_view_t view,const char *filename,nvlist_t **response);
intsetattrat(int fildes,xattr_view_t view,const char *filename,nvlist_t *request);
Thefgetattr() function obtains an nvlist of system attribute information about anopen file object specified by the file descriptorfildes, obtained from asuccessfulopen(2),creat(2),dup(2),fcntl(2), orpipe(2) function.
Thegetattrat() function first opens the extended attribute file specified byfilenamein the already opened file directory object specified byfildes. It thenretrieves an nvlist of system attributes and their values fromfilename.
Theresponse argument is allocated by eitherfgetattr() orgetattrat(). The applicationmust callnvlist_free(3NVPAIR) to deallocate the memory.
Upon successful completion, the nvlist will contain one nvpair for each ofthe system attributes associated withview. The list of views andthe attributes associated with each view are listed below. Not allunderlying file systems support all views and all attributes. The nvlist will notcontain an nvpair for any attribute not supported by the underlying filesystem.
Thefsetattr() function uses the nvlist pointed to byrequest to updateone or more of the system attribute's information about an open fileobject specified by the file descriptorfildes, obtained from a successfulopen(),creat(),dup(),fcntl(), orpipe() function. Thesetattrat() function first opens theextended attribute file specified byfilename in the already opened file directory objectspecified byfildes. It then uses the nvlist pointed to byrequestto update one or more of the system attributes of filename.
If completion is not successful then no system attribute information is updated.
The following chart lists the supported views, attributes, and data typesfor each view:
|
Upon successful completion, 0 is returned. Otherwise, -1 is returned anderrno is set to indicate the error.
Thefgetattr(),getattrat(),fsetattr(), andsetattrat(), functions will fail if:
Thefildes argument is not a valid open file descriptor.
The underlying file system does not support extended file attributes.
An error occurred while reading from the file system.
Thegetattrat() andsetattrat() functions will fail if:
Search permission or write permission forfilename is denied.
Thefilename argument does not name an existing file in the extended attribute directory represented byfildes.
There are insufficient privileges to manipulate attributes.
Example 1 Obtain an nvlist of readonly system attributes for an open file object.
Usefgetattr() to obtain an nvlist of the readonly system attributes forthe open file object represented by file descriptorfildes.
#include <fcntl.h>#include <sys/types.h>#include <attr.h>#include <sys/nvpair.h>nvlist_t *response;nvpair_t *pair = NULL;if (fgetattr(fildes, XATTR_VIEW_READONLY, &response)) { exit(1);}while (pair = nvlist_next_nvpair(response, pair)) { . . .}nvlist_free(response);Example 2 Set theA_READONLY system attribute on an open file object.
Usefsetattr() to set theA_OPAQUE system attribute on the open fileobject represented by file descriptorfildes.
nvlist_t *request;nvpair_t *pair = NULL;if (nvlist_alloc(&request, NV_UNIQUE_NAME, 0) != 0) { exit(1);}if (nvlist_add_boolean_value(request, A_READONLY, 1) != 0) { exit(1);}if (fsetattr(fildes, XATTR_VIEW_READWRITE, request)) { exit(1);}Example 3 Obtain an nvlist of the read/write system attributes for a file.
Usegetattrat() to obtain an nvlist of the read/write system attributes forthe file namedxattrfile in the extended attribute directory of the openfile represented by file descriptorfildes.
nvlist_t *response;nvpair_t *pair = NULL;if (getattrat(fildes, XATTR_VIEW_READWRITE, "file", &response)) { exit(1);}while (pair = nvlist_next_nvpair(response, pair)) { . . .}nvlist_free(response);Example 4 Set theA_APPENDONLY system attribute on a file.
Usesetattrat() to set theA_APPENDONLY system attribute on the file namedfile in the extended attribute directory of the open file represented byfile descriptorfildes.
nvlist_t *request;nvpair_t *pair = NULL;if (nvlist_alloc(&request, NV_UNIQUE_NAME, 0) != 0) { exit(1);}if (nvlist_add_boolean_value(request, A_APPENDONLY, 1) != 0) { exit(1);}if (setattrat(fildes, XATTR_VIEW_READWRITE, "file", request)) { exit(1); }Seeattributes(5) for descriptions of the following attributes:
|
creat(2),dup(2),fcntl(2),fstat(2),fstatat(2),open(2),pipe(2),libnvpair(3LIB),attributes(5),fsattr(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |