Changeset 7f9df7b9 in mainline for uspace/lib/posix/src/pwd.c
- Timestamp:
- 2018-01-22T22:42:57Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7a08c70
- Parents:
- e0f47f5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/src/pwd.c
re0f47f5 r7f9df7b9 33 33 */ 34 34 35 #define LIBPOSIX_INTERNAL36 #define __POSIX_DEF__(x) posix_##x37 38 35 #include "libc/stdbool.h" 39 36 #include "posix/pwd.h" … … 45 42 46 43 /* dummy user account */ 47 static const struct p osix_passwd dummy_pwd = {44 static const struct passwd dummy_pwd = { 48 45 .pw_name = (char *) "user", 49 46 .pw_uid = 0, … … 62 59 * doesn't have user accounts, this always returns the same made-up entry. 63 60 */ 64 struct p osix_passwd *posix_getpwent(void)61 struct passwd *getpwent(void) 65 62 { 66 63 if (entry_read) { … … 69 66 70 67 entry_read = true; 71 return (struct p osix_passwd *) &dummy_pwd;68 return (struct passwd *) &dummy_pwd; 72 69 } 73 70 … … 75 72 * Rewind the user list. 76 73 */ 77 void posix_setpwent(void)74 void setpwent(void) 78 75 { 79 76 entry_read = false; … … 83 80 * Ends enumerating and releases all resources. (Noop) 84 81 */ 85 void posix_endpwent(void)82 void endpwent(void) 86 83 { 87 84 /* noop */ … … 94 91 * @return Either found entry or NULL if no such entry exists. 95 92 */ 96 struct p osix_passwd *posix_getpwnam(const char *name)93 struct passwd *getpwnam(const char *name) 97 94 { 98 95 assert(name != NULL); 99 96 100 if ( posix_strcmp(name, "user") != 0) {97 if (strcmp(name, "user") != 0) { 101 98 return NULL; 102 99 } 103 100 104 return (struct p osix_passwd *) &dummy_pwd;101 return (struct passwd *) &dummy_pwd; 105 102 } 106 103 … … 116 113 * non-zero error number if error occured. 117 114 */ 118 int posix_getpwnam_r(const char *name, struct posix_passwd *pwd,119 char *buffer, size_t bufsize, struct p osix_passwd **result)115 int getpwnam_r(const char *name, struct passwd *pwd, 116 char *buffer, size_t bufsize, struct passwd **result) 120 117 { 121 118 assert(name != NULL); … … 124 121 assert(result != NULL); 125 122 126 if ( posix_strcmp(name, "user") != 0) {123 if (strcmp(name, "user") != 0) { 127 124 *result = NULL; 128 125 return 0; 129 126 } 130 127 131 return posix_getpwuid_r(0, pwd, buffer, bufsize, result);128 return getpwuid_r(0, pwd, buffer, bufsize, result); 132 129 } 133 130 … … 138 135 * @return Either found entry or NULL if no such entry exists. 139 136 */ 140 struct p osix_passwd *posix_getpwuid(posix_uid_t uid)137 struct passwd *getpwuid(uid_t uid) 141 138 { 142 139 if (uid != 0) { … … 144 141 } 145 142 146 return (struct p osix_passwd *) &dummy_pwd;143 return (struct passwd *) &dummy_pwd; 147 144 } 148 145 … … 158 155 * non-zero error number if error occured. 159 156 */ 160 int posix_getpwuid_r(posix_uid_t uid, struct posix_passwd *pwd,161 char *buffer, size_t bufsize, struct p osix_passwd **result)157 int getpwuid_r(uid_t uid, struct passwd *pwd, 158 char *buffer, size_t bufsize, struct passwd **result) 162 159 { 163 160 assert(pwd != NULL); … … 184 181 pwd->pw_dir = (char *) bf + 5; 185 182 pwd->pw_shell = (char *) bf + 7; 186 *result = (struct p osix_passwd *) pwd;183 *result = (struct passwd *) pwd; 187 184 188 185 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.