Changeset 2b3dd78 in mainline for uspace/lib/posix/src/unistd.c
- Timestamp:
- 2018-01-31T12:02:00Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5595841
- Parents:
- a0a9cc2 (diff), 14d789c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/src/unistd.c
ra0a9cc2 r2b3dd78 34 34 */ 35 35 36 #define LIBPOSIX_INTERNAL37 #define __POSIX_DEF__(x) posix_##x38 39 36 #include "internal/common.h" 40 37 #include "posix/unistd.h" … … 57 54 58 55 /* Array of environment variable strings (NAME=VALUE). */ 59 char **posix_environ = NULL; 60 char *posix_optarg; 56 char **environ = NULL; 61 57 62 58 /** … … 70 66 * @return Always 0 on HelenOS. 71 67 */ 72 unsigned int posix_sleep(unsigned int seconds)68 unsigned int sleep(unsigned int seconds) 73 69 { 74 70 return thread_sleep(seconds); … … 80 76 * @return User name (static) string or NULL if not found. 81 77 */ 82 char * posix_getlogin(void)78 char *getlogin(void) 83 79 { 84 80 /* There is currently no support for user accounts in HelenOS. */ … … 93 89 * @return Zero on success, error code otherwise. 94 90 */ 95 int posix_getlogin_r(char *name, size_t namesize)91 int getlogin_r(char *name, size_t namesize) 96 92 { 97 93 /* There is currently no support for user accounts in HelenOS. */ 98 94 if (namesize >= 5) { 99 posix_strcpy(name, (char *) "user");95 strcpy(name, (char *) "user"); 100 96 return 0; 101 97 } else { … … 111 107 * @return Boolean result of the test. 112 108 */ 113 int posix_isatty(int fd)109 int isatty(int fd) 114 110 { 115 111 // TODO … … 126 122 * @return Buffer pointer on success, NULL on failure. 127 123 */ 128 char * posix_getcwd(char *buf, size_t size)124 char *getcwd(char *buf, size_t size) 129 125 { 130 126 if (failed(vfs_cwd_get(buf, size))) … … 138 134 * @param path New working directory. 139 135 */ 140 int posix_chdir(const char *path)136 int chdir(const char *path) 141 137 { 142 138 if (failed(vfs_cwd_set(path))) … … 150 146 * @return Page size of the process. 151 147 */ 152 int posix_getpagesize(void)148 int getpagesize(void) 153 149 { 154 150 return PAGE_SIZE; … … 160 156 * @return Process ID. 161 157 */ 162 p osix_pid_t posix_getpid(void)158 pid_t getpid(void) 163 159 { 164 160 return task_get_id(); … … 170 166 * @return User ID. 171 167 */ 172 posix_uid_t posix_getuid(void)168 uid_t getuid(void) 173 169 { 174 170 /* There is currently no support for user accounts in HelenOS. */ … … 181 177 * @return Group ID. 182 178 */ 183 posix_gid_t posix_getgid(void)179 gid_t getgid(void) 184 180 { 185 181 /* There is currently no support for user accounts in HelenOS. */ … … 193 189 * @return 0 on success, -1 on error. 194 190 */ 195 int posix_close(int fildes)191 int close(int fildes) 196 192 { 197 193 posix_pos[fildes] = 0; … … 210 206 * @return Number of read bytes on success, -1 otherwise. 211 207 */ 212 ssize_t posix_read(int fildes, void *buf, size_t nbyte)208 ssize_t read(int fildes, void *buf, size_t nbyte) 213 209 { 214 210 size_t nread; … … 226 222 * @return Number of written bytes on success, -1 otherwise. 227 223 */ 228 ssize_t posix_write(int fildes, const void *buf, size_t nbyte)224 ssize_t write(int fildes, const void *buf, size_t nbyte) 229 225 { 230 226 size_t nwr; … … 243 239 * as measured in bytes from the beginning of the file, -1 otherwise. 244 240 */ 245 posix_off_t posix_lseek(int fildes, posix_off_t offset, int whence)246 { 247 struct stat st;241 off_t lseek(int fildes, off_t offset, int whence) 242 { 243 vfs_stat_t st; 248 244 249 245 switch (whence) { … … 274 270 * @return Zero on success, -1 otherwise. 275 271 */ 276 int posix_fsync(int fildes)272 int fsync(int fildes) 277 273 { 278 274 if (failed(vfs_sync(fildes))) … … 289 285 * @return Zero on success, -1 otherwise. 290 286 */ 291 int posix_ftruncate(int fildes, posix_off_t length)287 int ftruncate(int fildes, off_t length) 292 288 { 293 289 if (failed(vfs_resize(fildes, (aoff64_t) length))) … … 303 299 * @return Zero on success, -1 otherwise. 304 300 */ 305 int posix_rmdir(const char *path)301 int rmdir(const char *path) 306 302 { 307 303 if (failed(vfs_unlink_path(path))) … … 317 313 * @return Zero on success, -1 otherwise. 318 314 */ 319 int posix_unlink(const char *path)315 int unlink(const char *path) 320 316 { 321 317 if (failed(vfs_unlink_path(path))) … … 331 327 * @return On success, new file descriptor for the same file, otherwise -1. 332 328 */ 333 int posix_dup(int fildes)334 { 335 return posix_fcntl(fildes, F_DUPFD, 0);329 int dup(int fildes) 330 { 331 return fcntl(fildes, F_DUPFD, 0); 336 332 } 337 333 … … 344 340 * @return fildes2 on success, -1 otherwise. 345 341 */ 346 int posix_dup2(int fildes, int fildes2)342 int dup2(int fildes, int fildes2) 347 343 { 348 344 int file; … … 360 356 * @return Zero on success, -1 otherwise. 361 357 */ 362 int posix_access(const char *path, int amode)358 int access(const char *path, int amode) 363 359 { 364 360 if (amode == F_OK || (amode & (X_OK | W_OK | R_OK))) { … … 368 364 * Check file existence by attempting to open it. 369 365 */ 370 int fd = posix_open(path, O_RDONLY);366 int fd = open(path, O_RDONLY); 371 367 if (fd < 0) 372 368 return -1; 373 posix_close(fd);369 close(fd); 374 370 return 0; 375 371 } else { … … 386 382 * @return Variable value. 387 383 */ 388 long posix_sysconf(int name)384 long sysconf(int name) 389 385 { 390 386 long clk_tck = 0; … … 403 399 stats_physmem_t *mem_stats = stats_get_physmem(); 404 400 if (mem_stats) { 405 phys_pages = (long) (mem_stats->total / posix_getpagesize());406 avphys_pages = (long) (mem_stats->free / posix_getpagesize());401 phys_pages = (long) (mem_stats->total / getpagesize()); 402 avphys_pages = (long) (mem_stats->free / getpagesize()); 407 403 free(mem_stats); 408 404 mem_stats = 0; … … 415 411 return avphys_pages; 416 412 case _SC_PAGESIZE: 417 return posix_getpagesize();413 return getpagesize(); 418 414 case _SC_CLK_TCK: 419 415 return clk_tck; … … 430 426 * @return 431 427 */ 432 long p osix_pathconf(const char *path, int name)428 long pathconf(const char *path, int name) 433 429 { 434 430 // TODO: low priority, just a compile-time dependency of binutils … … 441 437 * @return 442 438 */ 443 p osix_pid_t posix_fork(void)439 pid_t fork(void) 444 440 { 445 441 // TODO: low priority, just a compile-time dependency of binutils … … 454 450 * @return 455 451 */ 456 int posix_execv(const char *path, char *const argv[])452 int execv(const char *path, char *const argv[]) 457 453 { 458 454 // TODO: low priority, just a compile-time dependency of binutils … … 467 463 * @return 468 464 */ 469 int posix_execvp(const char *file, char *const argv[])465 int execvp(const char *file, char *const argv[]) 470 466 { 471 467 // TODO: low priority, just a compile-time dependency of binutils … … 479 475 * @return 480 476 */ 481 int p osix_pipe(int fildes[2])477 int pipe(int fildes[2]) 482 478 { 483 479 // TODO: low priority, just a compile-time dependency of binutils … … 486 482 } 487 483 488 unsigned int posix_alarm(unsigned int seconds)484 unsigned int alarm(unsigned int seconds) 489 485 { 490 486 not_implemented();
Note:
See TracChangeset
for help on using the changeset viewer.