Changeset 7f9df7b9 in mainline for uspace/lib/posix/src/unistd.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/unistd.c
re0f47f5 r7f9df7b9 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" … … 70 67 * @return Always 0 on HelenOS. 71 68 */ 72 unsigned int posix_sleep(unsigned int seconds)69 unsigned int sleep(unsigned int seconds) 73 70 { 74 71 return thread_sleep(seconds); … … 80 77 * @return User name (static) string or NULL if not found. 81 78 */ 82 char * posix_getlogin(void)79 char *getlogin(void) 83 80 { 84 81 /* There is currently no support for user accounts in HelenOS. */ … … 93 90 * @return Zero on success, error code otherwise. 94 91 */ 95 int posix_getlogin_r(char *name, size_t namesize)92 int getlogin_r(char *name, size_t namesize) 96 93 { 97 94 /* There is currently no support for user accounts in HelenOS. */ 98 95 if (namesize >= 5) { 99 posix_strcpy(name, (char *) "user");96 strcpy(name, (char *) "user"); 100 97 return 0; 101 98 } else { … … 111 108 * @return Boolean result of the test. 112 109 */ 113 int posix_isatty(int fd)110 int isatty(int fd) 114 111 { 115 112 // TODO … … 126 123 * @return Buffer pointer on success, NULL on failure. 127 124 */ 128 char * posix_getcwd(char *buf, size_t size)125 char *getcwd(char *buf, size_t size) 129 126 { 130 127 if (failed(vfs_cwd_get(buf, size))) … … 138 135 * @param path New working directory. 139 136 */ 140 int posix_chdir(const char *path)137 int chdir(const char *path) 141 138 { 142 139 if (failed(vfs_cwd_set(path))) … … 150 147 * @return Page size of the process. 151 148 */ 152 int posix_getpagesize(void)149 int getpagesize(void) 153 150 { 154 151 return PAGE_SIZE; … … 160 157 * @return Process ID. 161 158 */ 162 p osix_pid_t posix_getpid(void)159 pid_t getpid(void) 163 160 { 164 161 return task_get_id(); … … 170 167 * @return User ID. 171 168 */ 172 posix_uid_t posix_getuid(void)169 uid_t getuid(void) 173 170 { 174 171 /* There is currently no support for user accounts in HelenOS. */ … … 181 178 * @return Group ID. 182 179 */ 183 posix_gid_t posix_getgid(void)180 gid_t getgid(void) 184 181 { 185 182 /* There is currently no support for user accounts in HelenOS. */ … … 193 190 * @return 0 on success, -1 on error. 194 191 */ 195 int posix_close(int fildes)192 int close(int fildes) 196 193 { 197 194 posix_pos[fildes] = 0; … … 210 207 * @return Number of read bytes on success, -1 otherwise. 211 208 */ 212 ssize_t posix_read(int fildes, void *buf, size_t nbyte)209 ssize_t read(int fildes, void *buf, size_t nbyte) 213 210 { 214 211 size_t nread; … … 226 223 * @return Number of written bytes on success, -1 otherwise. 227 224 */ 228 ssize_t posix_write(int fildes, const void *buf, size_t nbyte)225 ssize_t write(int fildes, const void *buf, size_t nbyte) 229 226 { 230 227 size_t nwr; … … 243 240 * as measured in bytes from the beginning of the file, -1 otherwise. 244 241 */ 245 posix_off_t posix_lseek(int fildes, posix_off_t offset, int whence)242 off_t lseek(int fildes, off_t offset, int whence) 246 243 { 247 244 vfs_stat_t st; … … 274 271 * @return Zero on success, -1 otherwise. 275 272 */ 276 int posix_fsync(int fildes)273 int fsync(int fildes) 277 274 { 278 275 if (failed(vfs_sync(fildes))) … … 289 286 * @return Zero on success, -1 otherwise. 290 287 */ 291 int posix_ftruncate(int fildes, posix_off_t length)288 int ftruncate(int fildes, off_t length) 292 289 { 293 290 if (failed(vfs_resize(fildes, (aoff64_t) length))) … … 303 300 * @return Zero on success, -1 otherwise. 304 301 */ 305 int posix_rmdir(const char *path)302 int rmdir(const char *path) 306 303 { 307 304 if (failed(vfs_unlink_path(path))) … … 317 314 * @return Zero on success, -1 otherwise. 318 315 */ 319 int posix_unlink(const char *path)316 int unlink(const char *path) 320 317 { 321 318 if (failed(vfs_unlink_path(path))) … … 331 328 * @return On success, new file descriptor for the same file, otherwise -1. 332 329 */ 333 int posix_dup(int fildes)334 { 335 return posix_fcntl(fildes, F_DUPFD, 0);330 int dup(int fildes) 331 { 332 return fcntl(fildes, F_DUPFD, 0); 336 333 } 337 334 … … 344 341 * @return fildes2 on success, -1 otherwise. 345 342 */ 346 int posix_dup2(int fildes, int fildes2)343 int dup2(int fildes, int fildes2) 347 344 { 348 345 int file; … … 360 357 * @return Zero on success, -1 otherwise. 361 358 */ 362 int posix_access(const char *path, int amode)359 int access(const char *path, int amode) 363 360 { 364 361 if (amode == F_OK || (amode & (X_OK | W_OK | R_OK))) { … … 368 365 * Check file existence by attempting to open it. 369 366 */ 370 int fd = posix_open(path, O_RDONLY);367 int fd = open(path, O_RDONLY); 371 368 if (fd < 0) 372 369 return -1; 373 posix_close(fd);370 close(fd); 374 371 return 0; 375 372 } else { … … 386 383 * @return Variable value. 387 384 */ 388 long posix_sysconf(int name)385 long sysconf(int name) 389 386 { 390 387 long clk_tck = 0; … … 403 400 stats_physmem_t *mem_stats = stats_get_physmem(); 404 401 if (mem_stats) { 405 phys_pages = (long) (mem_stats->total / posix_getpagesize());406 avphys_pages = (long) (mem_stats->free / posix_getpagesize());402 phys_pages = (long) (mem_stats->total / getpagesize()); 403 avphys_pages = (long) (mem_stats->free / getpagesize()); 407 404 free(mem_stats); 408 405 mem_stats = 0; … … 415 412 return avphys_pages; 416 413 case _SC_PAGESIZE: 417 return posix_getpagesize();414 return getpagesize(); 418 415 case _SC_CLK_TCK: 419 416 return clk_tck; … … 430 427 * @return 431 428 */ 432 long p osix_pathconf(const char *path, int name)429 long pathconf(const char *path, int name) 433 430 { 434 431 // TODO: low priority, just a compile-time dependency of binutils … … 441 438 * @return 442 439 */ 443 p osix_pid_t posix_fork(void)440 pid_t fork(void) 444 441 { 445 442 // TODO: low priority, just a compile-time dependency of binutils … … 454 451 * @return 455 452 */ 456 int posix_execv(const char *path, char *const argv[])453 int execv(const char *path, char *const argv[]) 457 454 { 458 455 // TODO: low priority, just a compile-time dependency of binutils … … 467 464 * @return 468 465 */ 469 int posix_execvp(const char *file, char *const argv[])466 int execvp(const char *file, char *const argv[]) 470 467 { 471 468 // TODO: low priority, just a compile-time dependency of binutils … … 479 476 * @return 480 477 */ 481 int p osix_pipe(int fildes[2])478 int pipe(int fildes[2]) 482 479 { 483 480 // TODO: low priority, just a compile-time dependency of binutils … … 486 483 } 487 484 488 unsigned int posix_alarm(unsigned int seconds)485 unsigned int alarm(unsigned int seconds) 489 486 { 490 487 not_implemented();
Note:
See TracChangeset
for help on using the changeset viewer.