| 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)
- group database entry functions
#include <grp.h>struct group *getgrnam(const char *name);
struct group *getgrnam_r(const char *name,struct group *grp,char *buffer,intbufsize);
struct group *getgrent(void);
struct group *getgrent_r(struct group *grp,char *buffer,intbufsize);
struct group *getgrgid(gid_tgid);
struct group *getgrgid_r(gid_tgid,struct group *grp,char *buffer,intbufsize);
voidsetgrent(void);
voidendgrent(void);
struct group *fgetgrent(FILE *f);
struct group *fgetgrent_r(FILE *f,struct group *grp,char *buffer,intbufsize);
cc [flag... ]file...-D_POSIX_PTHREAD_SEMANTICS [library... ]intgetgrnam_r(const char *name,struct group *grp,char *buffer,size_tbufsize,struct group **result);
intgetgrgid_r(gid_tgid,struct group *grp,char *buffer,size_tbufsize,struct group **result);
These functions are used to obtain entries describing user groups. Entries cancome from any of the sources forgroup specified in the/etc/nsswitch.conffile (seensswitch.conf(4)).
Thegetgrnam() function searches the group database for an entry with thegroup name specified by the character string parametername.
Thegetgrgid() function searches the group database for an entry with the(numeric) group id specified bygid.
Thesetgrent(),getgrent(), andendgrent() functions are used to enumerate group entriesfrom the database.
Thesetgrent() function effectively rewinds the group database to allow repeated searches.It sets (or resets) the enumeration to the beginning of the setof group entries. This function should be called before the firstcall togetgrent().
Thegetgrent() function returns a pointer to a structure containing the broken-outfields of an entry in the group database. When first called,getgrent() returns a pointer to agroup structure containing the next groupstructure in the group database. Successive calls can be used to search theentire database.
Theendgrent() function can be called to close the group database anddeallocate resources when processing is complete. It is permissible, though possibly lessefficient, for the process to call more group functions after callingendgrent().
Thefgetgrent() function, unlike the other functions above, does not usensswitch.conf.It reads and parses the next line from the streamf, whichis assumed to have the format of thegroup file (seegroup(4)).
Thegetgrnam(),getgrgid(),getgrent(), andfgetgrent() functions use thread-specific storage thatis reused in each call to one of these functions by thesame thread, making them safe to use but not recommended for multithreaded applications.
The parallel functionsgetgrnam_r(),getgrgid_r(),getgrent_r(), andfgetgrent_r() provide reentrant interfaces forthese operations.
Each reentrant interface performs the same operation as its non-reentrant counterpart, namedby removing the_r suffix. The reentrant interfaces, however, usebuffers supplied by the caller to store returned results instead of usingthread-specific data that can be overwritten by each call. They are safe foruse in both single-threaded and multithreaded applications.
Each reentrant interface takes the same arguments as its non-reentrant counterpart, aswell as the following additional parameters. Thegrp argument must be apointer to astruct group structure allocated by the caller. On successfulcompletion, the function returns the group entry in this structure. Storage referenced bythe group structure is allocated from the memory provided with thebufferargument that isbufsize characters in size. The maximum size neededfor this buffer can be determined with the_SC_GETGR_R_SIZE_MAXsysconf(3C) parameter. Thestandard-conforming versions place a pointer to the modifiedgrp structure in theresultparameter, instead of returning a pointer to this structure. A null pointeris returned at the location pointed to byresult on error orif the requested entry is not found.
For enumeration in multithreaded applications, the position within the enumeration is aprocess-wide property shared by all threads. Thesetgrent() function can be usedin a multithreaded application but resets the enumeration position for all threads. If multiple threads interleave calls togetgrent_r(), the threads will enumerate disjointsubsets of the group database. Like their non-reentrant counterparts,getgrnam_r() andgetgrgid_r()leave the enumeration position in an indeterminate state.
Group entries are represented by thestruct group structure defined in <grp.h>:
struct group { char *gr_name; /* the name of the group */ char *gr_passwd; /* the encrypted group password */ gid_t gr_gid; /* the numerical group ID */ char **gr_mem; /* vector of pointers to member names */};Thegetgrnam(),getgrnam_r(),getgrgid(), andgetgrgid_r() functions each return a pointer toastruct group if they successfully locate the requested entry. They return anull pointer if either the requested entry was not found or an erroroccurred. On error,errno is set to indicate the error. The standard-conformingfunctionsgetgrnam_r() andgetgrgid_r() return0 upon success or an error numberin case of failure.
Thegetgrent(),getgrent_r(),fgetgrent(), andfgetgrent_r() functions each return a pointerto astruct group if they successfully enumerate an entry; otherwise they returna null pointer on end-of-file or error. On error,errno is set toindicate the error.
Thegetgrnam(),getgrgid(),getgrent(), andfgetgrent() functions use thread–specific data storage, soreturned data must be copied before a subsequent call to any ofthese functions if the data are to be saved.
When the pointer returned by the reentrant functionsgetgrnam_r(),getgrgid_r(),getgrent_r(), andfgetgrent_r() is non-null, it is always equal to thegrp pointer thatwas supplied by the caller.
Applications wishing to check for error situations should seterrno to 0before callinggetgrnam(),getgrnam_r(),getgrent(),getgrent_r(),getgrgid(),getgrgid_r(),fgetgrent(), andfgetgrent_r(). Ifthese functions return a null pointer anderrno is non-zero, an erroroccurred.
Thegetgrent_r(),fgetgrent(), andfgetgrent_r() functions will fail if:
An I/O error has occurred.
Insufficient storage was supplied bybuffer andbufsize to contain the data to be referenced by the resultinggroup structure.
Thegetgrent_r() function will fail if:
There are {OPEN_MAX} file descriptors currently open in the calling process.
The maximum allowable number of files is currently open in the system.
Thegetgrnam(),getgrnam_r(),getgrgid(),getgrgid_r(), andgetgrent() functions may fail if:
A signal was caught during the operation.
An I/O error has occurred.
There are {OPEN_MAX} file descriptors currently open in the calling process.
The maximum allowable number of files is currently open in the system.
Thegetgrnam_r() andgetgrgid_r() functions may fail if:
Insufficient storage was supplied bybuffer andbufsize to contain the data to be referenced by the resultinggroup structure.
Seeattributes(5) for descriptions of the following attributes:
|
Theendgrent(),getgrent(),getgrgid(),getgrgid_r(),getgrnam(),getgrnam_r(), andsetgrent() functions are Standard.
Intro(3),getpwnam(3C),group(4),nsswitch.conf(4),passwd(4),attributes(5),standards(5)
When compiling multithreaded programs, seeIntro(3).
Use of the enumeration interfacesgetgrent() andgetgrent_r() is discouraged; enumeration issupported for the group file and NIS, but in general is notefficient and might not be supported for all database sources. Thesemantics of enumeration are discussed further innsswitch.conf(4).
Previous releases allowed the use of ``+'' and ``-'' entries in/etc/groupto selectively include and exclude entries from NIS. The primary usage ofthese entries is superseded by the name service switch, so the ``+/-''form might not be supported in future releases.
If required, the ``+/-'' functionality can still be obtained for NIS byspecifyingcompat as the source forgroup.
Solaris 2.4 and earlier releases provided definitions of thegetgrnam_r() andgetgrgid_r()functions as specified in POSIX.1c Draft 6. The final POSIX.1c standard changedthe interface for these functions. Support for the Draft 6 interface isprovided for compatibility only and might not be supported in future releases. Newapplications and libraries should use the standard-conforming interface.
For POSIX.1c-conforming applications, the_POSIX_PTHREAD_SEMANTICS and_REENTRANT flags are automatically turned onby defining the_POSIX_C_SOURCE flag with a value ≥199506L.
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |