GETGRNAM(3) Library Functions Manual GETGRNAM(3)

getgrnam getgrnam_rsearch group database for a name

#include <sys/types.h>
#include <grp.h>

struct group *getgrnam(const char *name);
int getgrnam_r(const char *name, struct group *grp, char *buffer,
    size_t bufsize, struct group **result);

The getgrnam() function searches the group database for an entry with a matching name .

The getgrnam() interface need not be reentrant.

The getgrnam_r() function updates the structure pointed to by and stores a pointer to that structure at the location pointed to by The structure contains an entry from the group database with a matching or . Storage referenced by the group structure is allocated from the memory provided with the parameter, which is characters in size. The maximum size needed for this buffer can be determined with the {_SC_GETGR_R_SIZE_MAX} parameter. A NULL pointer is returned at the location pointed to by on error or if the requested entry is not found.

The getgrnam() function returns a pointer to a struct group with the structure defined in <grp.h> with a matching entry if one is found. The getgrnam() function returns a null pointer if either the requested entry was not found, or an error occurred. On error, errno will be set to indicate the error.

The return value may point to a static area which is overwritten by a subsequent call to , or getgrnam().

If successful, the getgrnam_r() function returns zero. Otherwise, an error number is returned to indicate the error.

The getgrnam() function may fail if:

An I/O error has occurred.
A signal was caught during getgrnam() .
{OPEN_MAX} file descriptors are currently open in the calling process.
The maximum allowable number of files is currently open in the system.

The getgrnam_r() function may fail if:

Insufficient storage was supplied via buffer and bufsize to contain the data to be referenced by the resulting group structure.

None.

Applications wishing to check for error situations should set errno to 0 before calling getgrnam() . If errno is set on return, an error occurred.

None.

endgrent(3) , getgrgid(3) , <grp.h> , <limits.h> , <sys/types.h> .

getgrnam() derived from System V Release 2.0.

getgrnam_r() derived the POSIX Threads Extension (1003.1c-1995).

February 1997 posix.fail