230 lines
7.4 KiB
HTML
230 lines
7.4 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
||
|
<title>getgroups()--Get Group IDs</title>
|
||
|
<!-- Begin Header Records ========================================= -->
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<!-- Change History: -->
|
||
|
<!-- file cleaned -->
|
||
|
<!-- Unix2 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
||
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
||
|
<!-- File cleanup completed Feb 2002 by v2cdijab -->
|
||
|
<!-- This file has undergone html cleanup on 05/14/02 by JET -->
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<!-- End Header Records -->
|
||
|
<!-- Java sync-link -->
|
||
|
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
|
||
|
</script>
|
||
|
|
||
|
<a name="Top_Of_Page"></a>
|
||
|
|
||
|
<h2>getgroups()--Get Group IDs</h2>
|
||
|
|
||
|
<!-- =========================================== -->
|
||
|
<!-- S Y N T A X / P A R M T A B L E -->
|
||
|
<!-- =========================================== -->
|
||
|
<div class="box" style="width: 70%;">
|
||
|
<br>
|
||
|
Syntax<br>
|
||
|
<pre>
|
||
|
#include <unistd.h>
|
||
|
|
||
|
int getgroups(int <em>gidsetsize</em>, gid_t <em>grouplist</em>[])
|
||
|
</pre>
|
||
|
|
||
|
Service Program Name: QSYPAPI<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Default Public Authority: *USE<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Threadsafe: No<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<!-- =========================================== -->
|
||
|
<!-- D E F I N I T I O N -->
|
||
|
<!-- =========================================== -->
|
||
|
<p>If the <em>gidsetsize</em> argument is zero, <strong>getgroups()</strong>
|
||
|
returns the number of group IDs associated with the calling thread without
|
||
|
modifying the array pointed to by the <em>grouplist</em> argument. The number
|
||
|
of group IDs includes the effective group ID and the supplementary group IDs.
|
||
|
Otherwise, <strong>getgroups()</strong> fills in the array <em>grouplist</em>
|
||
|
with the effective group ID and supplementary group IDs of the calling thread
|
||
|
and returns the actual number of group IDs stored. The values of array entries
|
||
|
with indexes larger than or equal to the returned value are undefined.</p>
|
||
|
|
||
|
<br>
|
||
|
<!-- =========================================== -->
|
||
|
<!-- P A R A M E T E R S -->
|
||
|
<!-- =========================================== -->
|
||
|
|
||
|
<h3>Parameters</h3>
|
||
|
|
||
|
<!-- Parameter 1 -->
|
||
|
<dl>
|
||
|
<dt><strong><em>gidsetsize</em></strong></dt>
|
||
|
|
||
|
<dd>(Input) The number of elements in the supplied array <em>
|
||
|
grouplist</em>.<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<!-- Parameter 2 -->
|
||
|
<dt><strong><em>grouplist</em></strong></dt>
|
||
|
|
||
|
<dd>(Output) The effective group ID and supplementary group IDs. The first
|
||
|
element in <em>grouplist</em> is the effective group ID.</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
<!-- =========================================== -->
|
||
|
<!-- A U T H O R I T I E S A N D L O C K S -->
|
||
|
<!-- =========================================== -->
|
||
|
|
||
|
<h3>Authorities</h3>
|
||
|
|
||
|
<p>No authorization is required.</p>
|
||
|
|
||
|
<br>
|
||
|
<!-- =========================================== -->
|
||
|
<!-- R E T U R N V A L U E -->
|
||
|
<!-- =========================================== -->
|
||
|
|
||
|
<h3>Return Value</h3>
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="15 85" -->
|
||
|
<tr>
|
||
|
<td align="left" valign="top" nowrap><em>0 or > 0</em></td>
|
||
|
<td align="left" valign="top"><strong>getgroups()</strong> was successful. If
|
||
|
the <em>gidsetsize</em> argument is 0, the number of group IDs is returned.
|
||
|
This number includes the effective group ID and supplementary group IDs. If
|
||
|
<em>gidsetsize</em> is greater than 0, the array <em>grouplist</em> is filled
|
||
|
with the effective group ID and supplementary group IDs of the calling thread
|
||
|
and the return value represents the actual number of group IDs stored.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-1</em></td>
|
||
|
<td align="left" valign="top"><strong>getgroups()</strong> was not successful.
|
||
|
The <em>errno</em> global variable is set to indicate the error.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
<br>
|
||
|
<!-- =========================================== -->
|
||
|
<!-- E R R O R C O N D I T I O N S -->
|
||
|
<!-- =========================================== -->
|
||
|
|
||
|
<h3>Error Conditions</h3>
|
||
|
|
||
|
<p>If <strong>getgroups()</strong> is not successful, <em>errno</em> usually
|
||
|
indicates one of the following errors. Under some conditions, <em>errno</em>
|
||
|
could indicate an error other than those listed here.</p>
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="25 75" -->
|
||
|
|
||
|
<tr>
|
||
|
<th align="left" valign="bottom">Error condition</th>
|
||
|
<th align="left" valign="bottom">Additional information</th>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EINVAL">EINVAL</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
<p>The <em>gidsetsize</em> argument is not equal to zero and is less than the
|
||
|
number of group IDs.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
<!-- =========================================== -->
|
||
|
<!-- U S A G E N O T E S -->
|
||
|
<!-- =========================================== -->
|
||
|
|
||
|
<h3><a name="USAGE_NOTES">Usage Notes</a></h3>
|
||
|
|
||
|
<p>This function can be used in two different ways. First, if called with <em>
|
||
|
gidsetsize</em> equal to 0, it is used to return the number of groups
|
||
|
associated with a thread. Second, if called with <em>gidsetsize</em> not equal
|
||
|
to 0, it is used to return a list of the <samp>GID</samp>s representing the
|
||
|
effective and supplementary groups associated with a thread. In this case, the
|
||
|
<em>gidsetsize</em> argument represents how much space is available in the <em>
|
||
|
grouplist</em> argument.</p>
|
||
|
|
||
|
<p>The calling routine can choose to call this function with <em>
|
||
|
gidsetsize</em> equal to 0 to determine how much space to allocate for a second
|
||
|
call to this function. The second call returns the values. The following is an
|
||
|
example of this method:</p>
|
||
|
|
||
|
<pre>
|
||
|
int numgroups;
|
||
|
gid_t *grouplist;
|
||
|
|
||
|
numgroups = getgroups(0,NULL);
|
||
|
grouplist = (gid_t *) calloc( numgroups, sizeof(gid_t) );
|
||
|
if (getgroups( numgroups, grouplist) != -1) {
|
||
|
.
|
||
|
.
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p>Alternatively, the calling routine can choose to create enough space for
|
||
|
NGROUPS_MAX entries to ensure enough space is available for the maximum
|
||
|
possible number of entries that may be returned. This introduces the
|
||
|
possibility of wasted space. The following is an example of this method:</p>
|
||
|
|
||
|
<pre>
|
||
|
int numgroups;
|
||
|
gid_t grouplist[ NGROUPS_MAX ];
|
||
|
|
||
|
if ( getgroups( NGROUPS_MAX, grouplist ) != -1 ) {
|
||
|
.
|
||
|
.
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<br>
|
||
|
<!-- =========================================== -->
|
||
|
<!-- R E L A T E D I N F O R M A T I O N -->
|
||
|
<!-- =========================================== -->
|
||
|
|
||
|
<h3>Related Information</h3>
|
||
|
|
||
|
<ul>
|
||
|
<li>The <<strong>unistd.h</strong>> file (see <a href="unix13.htm">Header
|
||
|
Files for UNIX-Type Functions</a>)</li>
|
||
|
</ul>
|
||
|
|
||
|
<br>
|
||
|
<hr>
|
||
|
API introduced: V3R1
|
||
|
|
||
|
<hr>
|
||
|
<center>
|
||
|
<table cellpadding="2" cellspacing="2">
|
||
|
<tr align="center">
|
||
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
||
|
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</center>
|
||
|
</body>
|
||
|
</html>
|
||
|
|