source: rtems/cpukit/posix/src/types.c @ 05ce4e09

4.104.114.84.95
Last change on this file since 05ce4e09 was 05ce4e09, checked in by Joel Sherrill <joel.sherrill@…>, on 06/07/96 at 15:21:27

changed code which set errno and then returned -1 to use the macro
set_errno_and_return_minus_one.

  • Property mode set to 100644
File size: 3.1 KB
RevLine 
[7f72217e]1/*
[eb5a7e07]2 *  $Id$
[5e9b32b]3 */
4
[c48e0ee]5#include <limits.h>
6#include <errno.h>
7#include <string.h>
[5e9b32b]8#include <sys/types.h>
9
[f4719d5a]10#include <rtems/system.h>
[c238a218]11#include <rtems/score/object.h>
[05ce4e09]12#include <rtems/posix/seterr.h>
[f4719d5a]13
[c48e0ee]14pid_t _POSIX_types_Ppid = 0;
15uid_t _POSIX_types_Uid = 0;
16uid_t _POSIX_types_Euid = 0;
17gid_t _POSIX_types_Gid = 0;
18gid_t _POSIX_types_Egid = 0;
19
[5e9b32b]20/*PAGE
21 *
22 *  4.1.1 Get Process and Parent Process IDs, P1003.1b-1993, p. 83
23 */
24
25pid_t getpid( void )
26{
[c238a218]27  return _Objects_Local_node;
[5e9b32b]28}
29
30/*PAGE
31 *
32 *  4.1.1 Get Process and Parent Process IDs, P1003.1b-1993, p. 83
33 */
34
35pid_t getppid( void )
36{
[c48e0ee]37  return _POSIX_types_Ppid;
[5e9b32b]38}
39
40/*PAGE
41 *
42 *  4.2.1 Get Real User, Effective User, Ral Group, and Effective Group IDs,
43 *        P1003.1b-1993, p. 84
44 */
45
46uid_t getuid( void )
47{
[c48e0ee]48  return _POSIX_types_Uid;
[5e9b32b]49}
50
51/*PAGE
52 *
53 *  4.2.1 Get Real User, Effective User, Ral Group, and Effective Group IDs,
54 *        P1003.1b-1993, p. 84
55 */
56
57uid_t geteuid( void )
58{
[c48e0ee]59  return _POSIX_types_Euid;
[5e9b32b]60}
61
62/*PAGE
63 *
64 *  4.2.1 Get Real User, Effective User, Ral Group, and Effective Group IDs,
65 *        P1003.1b-1993, p. 84
66 */
67
68gid_t getgid( void )
69{
[c48e0ee]70  return _POSIX_types_Gid;
[5e9b32b]71}
72
73/*PAGE
74 *
75 *  4.2.1 Get Real User, Effective User, Ral Group, and Effective Group IDs,
76 *        P1003.1b-1993, p. 84
77 */
78
79gid_t getegid( void )
80{
[c48e0ee]81  return _POSIX_types_Egid;
[5e9b32b]82}
83
84/*PAGE
85 *
86 *  4.2.2 Set User and Group IDs, P1003.1b-1993, p. 84
87 */
88
89int setuid(
90  uid_t  uid
91)
92{
[c48e0ee]93  _POSIX_types_Uid = uid;
94  return 0;
[5e9b32b]95}
96
97/*PAGE
98 *
99 *  4.2.2 Set User and Group IDs, P1003.1b-1993, p. 84
100 */
101
102int setgid(
103  gid_t  gid
104)
105{
[c48e0ee]106  _POSIX_types_Gid = gid;
107  return 0;
[5e9b32b]108}
109
110/*PAGE
111 *
112 *  4.2.3 Get Supplementary IDs, P1003.1b-1993, p. 86
113 */
114
115int getgroups(
116  int    gidsetsize,
117  gid_t  grouplist[]
118)
119{
[c48e0ee]120  return 0;  /* no supplemental group ids */
[5e9b32b]121}
122
123/*PAGE
124 *
125 *  4.2.4 Get User Name, P1003.1b-1993, p. 87
126 *
127 *  NOTE:  P1003.1c/D10, p. 49 adds getlogin_r().
128 */
129
[c48e0ee]130static char _POSIX_types_Getlogin_buffer[ LOGIN_NAME_MAX ];
131
[5e9b32b]132char *getlogin( void )
133{
[c48e0ee]134  (void) getlogin_r( _POSIX_types_Getlogin_buffer, LOGIN_NAME_MAX );
135  return _POSIX_types_Getlogin_buffer;
[5e9b32b]136}
137
138/*PAGE
139 *
140 *  4.2.4 Get User Name, P1003.1b-1993, p. 87
141 *
142 *  NOTE:  P1003.1c/D10, p. 49 adds getlogin_r().
143 */
144
[613cff6]145int getlogin_r(
146  char   *name,
147  size_t  namesize
148)
[5e9b32b]149{
[c48e0ee]150  if ( namesize < LOGIN_NAME_MAX )
151    return ERANGE;
152
153  strcpy( name, "posixapp" );
154  return 0;
[5e9b32b]155}
156
157/*PAGE
158 *
159 *  4.3.1 Get Process Group IDs, P1003.1b-1993, p. 89
160 */
161
162pid_t getpgrp( void )
163{
[c48e0ee]164  /*
165   *  This always succeeds and returns the process group id.  For rtems,
166   *  this will always be the local node;
167   */
168
169  return _Objects_Local_node;
[5e9b32b]170}
171
172/*PAGE
173 *
174 *  4.3.2 Create Session and Set Process Group ID, P1003.1b-1993, p. 88
175 */
176
177pid_t setsid( void )
178{
[05ce4e09]179  set_errno_and_return_minus_one( ENOSYS );
[5e9b32b]180}
181
182/*PAGE
183 *
184 *  4.3.3 Set Process Group ID for Job Control, P1003.1b-1993, p. 89
185 */
186
187int setpgid(
188  pid_t  pid,
189  pid_t  pgid
190)
191{
[05ce4e09]192  set_errno_and_return_minus_one( ENOSYS );
[5e9b32b]193}
[2a98af84]194
195/*
196 * TEMPORARY
197 */
198
199#include <assert.h>
200
201int POSIX_MP_NOT_IMPLEMENTED()
202{
203  assert( 0 );
204  return 0;
205}
206
207int POSIX_BOTTOM_REACHED()
208{
209  assert( 0 );
210  return 0;
211}
212
213int POSIX_NOT_IMPLEMENTED()
214{
215  assert( 0 );
216  return 0;
217}
218
219/*
220 * END OF TEMPORARY
221 */
222
Note: See TracBrowser for help on using the repository browser.