getgrgid_r() — Get group database entry for a group ID

Standards

Standards / Extensions C or C++ Dependencies

Single UNIX Specification, Version 2
Single UNIX Specification, Version 3
z/OS® UNIX

both OS/390 V2R8

Format

#define _XOPEN_SOURCE 500
#include <sys/types.h>
#include <grp.h>

int getgrgid_r(gid_t gid, struct group *grp, char *buffer,
size_t bufsize, struct group **result);
 
#define _POSIX_SOURCE
#include <grp.h>

int __getgrgid1(gid_t gid, struct group *grp, char *buffer,
size_t bufsize, struct group **result);

General description

The getgrgid_r() function updates the group structure pointed to by grp and stores a pointer to that structure at the location pointed to by result. The structure contains an entry from the group database with a matching gid. Storage referenced by the group structure is allocated from the memory provided with the buffer parameter, which is bufsize bytes in size. A NULL pointer is returned at the location pointed to by result on error or if the requested entry is not found.

The __getgrgid1() function is identical to getgrgid_r() except that it does not return the individual group member names. Element gr_mem of the group structure pointed to by grp will be set to NULL.

Returned value

If successful, getgrgid_r() or __getgrgid1() returns 0.

If unsuccessful, getgrgid_r() or __getgrgid1() returns an error number and sets errno to one of the following values:

Error Code
Description
EINVAL
One of the input arguments was not valid. Arguments grp, buffer, and result must not be NULL. Argument bufsize must not be 0.
ERANGE
Insufficient storage was supplied in buffer and bufsize to contain the data to be referenced by the resulting group structure.
EMVSSAFEXTRERR
The system authorization facility (SAF) RACROUTE EXTRACT service had an error.
EMVSSAF2ERR
The SAF Get GMAP service had an error.

Related information