OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man3 / getgrnam.3
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .\" References consulted:
25 .\"     Linux libc source code
26 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\"     386BSD man pages
28 .\"
29 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
30 .\" Modified 2003-11-15 by aeb
31 .\"
32 .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka
33 .\"     all rights reserved.
34 .\" Translated 1997-12-19, HIROFUMI Nishizuka <nishi@rpts.cl.nec.co.jp>
35 .\" Updated & Modefied 1999-02-26, Shouichi Saito
36 .\" Updated & Modified 2004-06-05, Yuichi SATO <ysato444@yahoo.co.jp>
37 .\" Updated & Modified 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
38 .\" Updated 2008-12-24, Akihiro MOTOKI, LDP v3.14
39 .\"
40 .TH GETGRNAM 3 2009-03-30 "" "Linux Programmer's Manual"
41 .\"O .SH NAME
42 .SH Ì¾Á°
43 .\"O getgrnam, getgrnam_r, getgrgid, getgrgid_r \- get group file entry
44 getgrnam, getgrnam_r, getgrgid, getgrgid_r \- ¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë¥¨¥ó¥È¥ê¤Î¼è¤ê½Ð¤·
45 .\"O .SH SYNOPSIS
46 .SH ½ñ¼°
47 .nf
48 .B #include <sys/types.h>
49 .B #include <grp.h>
50 .sp
51 .BI "struct group *getgrnam(const char *" name );
52 .sp
53 .BI "struct group *getgrgid(gid_t " gid );
54 .sp
55 .BI "int getgrnam_r(const char *" name ", struct group *" grp ,
56 .br
57 .BI "          char *" buf ", size_t " buflen ", struct group **" result );
58 .sp
59 .BI "int getgrgid_r(gid_t " gid ", struct group *" grp ,
60 .br
61 .BI "          char *" buf ", size_t " buflen ", struct group **" result );
62 .fi
63 .sp
64 .in -4n
65 .\"O Feature Test Macro Requirements for glibc (see
66 .\"O .BR feature_test_macros (7)):
67 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
68 .RB ( feature_test_macros (7)
69 »²¾È):
70 .ad l
71 .in
72 .sp
73 .BR getgrnam_r (),
74 .BR getgrgid_r ():
75 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE ||
76 _SVID_SOURCE || _POSIX_SOURCE
77 .ad b
78 .\"O .SH DESCRIPTION
79 .SH ÀâÌÀ
80 .\"O The
81 .\"O .BR getgrnam ()
82 .\"O function returns a pointer to a structure containing
83 .\"O the broken-out fields of the record in the group database
84 .\"O (e.g., the local group file
85 .\"O .IR /etc/group ,
86 .\"O NIS, and LDAP)
87 .\"O that matches the group name
88 .\"O .IR name .
89 .BR getgrnam ()
90 ´Ø¿ô¤Ï¡¢¥°¥ë¡¼¥×̾
91 .I name
92 ¤Ë¥Þ¥Ã¥Á¤¹¤ë¥°¥ë¡¼¥×¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥¨¥ó¥È¥ê¤ò
93 Í×ÁÇËè¤Ëʬ²ò¤·¡¢³ÆÍ×ÁǤò³ÊǼ¤·¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹
94 (¥Ñ¥¹¥ï¡¼¥É¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÎã:
95 ¥í¡¼¥«¥ë¤Î¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë
96 .IR /etc/group ,
97 NIS, LDAP)¡£
98 .PP
99 .\"O The
100 .\"O .BR getgrgid ()
101 .\"O function returns a pointer to a structure containing
102 .\"O the broken-out fields of the record in the group database
103 .\"O that matches the group ID
104 .\"O .IR gid .
105 .BR getgrgid ()
106 ´Ø¿ô¤Ï¡¢¥°¥ë¡¼¥× ID
107 .I uid
108 ¤Ë¥Þ¥Ã¥Á¤¹¤ë¥°¥ë¡¼¥×¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥¨¥ó¥È¥ê¤ò
109 Í×ÁÇËè¤Ëʬ²ò¤·¡¢³ÆÍ×ÁǤò³ÊǼ¤·¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
110 .PP
111 .\"O The
112 .\"O .BR getgrnam_r ()
113 .\"O and
114 .\"O .BR getgrgid_r ()
115 .\"O functions obtain the same information, but store the retrieved
116 .\"O .I group
117 .\"O structure
118 .\"O in the space pointed to by
119 .\"O .IR grp .
120 .BR getgrnam_r ()
121 ¤È
122 .BR getgrgid_r ()
123 ´Ø¿ô¤Ï (¾åµ­¤Î´Ø¿ô¤È) Æ±¤¸¾ðÊó¤ò¼èÆÀ¤¹¤ë¤¬¡¢
124 ¼èÆÀ¤·¤¿
125 .I group
126 ¹½Â¤ÂΤò
127 .I grp
128 ¤¬»Ø¤¹Îΰè¤Ë³ÊǼ¤¹¤ë¡£
129 .\"O This
130 .\"O .I group
131 .\"O structure contains pointers to strings, and these strings
132 .\"O are stored in the buffer
133 .\"O .I buf
134 .\"O of size
135 .\"O .IR buflen .
136 ¤³¤Î
137 .I group
138 ¹½Â¤ÂΤˤÏʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬´Þ¤Þ¤ì¡¢
139 ¤³¤ì¤é¤Îʸ»úÎó¤Ï¥µ¥¤¥º
140 .I buflen
141 ¤Î¥Ð¥Ã¥Õ¥¡
142 .I buf
143 ¤Ë³ÊǼ¤µ¤ì¤ë¡£
144 .\"O A pointer to the result (in case of success) or NULL (in case no entry
145 .\"O was found or an error occurred) is stored in
146 .\"O .IR *result .
147 À®¸ù¤·¤¿¾ì¹ç
148 .I *gbufp
149 ¤Ë¤Ï·ë²Ì¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬³ÊǼ¤µ¤ì¤ë¡£
150 ¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤ä¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ë¤Ï
151 .I *result
152 ¤Ë¤Ï NULL ¤¬Æþ¤ë¡£
153 .PP
154 .\"O The \fIgroup\fP structure is defined in \fI<grp.h>\fP as follows:
155 \fIgroup\fP ¹½Â¤ÂΤϡ¢\fI<grp.h>\fP ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
156 .sp
157 .in +4n
158 .nf
159 struct group {
160 .\"O     char   *gr_name;       /* group name */
161 .\"O     char   *gr_passwd;     /* group password */
162 .\"O     gid_t   gr_gid;        /* group ID */
163 .\"O     char  **gr_mem;        /* group members */
164     char   *gr_name;       /* ¥°¥ë¡¼¥×̾ */
165     char   *gr_passwd;     /* ¥°¥ë¡¼¥×¤Î¥Ð¥¹¥ï¡¼¥É */
166     gid_t   gr_gid;        /* ¥°¥ë¡¼¥× ID */
167     char  **gr_mem;        /* ¥°¥ë¡¼¥×¤Î¥á¥ó¥Ð */
168 };
169 .fi
170 .in
171 .PP
172 .\"O The maximum needed size for
173 .\"O .I buf
174 .\"O can be found using
175 .\"O .BR sysconf (3)
176 .\"O with the argument
177 .\"O .BR _SC_GETGR_R_SIZE_MAX .
178 .I buf
179 ¤ËºÇÂçɬÍפʥµ¥¤¥º¤Ï¡¢
180 .BR sysconf (3)
181 ¤Ë°ú¤­¿ô
182 .B _SC_GETGR_R_SIZE_MAX
183 ¤ò»ØÄꤷ¤Æ¼Â¹Ô¤¹¤ë¤³¤È¤Çʬ¤«¤ë¡£
184 .\"O .SH "RETURN VALUE"
185 .SH ÊÖ¤êÃÍ
186 .\"O The
187 .\"O .BR getgrnam ()
188 .\"O and
189 .\"O .BR getgrgid ()
190 .\"O functions return a pointer to a
191 .\"O .I group
192 .\"O structure, or NULL if the matching entry
193 .\"O is not found or an error occurs.
194 .BR getgrnam ()
195 ¤È
196 .BR getgrgid ()
197 ´Ø¿ô¤Ï¡¢
198 .I group
199 ¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
200 ¥Þ¥Ã¥Á¤¹¤ë¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤ä¡¢
201 ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï NULL ¤òÊÖ¤¹¡£
202 .\"O If an error occurs,
203 .\"O .I errno
204 .\"O is set appropriately.
205 .\"O If one wants to check
206 .\"O .I errno
207 .\"O after the call, it should be set to zero before the call.
208 ¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¾ì¹ç¡¢
209 .I errno
210 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
211 ¸Æ¤Ó½Ð¤·¤Î¸å¤Ç
212 .I errno
213 ¤ò¥Á¥§¥Ã¥¯¤·¤¿¤¤¾ì¹ç¤Ï¡¢
214 ¸Æ¤Ó½Ð¤·¤ÎÁ°¤Ë (¤³¤ÎÃͤò) 0 ¤ËÀßÄꤷ¤Æ¤ª¤¯¤Ù¤­¤Ç¤¢¤ë¡£
215 .LP
216 .\"O The return value may point to a static area, and may be overwritten
217 .\"O by subsequent calls to
218 .\"O .BR getgrent (3),
219 .\"O .BR getgrgid (),
220 .\"O or
221 .\"O .BR getgrnam ().
222 .\"O (Do not pass the returned pointer to
223 .\"O .BR free (3).)
224 ÊÖ¤êÃͤÏÀÅŪ¤ÊÎΰè¤ò»Ø¤·¤Æ¤ª¤ê¡¢¤½¤Î¸å¤Î
225 .BR getgrent (3),
226 .BR getgrgid (),
227 .BR getgrnam ()
228 ¤Î¸Æ¤Ó½Ð¤·¤Ç¾å½ñ¤­¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
229 (ÊÖ¤µ¤ì¤¿¥Ý¥¤¥ó¥¿¤ò
230 .BR free (3)
231 ¤ËÅϤµ¤Ê¤¤¤³¤È¡£)
232 .LP
233 .\"O On success,
234 .\"O .BR getgrnam_r ()
235 .\"O and
236 .\"O .BR getgrgid_r ()
237 .\"O return zero, and set
238 .\"O .IR *result
239 .\"O to
240 .\"O .IR grp .
241 .\"O If no matching group record was found,
242 .\"O these functions return 0 and store NULL in
243 .\"O .IR *result .
244 .\"O In case of error, an error number is returned, and NULL is stored in
245 .\"O .IR *result .
246 À®¸ù¤¹¤ë¤È¡¢
247 .BR getgrnam_r ()
248 ¤È
249 .BR getgrgid_r ()
250 ¤Ï 0 ¤òÊÖ¤·¡¢
251 .I *result
252 ¤Ë
253 .I grp
254 ¤òÀßÄꤹ¤ë¡£
255 ¥Þ¥Ã¥Á¤¹¤ë¥°¥ë¡¼¥×¡¦¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢
256 0 ¤òÊÖ¤·¡¢
257 .I *result
258 ¤Ë NULL ¤òÀßÄꤹ¤ë¡£
259 ¥¨¥é¡¼¤Î¾ì¹ç¡¢¥¨¥é¡¼ÈÖ¹æ¤òÊÖ¤·¡¢
260 .I *result
261 ¤Ë NULL ¤òÀßÄꤹ¤ë¡£
262 .\"O .SH ERRORS
263 .SH ¥¨¥é¡¼
264 .TP
265 .\"O .BR 0 " or " ENOENT " or " ESRCH " or " EBADF " or " EPERM " or ... "
266 .BR 0 " ¤Þ¤¿¤Ï " ENOENT " ¤Þ¤¿¤Ï " ESRCH " ¤Þ¤¿¤Ï " EBADF " ¤Þ¤¿¤Ï " EPERM " ¤Þ¤¿¤Ï ... "
267 .\"O The given
268 .\"O .I name
269 .\"O or
270 .\"O .I gid
271 .\"O was not found.
272 »ØÄꤵ¤ì¤¿
273 .I name
274 ¤Þ¤¿¤Ï
275 .I gid
276 ¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¡£
277 .TP
278 .B EINTR
279 .\"O A signal was caught.
280 ¥·¥°¥Ê¥ë¤¬¥­¥ã¥Ã¥Á¤µ¤ì¤¿¡£
281 .TP
282 .B EIO
283 .\"O I/O error.
284 I/O ¥¨¥é¡¼¡£
285 .TP
286 .B EMFILE
287 .\"O The maximum number
288 .\"O .RB ( OPEN_MAX )
289 .\"O of files was open already in the calling process.
290 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Ë¤ª¤¤¤Æ¡¢
291 ´û¤ËºÇÂç¿ô
292 .RB ( OPEN_MAX )
293 ¤Î¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¡£
294 .TP
295 .B ENFILE
296 .\"O The maximum number of files was open already in the system.
297 ¥·¥¹¥Æ¥à¾å¤Ç´û¤ËºÇÂç¿ô¤Î¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¡£
298 .TP
299 .B ENOMEM
300 .\"O .\" not in POSIX
301 .\"O Insufficient memory to allocate
302 .\"O .I group
303 .\"O structure.
304 .\"O .\" to allocate the group structure, or to allocate buffers
305 .\" POSIX ¤Ë¤Ï¤Ê¤¤
306 .I group
307 ¹½Â¤ÂΤò³ä¤êÅö¤Æ¤ë¤¿¤á¤Î¥á¥â¥ê¤¬ÉÔ½½Ê¬¡£
308 .\" ¥°¥ë¡¼¥×¾ðÊó¹½Â¤ÂΤò³ä¤êÅö¤Æ¤ë¤¿¤á¡¢¤Þ¤¿¤Ï¥Ð¥Ã¥Õ¥¡¤ò³ä¤êÅö¤Æ¤ë¤¿¤á¤Î
309 .TP
310 .B ERANGE
311 .\"O Insufficient buffer space supplied.
312 Í¿¤¨¤é¤ì¤¿¥Ð¥Ã¥Õ¥¡¶õ´Ö¤¬ÉÔ½½Ê¬¤Ç¤¢¤ë¡£
313 .\"O .SH FILES
314 .SH ¥Õ¥¡¥¤¥ë
315 .TP
316 .I /etc/group
317 .\"O local group database file
318 ¥í¡¼¥«¥ë¤Î¥°¥ë¡¼¥×¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë
319 .\"O .SH "CONFORMING TO"
320 .SH ½àµò
321 SVr4, 4.3BSD, POSIX.1-2001.
322 .\"O .SH NOTES
323 .SH Ãí°Õ
324 .\"O The formulation given above under "RETURN VALUE" is from POSIX.1-2001.
325 ¾åµ­¤Î¡ÖÊÖ¤êÃ͡װʲ¼¤Îµ­½Ò¤Ï POSIX.1-2001 ¤Ëµò¤ë¡£
326 .\"O It does not call "not found" an error, hence does not specify what value
327 .\"O .I errno
328 .\"O might have in this situation.
329 .\"O But that makes it impossible to recognize
330 .\"O errors.
331 .\"O One might argue that according to POSIX
332 .\"O .I errno
333 .\"O should be left unchanged if an entry is not found.
334 .\"O Experiments on various
335 .\"O Unix-like systems shows that lots of different values occur in this
336 .\"O situation: 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM and probably others.
337 ¤³¤Îɸ½à¤Ï¡Ö(¥¨¥ó¥È¥ê¤¬) ¸«¤Ä¤«¤é¤Ê¤¤¤³¤È¡×¤ò¥¨¥é¡¼¤È¤·¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢
338 ¤½¤Î¤è¤¦¤Ê¾ì¹ç¤Ë
339 .I errno
340 ¤¬¤É¤Î¤è¤¦¤ÊÃͤˤʤ뤫¤òÄê¤á¤Æ¤¤¤Ê¤¤¡£
341 ¤½¤Î¤¿¤á¡¢¥¨¥é¡¼¤òǧ¼±¤¹¤ë¤³¤È¤ÏÉÔ²Äǽ¤Ç¤¢¤ë¡£
342 POSIX ¤Ë½àµò¤·¤Æ¡¢¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤¤¾ì¹ç¤Ï
343 .I errno
344 ¤òÊѹ¹¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤Ù¤­¤Ç¤¢¤ë¡¢¤È¼çÄ¥¤¹¤ë¿Í¤â¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
345 ÍÍ¡¹¤Ê Unix ·Ï¤Î¥·¥¹¥Æ¥à¤Ç»î¤·¤Æ¤ß¤ë¤È¡¢¤½¤Î¤è¤¦¤Ê¾ì¹ç¤Ë¤Ï
346 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM ¤È¤¤¤Ã¤¿ÍÍ¡¹¤ÊÃͤ¬ÊÖ¤µ¤ì¤ë¡£
347 ¾¤ÎÃͤ¬ÊÖ¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
348 .\"O .\" more precisely:
349 .\"O .\" AIX 5.1 - gives ESRCH
350 .\"O .\" OSF1 4.0g - gives EWOULDBLOCK
351 .\"O .\" libc, glibc up to version 2.6, Irix 6.5 - give ENOENT
352 .\"O .\" glibc since version 2.7 - give 0
353 .\"O .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 - give EPERM
354 .\"O .\" SunOS 5.8 - gives EBADF
355 .\"O .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 - give 0
356 .\" ¤è¤êÀµ³Î¤Ë¤Ï:
357 .\" AIX 5.1 ¤Ï ESRCH ¤òÊÖ¤¹¡£
358 .\" OSF1 4.0g ¤Ï EWOULDBLOCK ¤òÊÖ¤¹¡£
359 .\" libc, glibc (¥Ð¡¼¥¸¥ç¥ó 2.6 ¤Þ¤Ç), Irix 6.5 ¤Ï ENOENT ¤òÊÖ¤¹¡£
360 .\" glibc (¥Ð¡¼¥¸¥ç¥ó 2.7 °Ê¹ß) ¤Ï 0 ¤òÊÖ¤¹¡£
361 .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 ¤Ï EPERM ¤òÊÖ¤¹¡£
362 .\" SunOS 5.8 ¤Ï EBADF ¤òÊÖ¤¹¡£
363 .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 ¤Ï 0 ¤òÊÖ¤¹¡£
364 .\"O .SH "SEE ALSO"
365 .SH ´ØÏ¢¹àÌÜ
366 .BR endgrent (3),
367 .BR fgetgrent (3),
368 .BR getgrent (3),
369 .BR getpwnam (3),
370 .BR setgrent (3),
371 .BR group (5)