diff options
author | Ralf Corsepius <ralf.corsepius@rtems.org> | 2003-08-18 07:31:32 +0000 |
---|---|---|
committer | Ralf Corsepius <ralf.corsepius@rtems.org> | 2003-08-18 07:31:32 +0000 |
commit | c5f52e9725745b0cd81e3b2b4881fc2360f830ec (patch) | |
tree | 1db87a69b5067c144aa105f34199b133a15fcfa9 /cpukit/libcsupport/src | |
parent | 2003-08-18 Ralf Corsepius <corsepiu@faw.uni-ulm.de> (diff) | |
download | rtems-c5f52e9725745b0cd81e3b2b4881fc2360f830ec.tar.bz2 |
2003-08-18 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
PR 449/rtems:
* src/getegid.c: New (Copied from ../posix/src).
* src/geteuid.c: New (Copied from ../posix/src).
* src/getgid.c: New (Copied from ../posix/src).
* src/getgroups.c: New (Copied from ../posix/src).
* src/getlogin.c: New (Copied from ../posix/src).
* src/getpgrp.c: New (Copied from ../posix/src).
* src/getpid.c: New (Copied from ../posix/src).
* src/getppid.c: New (Copied from ../posix/src).
* src/getuid.c: New (Copied from ../posix/src).
* src/setpgid.c: New (Copied from ../posix/src).
* src/setsid.c: New (Copied from ../posix/src).
* src/no_posix: Remove getpid and _getpid_r.
* Makefile.am: Reflect changes above.
Diffstat (limited to 'cpukit/libcsupport/src')
-rw-r--r-- | cpukit/libcsupport/src/getegid.c | 33 | ||||
-rw-r--r-- | cpukit/libcsupport/src/geteuid.c | 33 | ||||
-rw-r--r-- | cpukit/libcsupport/src/getgid.c | 47 | ||||
-rw-r--r-- | cpukit/libcsupport/src/getgroups.c | 30 | ||||
-rw-r--r-- | cpukit/libcsupport/src/getlogin.c | 64 | ||||
-rw-r--r-- | cpukit/libcsupport/src/getpgrp.c | 31 | ||||
-rw-r--r-- | cpukit/libcsupport/src/getpid.c | 45 | ||||
-rw-r--r-- | cpukit/libcsupport/src/getppid.c | 29 | ||||
-rw-r--r-- | cpukit/libcsupport/src/getuid.c | 47 | ||||
-rw-r--r-- | cpukit/libcsupport/src/list | 11 | ||||
-rw-r--r-- | cpukit/libcsupport/src/no_posix.c | 21 | ||||
-rw-r--r-- | cpukit/libcsupport/src/setpgid.c | 29 | ||||
-rw-r--r-- | cpukit/libcsupport/src/setsid.c | 28 |
13 files changed, 427 insertions, 21 deletions
diff --git a/cpukit/libcsupport/src/getegid.c b/cpukit/libcsupport/src/getegid.c new file mode 100644 index 0000000000..09bb75aeef --- /dev/null +++ b/cpukit/libcsupport/src/getegid.c @@ -0,0 +1,33 @@ +/* + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <limits.h> +#include <string.h> +#include <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/object.h> +#include <rtems/seterr.h> +#include <rtems/userenv.h> + +/* + * MACRO in userenv.h +gid_t _POSIX_types_Egid = 0; +*/ + +/*PAGE + * + * 4.2.1 Get Real User, Effective User, Ral Group, and Effective Group IDs, + * P1003.1b-1993, p. 84 + */ + +gid_t getegid( void ) +{ + return _POSIX_types_Egid; +} + diff --git a/cpukit/libcsupport/src/geteuid.c b/cpukit/libcsupport/src/geteuid.c new file mode 100644 index 0000000000..9374999683 --- /dev/null +++ b/cpukit/libcsupport/src/geteuid.c @@ -0,0 +1,33 @@ +/* + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <limits.h> +#include <string.h> +#include <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/object.h> +#include <rtems/seterr.h> + +#include <rtems/userenv.h> + +/* + * MACRO in userenv.h +uid_t _POSIX_types_Euid = 0; +*/ + +/*PAGE + * + * 4.2.1 Get Real User, Effective User, Ral Group, and Effective Group IDs, + * P1003.1b-1993, p. 84 + */ + +uid_t geteuid( void ) +{ + return _POSIX_types_Euid; +} diff --git a/cpukit/libcsupport/src/getgid.c b/cpukit/libcsupport/src/getgid.c new file mode 100644 index 0000000000..f104a6a039 --- /dev/null +++ b/cpukit/libcsupport/src/getgid.c @@ -0,0 +1,47 @@ +/* + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <limits.h> +#include <string.h> +#include <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/object.h> +#include <rtems/seterr.h> + +#include <rtems/userenv.h> + +/* + * MACRO in userenv.h + * +gid_t _POSIX_types_Gid = 0; +*/ + +/*PAGE + * + * 4.2.1 Get Real User, Effective User, Ral Group, and Effective Group IDs, + * P1003.1b-1993, p. 84 + */ + +gid_t getgid( void ) +{ + return _POSIX_types_Gid; +} + +/*PAGE + * + * 4.2.2 Set User and Group IDs, P1003.1b-1993, p. 84 + */ + +int setgid( + gid_t gid +) +{ + _POSIX_types_Gid = gid; + return 0; +} diff --git a/cpukit/libcsupport/src/getgroups.c b/cpukit/libcsupport/src/getgroups.c new file mode 100644 index 0000000000..b46cc6163a --- /dev/null +++ b/cpukit/libcsupport/src/getgroups.c @@ -0,0 +1,30 @@ +/* + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <limits.h> +#include <errno.h> +#include <string.h> +#include <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/object.h> +#include <rtems/seterr.h> + +/*PAGE + * + * 4.2.3 Get Supplementary IDs, P1003.1b-1993, p. 86 + */ + +int getgroups( + int gidsetsize, + gid_t grouplist[] +) +{ + return 0; /* no supplemental group ids */ +} + diff --git a/cpukit/libcsupport/src/getlogin.c b/cpukit/libcsupport/src/getlogin.c new file mode 100644 index 0000000000..64ee0b6d02 --- /dev/null +++ b/cpukit/libcsupport/src/getlogin.c @@ -0,0 +1,64 @@ +/* + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <limits.h> +#include <string.h> +#include <sys/types.h> +#include <errno.h> + +#include <rtems/system.h> +#include <rtems/score/object.h> +#include <rtems/seterr.h> +#include <rtems/userenv.h> + +#include <unistd.h> +#include <pwd.h> + +/*PAGE + * + * 4.2.4 Get User Name, P1003.1b-1993, p. 87 + * + * NOTE: P1003.1c/D10, p. 49 adds getlogin_r(). + */ + +/* + * MACRO in userenv.h + * +static char _POSIX_types_Getlogin_buffer[ LOGIN_NAME_MAX ]; +*/ + +char *getlogin( void ) +{ + (void) getlogin_r( _POSIX_types_Getlogin_buffer, LOGIN_NAME_MAX ); + return _POSIX_types_Getlogin_buffer; +} + +/*PAGE + * + * 4.2.4 Get User Name, P1003.1b-1993, p. 87 + * + * NOTE: P1003.1c/D10, p. 49 adds getlogin_r(). + */ + +int getlogin_r( + char *name, + size_t namesize +) +{ + struct passwd *pw; + if ( namesize < LOGIN_NAME_MAX ) + return ERANGE; + + pw=getpwuid(getuid()); + if (!pw) { + strcpy(name,""); + } else { + strncpy(name,pw->pw_name,LOGIN_NAME_MAX); + }; + return 0; +} diff --git a/cpukit/libcsupport/src/getpgrp.c b/cpukit/libcsupport/src/getpgrp.c new file mode 100644 index 0000000000..0904d23883 --- /dev/null +++ b/cpukit/libcsupport/src/getpgrp.c @@ -0,0 +1,31 @@ +/* + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <limits.h> +#include <errno.h> +#include <string.h> +#include <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/object.h> +#include <rtems/seterr.h> + +/*PAGE + * + * 4.3.1 Get Process Group IDs, P1003.1b-1993, p. 89 + */ + +pid_t getpgrp( void ) +{ + /* + * This always succeeds and returns the process group id. For rtems, + * this will always be the local node; + */ + + return _Objects_Local_node; +} diff --git a/cpukit/libcsupport/src/getpid.c b/cpukit/libcsupport/src/getpid.c new file mode 100644 index 0000000000..5442b6468d --- /dev/null +++ b/cpukit/libcsupport/src/getpid.c @@ -0,0 +1,45 @@ +/* + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <limits.h> +#include <errno.h> +#include <string.h> +#include <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/object.h> +#include <rtems/seterr.h> + +/*PAGE + * + * 4.1.1 Get Process and Parent Process IDs, P1003.1b-1993, p. 83 + */ + +pid_t getpid( void ) +{ + return _Objects_Local_node; +} + +/* + * _getpid_r + * + * This is the Newlib dependent reentrant version of getpid(). + */ + +#if defined(RTEMS_NEWLIB) + +#include <reent.h> + +pid_t _getpid_r( + struct _reent *ptr +) +{ + return getpid(); +} +#endif + diff --git a/cpukit/libcsupport/src/getppid.c b/cpukit/libcsupport/src/getppid.c new file mode 100644 index 0000000000..f8a2f7bbf1 --- /dev/null +++ b/cpukit/libcsupport/src/getppid.c @@ -0,0 +1,29 @@ +/* + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <limits.h> +#include <errno.h> +#include <string.h> +#include <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/object.h> +#include <rtems/seterr.h> + +pid_t _POSIX_types_Ppid = 0; + +/*PAGE + * + * 4.1.1 Get Process and Parent Process IDs, P1003.1b-1993, p. 83 + */ + +pid_t getppid( void ) +{ + return _POSIX_types_Ppid; +} + diff --git a/cpukit/libcsupport/src/getuid.c b/cpukit/libcsupport/src/getuid.c new file mode 100644 index 0000000000..09cc25e7c1 --- /dev/null +++ b/cpukit/libcsupport/src/getuid.c @@ -0,0 +1,47 @@ +/* + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <limits.h> +#include <string.h> +#include <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/object.h> +#include <rtems/seterr.h> + +#include <rtems/userenv.h> + +/* + * MACRO in userenv.h + * +uid_t _POSIX_types_Uid = 0; +*/ + +/*PAGE + * + * 4.2.1 Get Real User, Effective User, Ral Group, and Effective Group IDs, + * P1003.1b-1993, p. 84 + */ + +uid_t getuid( void ) +{ + return _POSIX_types_Uid; +} + +/*PAGE + * + * 4.2.2 Set User and Group IDs, P1003.1b-1993, p. 84 + */ + +int setuid( + uid_t uid +) +{ + _POSIX_types_Uid = uid; + return 0; +} diff --git a/cpukit/libcsupport/src/list b/cpukit/libcsupport/src/list new file mode 100644 index 0000000000..ef16047df5 --- /dev/null +++ b/cpukit/libcsupport/src/list @@ -0,0 +1,11 @@ +libcsupport/src/getegid.c +libcsupport/src/geteuid.c +libcsupport/src/getgid.c +libcsupport/src/getgroups.c +libcsupport/src/getlogin.c +libcsupport/src/getpgrp.c +libcsupport/src/getpid.c +libcsupport/src/getppid.c +libcsupport/src/getuid.c +libcsupport/src/setpgid.c +libcsupport/src/setsid.c diff --git a/cpukit/libcsupport/src/no_posix.c b/cpukit/libcsupport/src/no_posix.c index fee2e96de0..857f6b23a0 100644 --- a/cpukit/libcsupport/src/no_posix.c +++ b/cpukit/libcsupport/src/no_posix.c @@ -2,8 +2,6 @@ * Marginal implementations of some POSIX API routines * to be used when POSIX is disabled. * - * + getpid - * + _getpid_r * + kill * + _kill_r * + __kill @@ -29,25 +27,6 @@ */ #if !defined(RTEMS_POSIX_API) -pid_t getpid(void) -{ - return 0; -} - -#if defined(RTEMS_NEWLIB) -#include <reent.h> - -pid_t _getpid_r( - struct _reent *ptr -) -{ - return getpid(); -} -#endif - -#endif - -#if !defined(RTEMS_POSIX_API) int kill( pid_t pid, int sig ) { return 0; diff --git a/cpukit/libcsupport/src/setpgid.c b/cpukit/libcsupport/src/setpgid.c new file mode 100644 index 0000000000..26786cc552 --- /dev/null +++ b/cpukit/libcsupport/src/setpgid.c @@ -0,0 +1,29 @@ +/* + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <limits.h> +#include <errno.h> +#include <string.h> +#include <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/object.h> +#include <rtems/seterr.h> + +/*PAGE + * + * 4.3.3 Set Process Group ID for Job Control, P1003.1b-1993, p. 89 + */ + +int setpgid( + pid_t pid, + pid_t pgid +) +{ + rtems_set_errno_and_return_minus_one( ENOSYS ); +} diff --git a/cpukit/libcsupport/src/setsid.c b/cpukit/libcsupport/src/setsid.c new file mode 100644 index 0000000000..81a60a798d --- /dev/null +++ b/cpukit/libcsupport/src/setsid.c @@ -0,0 +1,28 @@ +/* + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <limits.h> +#include <errno.h> +#include <string.h> +#include <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/object.h> +#include <rtems/seterr.h> + +/*PAGE + * + * 4.3.2 Create Session and Set Process Group ID, P1003.1b-1993, p. 88 + */ + +pid_t setsid( void ) +{ + rtems_set_errno_and_return_minus_one( EPERM ); +} + + |