Get information about the group with a given ID
#include <sys/types.h> #include <grp.h> int getgrgid_r ( gid_t gid, struct group* grp, char* buffer, size_t bufsize, struct group** result );
- The ID of the group you want to get information about.
- A pointer to a group structure where the function can store information about the group.
- A buffer from which to allocate any memory required.
- The size of the buffer.
- The address of a pointer that getgrgid_r() sets to the same pointer as grp on success, or to NULL if the function can't find the group.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
If _POSIX_THREAD_SAFE_FUNCTIONS is defined, getgrgid_r() updates the group structure pointed by grp and stores a pointer to that structure at the location pointed by result. The structure contains an entry from the group database with a matching gid.
This function allocates storage referenced by the group structure from the memory provided with the buffer parameter, which is bufsize characters in size. You can determine the maximum size needed for this buffer by calling sysconf() with an argument of _SC_GETGR_R_SIZE_MAX.
The getgrgid_r() stores a NULL pointer at the location pointed by result on error or if the requested entry isn't found.
Zero for success, or an error number if an error occurred.
- Insufficient storage was supplied via buffer and bufsize to contain the resulting group structure.
The getgrgid_r() function uses the following functions, and as a result, errno can be set to an error for any of these calls: