mirror of https://github.com/mkerrisk/man-pages
120 lines
3.9 KiB
Plaintext
120 lines
3.9 KiB
Plaintext
|
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||
|
.TH "GETGRNAM" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||
|
.\" getgrnam
|
||
|
.SH NAME
|
||
|
getgrnam, getgrnam_r \- search group database for a name
|
||
|
.SH SYNOPSIS
|
||
|
.LP
|
||
|
\fB#include <grp.h>
|
||
|
.br
|
||
|
.sp
|
||
|
struct group *getgrnam(const char *\fP\fIname\fP\fB);
|
||
|
.br
|
||
|
\fP
|
||
|
.LP
|
||
|
\fBint getgrnam_r(const char *\fP\fIname\fP\fB, struct group *\fP\fIgrp\fP\fB,
|
||
|
char
|
||
|
*\fP\fIbuffer\fP\fB,
|
||
|
.br
|
||
|
\ \ \ \ \ \ size_t\fP \fIbufsize\fP\fB, struct group **\fP\fIresult\fP\fB);
|
||
|
\fP
|
||
|
\fB
|
||
|
.br
|
||
|
\fP
|
||
|
.SH DESCRIPTION
|
||
|
.LP
|
||
|
The \fIgetgrnam\fP() function shall search the group database for
|
||
|
an entry with a matching \fIname\fP.
|
||
|
.LP
|
||
|
The \fIgetgrnam\fP() function need not be reentrant. A function that
|
||
|
is not required to be reentrant is not required to be
|
||
|
thread-safe.
|
||
|
.LP
|
||
|
The \fIgetgrnam_r\fP() function shall update the \fBgroup\fP structure
|
||
|
pointed to by \fIgrp\fP and store a pointer to that
|
||
|
structure at the location pointed to by \fIresult\fP. The structure
|
||
|
shall contain an entry from the group database with a matching
|
||
|
\fIgid\fP or \fIname\fP. Storage referenced by the \fBgroup\fP structure
|
||
|
is allocated from the memory provided with the
|
||
|
\fIbuffer\fP parameter, which is \fIbufsize\fP bytes in size. The
|
||
|
maximum size needed for this buffer can be determined with the
|
||
|
{_SC_GETGR_R_SIZE_MAX} \fIsysconf\fP() parameter. A NULL pointer is
|
||
|
returned at the
|
||
|
location pointed to by \fIresult\fP on error or if the requested entry
|
||
|
is not found.
|
||
|
.SH RETURN VALUE
|
||
|
.LP
|
||
|
The \fIgetgrnam\fP() function shall return a pointer to a \fBstruct
|
||
|
group\fP with the structure defined in \fI<grp.h>\fP with a matching
|
||
|
entry if one is found. The \fIgetgrnam\fP() function shall
|
||
|
return a null pointer if either the requested entry was not found,
|
||
|
or an error occurred. On error, \fIerrno\fP shall be set to
|
||
|
indicate the error.
|
||
|
.LP
|
||
|
The return value may point to a static area which is overwritten by
|
||
|
a subsequent call to \fIgetgrent\fP(), \fIgetgrgid\fP(), or
|
||
|
\fIgetgrnam\fP().
|
||
|
.LP
|
||
|
If successful, the \fIgetgrnam_r\fP() function shall return zero;
|
||
|
otherwise, an error number shall be returned to indicate the
|
||
|
error.
|
||
|
.SH ERRORS
|
||
|
.LP
|
||
|
The \fIgetgrnam\fP() and \fIgetgrnam_r\fP() functions may fail if:
|
||
|
.TP 7
|
||
|
.B EIO
|
||
|
An I/O error has occurred.
|
||
|
.TP 7
|
||
|
.B EINTR
|
||
|
A signal was caught during \fIgetgrnam\fP().
|
||
|
.TP 7
|
||
|
.B EMFILE
|
||
|
{OPEN_MAX} file descriptors are currently open in the calling process.
|
||
|
.TP 7
|
||
|
.B ENFILE
|
||
|
The maximum allowable number of files is currently open in the system.
|
||
|
.sp
|
||
|
.LP
|
||
|
The \fIgetgrnam_r\fP() function may fail if:
|
||
|
.TP 7
|
||
|
.B ERANGE
|
||
|
Insufficient storage was supplied via \fIbuffer\fP and \fIbufsize\fP
|
||
|
to contain the data to be referenced by the resulting
|
||
|
\fBgroup\fP structure.
|
||
|
.sp
|
||
|
.LP
|
||
|
\fIThe following sections are informative.\fP
|
||
|
.SH EXAMPLES
|
||
|
.LP
|
||
|
None.
|
||
|
.SH APPLICATION USAGE
|
||
|
.LP
|
||
|
Applications wishing to check for error situations should set \fIerrno\fP
|
||
|
to 0 before calling \fIgetgrnam\fP(). If
|
||
|
\fIerrno\fP is set on return, an error occurred.
|
||
|
.LP
|
||
|
The \fIgetgrnam_r\fP() function is thread-safe and shall return values
|
||
|
in a user-supplied buffer instead of possibly using a
|
||
|
static data area that may be overwritten by each call.
|
||
|
.SH RATIONALE
|
||
|
.LP
|
||
|
None.
|
||
|
.SH FUTURE DIRECTIONS
|
||
|
.LP
|
||
|
None.
|
||
|
.SH SEE ALSO
|
||
|
.LP
|
||
|
\fIendgrent\fP() , \fIgetgrgid\fP() , the Base Definitions volume
|
||
|
of
|
||
|
IEEE\ Std\ 1003.1-2001, \fI<grp.h>\fP, \fI<limits.h>\fP, \fI<sys/types.h>\fP
|
||
|
.SH COPYRIGHT
|
||
|
Portions of this text are reprinted and reproduced in electronic form
|
||
|
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||
|
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||
|
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||
|
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||
|
event of any discrepancy between this version and the original IEEE and
|
||
|
The Open Group Standard, the original IEEE and The Open Group Standard
|
||
|
is the referee document. The original Standard can be obtained online at
|
||
|
http://www.opengroup.org/unix/online.html .
|