[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

getgrgid_r Subroutine

Purpose

Gets a group database entry for a group ID.

Library

Thread-Safe C Library (libc_r.a)

Syntax

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

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

Description

The getgrgid_r subroutine 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 characters in size. The maximum size needed for this buffer can be determined with the {_SC_GETGR_R_SIZE_MAX} sysconf parameter. A NULL pointer is returned at the location pointed to by result on error or if the requested entry is not found.

Return Values

Upon successful completion, getgrgid_r returns a pointer to a struct group with the structure defined in <grp.h> with a matching entry if one is found. The getgrgid_r 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 points to a static area that is overwritten by a subsequent call to the getgrent, getgrgid, or getgrnam subroutine.

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

Error Codes

The getgrgid_r function fails if:

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

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

Implementation Specifics

The getgrent, getgrgid, getgrnam, setgrent, endgrent subroutine.

The <grp.h>, <limits.h>, and <sys/types.h> header files.


[ Previous | Next | Contents | Glossary | Home | Search ]