Changeset 0d0b319 in mainline
- Timestamp:
- 2018-01-04T20:03:02Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3c7702c0
- Parents:
- 10de842
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 19:18:29)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 20:03:02)
- Files:
-
- 2 deleted
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
abi/include/abi/errno.h
r10de842 r0d0b319 1 1 /* Generated file. Edit errno.in instead. */ 2 2 #define EOK __errno_t( 0) 3 #define ENOENT __errno_t( -1)4 #define ENOMEM __errno_t( -2)5 #define ELIMIT __errno_t( -3)6 #define EREFUSED __errno_t( -4)7 #define EFORWARD __errno_t( -5)8 #define EPERM __errno_t( -6)9 #define EHANGUP __errno_t( -7)10 #define EPARTY __errno_t( -8)11 #define EEXIST __errno_t( -9)12 #define EBADMEM __errno_t( -10)13 #define ENOTSUP __errno_t( -11)14 #define EADDRNOTAVAIL __errno_t( -12)15 #define ETIMEOUT __errno_t( -13)16 #define EINVAL __errno_t( -14)17 #define EBUSY __errno_t( -15)18 #define EOVERFLOW __errno_t( -16)19 #define EINTR __errno_t( -17)20 #define EMFILE __errno_t( -18)21 #define ENAMETOOLONG __errno_t( -256)22 #define EISDIR __errno_t( -257)23 #define ENOTDIR __errno_t( -258)24 #define ENOSPC __errno_t( -259)25 #define ENOTEMPTY __errno_t( -261)26 #define EBADF __errno_t( -262)27 #define EDOM __errno_t( -263)28 #define ERANGE __errno_t( -264)29 #define EXDEV __errno_t( -265)30 #define EIO __errno_t( -266)31 #define EMLINK __errno_t( -267)32 #define ENXIO __errno_t( -268)33 #define ENOFS __errno_t( -269)34 #define EBADCHECKSUM __errno_t( -300)35 #define ESTALL __errno_t( -301)36 #define EEMPTY __errno_t( -302)37 #define ENAK __errno_t( -303)38 #define EAGAIN __errno_t( -11002)3 #define ENOENT __errno_t( 1) 4 #define ENOMEM __errno_t( 2) 5 #define ELIMIT __errno_t( 3) 6 #define EREFUSED __errno_t( 4) 7 #define EFORWARD __errno_t( 5) 8 #define EPERM __errno_t( 6) 9 #define EHANGUP __errno_t( 7) 10 #define EPARTY __errno_t( 8) 11 #define EEXIST __errno_t( 9) 12 #define EBADMEM __errno_t( 10) 13 #define ENOTSUP __errno_t( 11) 14 #define EADDRNOTAVAIL __errno_t( 12) 15 #define ETIMEOUT __errno_t( 13) 16 #define EINVAL __errno_t( 14) 17 #define EBUSY __errno_t( 15) 18 #define EOVERFLOW __errno_t( 16) 19 #define EINTR __errno_t( 17) 20 #define EMFILE __errno_t( 18) 21 #define ENAMETOOLONG __errno_t( 19) 22 #define EISDIR __errno_t( 20) 23 #define ENOTDIR __errno_t( 21) 24 #define ENOSPC __errno_t( 22) 25 #define ENOTEMPTY __errno_t( 23) 26 #define EBADF __errno_t( 24) 27 #define EDOM __errno_t( 25) 28 #define ERANGE __errno_t( 26) 29 #define EXDEV __errno_t( 27) 30 #define EIO __errno_t( 28) 31 #define EMLINK __errno_t( 29) 32 #define ENXIO __errno_t( 30) 33 #define ENOFS __errno_t( 31) 34 #define EBADCHECKSUM __errno_t( 32) 35 #define ESTALL __errno_t( 33) 36 #define EEMPTY __errno_t( 34) 37 #define ENAK __errno_t( 35) 38 #define EAGAIN __errno_t( 36) 39 39 40 #define HTTP_EMULTIPLE_HEADERS __errno_t( -20001) 41 #define HTTP_EMISSING_HEADER __errno_t( -20002) 42 #define HTTP_EPARSE __errno_t( -20003) 40 /* libhttp error codes. Defining them here is a temporary hack. */ 43 41 44 #define EXT4_ERR_BAD_DX_DIR __errno_t( -75000) 42 #define HTTP_EMULTIPLE_HEADERS __errno_t( 50) 43 #define HTTP_EMISSING_HEADER __errno_t( 51) 44 #define HTTP_EPARSE __errno_t( 52) 45 46 /* libext4 error codes. Same as above. */ 47 48 #define EXT4_ERR_BAD_DX_DIR __errno_t( 60) 49 50 51 /* POSIX error codes + whatever nonstandard names crop up in third-party 52 * software. These are not used in HelenOS code, but are defined here in 53 * order to avoid nasty hacks in libposix. 54 * 55 * If you decide to use one of these in native HelenOS code, 56 * move it up to the first group. 57 */ 58 59 #define E2BIG __errno_t( 101) 60 #define EACCES __errno_t( 102) 61 #define EADDRINUSE __errno_t( 103) 62 #define EAFNOSUPPORT __errno_t( 105) 63 #define EALREADY __errno_t( 107) 64 #define EBADMSG __errno_t( 109) 65 #define ECANCELED __errno_t( 111) 66 #define ECHILD __errno_t( 112) 67 #define ECONNABORTED __errno_t( 113) 68 #define ECONNREFUSED __errno_t( 114) 69 #define ECONNRESET __errno_t( 115) 70 #define EDEADLK __errno_t( 116) 71 #define EDESTADDRREQ __errno_t( 117) 72 #define EDQUOT __errno_t( 119) 73 #define EFAULT __errno_t( 121) 74 #define EFBIG __errno_t( 122) 75 #define EHOSTUNREACH __errno_t( 123) 76 #define EIDRM __errno_t( 124) 77 #define EILSEQ __errno_t( 125) 78 #define EINPROGRESS __errno_t( 126) 79 #define EISCONN __errno_t( 130) 80 #define ELOOP __errno_t( 132) 81 #define EMSGSIZE __errno_t( 135) 82 #define EMULTIHOP __errno_t( 136) 83 #define ENETDOWN __errno_t( 138) 84 #define ENETRESET __errno_t( 139) 85 #define ENETUNREACH __errno_t( 140) 86 #define ENFILE __errno_t( 141) 87 #define ENOBUFS __errno_t( 142) 88 #define ENODATA __errno_t( 143) 89 #define ENODEV __errno_t( 144) 90 #define ENOEXEC __errno_t( 146) 91 #define ENOLCK __errno_t( 147) 92 #define ENOLINK __errno_t( 148) 93 #define ENOMSG __errno_t( 150) 94 #define ENOPROTOOPT __errno_t( 151) 95 #define ENOSR __errno_t( 153) 96 #define ENOSTR __errno_t( 154) 97 #define ENOSYS __errno_t( 155) 98 #define ENOTCONN __errno_t( 156) 99 #define ENOTRECOVERABLE __errno_t( 159) 100 #define ENOTSOCK __errno_t( 160) 101 #define ENOTTY __errno_t( 162) 102 #define EOPNOTSUPP __errno_t( 164) 103 #define EOWNERDEAD __errno_t( 166) 104 #define EPIPE __errno_t( 168) 105 #define EPROTO __errno_t( 169) 106 #define EPROTONOSUPPORT __errno_t( 170) 107 #define EPROTOTYPE __errno_t( 171) 108 #define EROFS __errno_t( 173) 109 #define ESPIPE __errno_t( 174) 110 #define ESRCH __errno_t( 175) 111 #define ESTALE __errno_t( 176) 112 #define ETIME __errno_t( 177) 113 #define ETIMEDOUT __errno_t( 178) 114 #define ETXTBSY __errno_t( 179) 115 #define EWOULDBLOCK __errno_t( 180) -
abi/include/abi/errno.in
r10de842 r0d0b319 1 1 __errno_entry(EOK , 0, "No error") 2 __errno_entry(ENOENT , -1, "No such entry")3 __errno_entry(ENOMEM , -2, "Not enough memory")4 __errno_entry(ELIMIT , -3, "Limit exceeded")5 __errno_entry(EREFUSED , -4, "Connection refused")6 __errno_entry(EFORWARD , -5, "Forwarding error")7 __errno_entry(EPERM , -6, "Permission denied")8 __errno_entry(EHANGUP , -7, "Answerbox closed connection")9 __errno_entry(EPARTY , -8, "Other party encountered an error")10 __errno_entry(EEXIST , -9, "Entry already exists")11 __errno_entry(EBADMEM , -10, "Bad memory pointer")12 __errno_entry(ENOTSUP , -11, "Operation not supported")13 __errno_entry(EADDRNOTAVAIL , -12, "Address not available")14 __errno_entry(ETIMEOUT , -13, "Timeout expired")15 __errno_entry(EINVAL , -14, "Invalid value")16 __errno_entry(EBUSY , -15, "Resource is busy")17 __errno_entry(EOVERFLOW , -16, "Result does not fit its size")18 __errno_entry(EINTR , -17, "Operation interrupted")19 __errno_entry(EMFILE , -18, "Too many open files")20 __errno_entry(ENAMETOOLONG , -256, "Name is too long")21 __errno_entry(EISDIR , -257, "Entry is a directory")22 __errno_entry(ENOTDIR , -258, "Entry is not a directory")23 __errno_entry(ENOSPC , -259, "No space left")24 __errno_entry(ENOTEMPTY , -261, "Directory is not empty")25 __errno_entry(EBADF , -262, "Bad object handle")26 __errno_entry(EDOM , -263, "Domain error")27 __errno_entry(ERANGE , -264, "Value out of range")28 __errno_entry(EXDEV , -265, "Prohibited cross-device link")29 __errno_entry(EIO , -266, "Input/output error")30 __errno_entry(EMLINK , -267, "Too many links")31 __errno_entry(ENXIO , -268, "Device or address does not exist")32 __errno_entry(ENOFS , -269, "No such file system type")33 __errno_entry(EBADCHECKSUM , -300, "Bad checksum")34 __errno_entry(ESTALL , -301, "USB: Operation stalled")35 __errno_entry(EEMPTY , -302, "Resource is empty")36 __errno_entry(ENAK , -303, "Negative acknowledgement")37 __errno_entry(EAGAIN , -11002, "Operation could not proceed, try again")2 __errno_entry(ENOENT , 1, "No such entry") 3 __errno_entry(ENOMEM , 2, "Not enough memory") 4 __errno_entry(ELIMIT , 3, "Limit exceeded") 5 __errno_entry(EREFUSED , 4, "Connection refused") 6 __errno_entry(EFORWARD , 5, "Forwarding error") 7 __errno_entry(EPERM , 6, "Permission denied") 8 __errno_entry(EHANGUP , 7, "Answerbox closed connection") 9 __errno_entry(EPARTY , 8, "Other party encountered an error") 10 __errno_entry(EEXIST , 9, "Entry already exists") 11 __errno_entry(EBADMEM , 10, "Bad memory pointer") 12 __errno_entry(ENOTSUP , 11, "Operation not supported") 13 __errno_entry(EADDRNOTAVAIL , 12, "Address not available") 14 __errno_entry(ETIMEOUT , 13, "Timeout expired") 15 __errno_entry(EINVAL , 14, "Invalid value") 16 __errno_entry(EBUSY , 15, "Resource is busy") 17 __errno_entry(EOVERFLOW , 16, "Result does not fit its size") 18 __errno_entry(EINTR , 17, "Operation interrupted") 19 __errno_entry(EMFILE , 18, "Too many open files") 20 __errno_entry(ENAMETOOLONG , 19, "Name is too long") 21 __errno_entry(EISDIR , 20, "Entry is a directory") 22 __errno_entry(ENOTDIR , 21, "Entry is not a directory") 23 __errno_entry(ENOSPC , 22, "No space left") 24 __errno_entry(ENOTEMPTY , 23, "Directory is not empty") 25 __errno_entry(EBADF , 24, "Bad object handle") 26 __errno_entry(EDOM , 25, "Mathematics argument out of domain of function") 27 __errno_entry(ERANGE , 26, "Value out of range") 28 __errno_entry(EXDEV , 27, "Prohibited cross-device link") 29 __errno_entry(EIO , 28, "Input/output error") 30 __errno_entry(EMLINK , 29, "Too many links") 31 __errno_entry(ENXIO , 30, "Device or address does not exist") 32 __errno_entry(ENOFS , 31, "No such file system type") 33 __errno_entry(EBADCHECKSUM , 32, "Bad checksum") 34 __errno_entry(ESTALL , 33, "USB: Operation stalled") 35 __errno_entry(EEMPTY , 34, "Resource is empty") 36 __errno_entry(ENAK , 35, "Negative acknowledgement") 37 __errno_entry(EAGAIN , 36, "Operation could not proceed, try again") 38 38 39 __errno_entry(HTTP_EMULTIPLE_HEADERS , -20001, "HTTP: Multiple headers") // libhttp error codes. Defining them here is a temporary hack. 40 __errno_entry(HTTP_EMISSING_HEADER , -20002, "HTTP: Missing header") 41 __errno_entry(HTTP_EPARSE , -20003, "HTTP: Parse error") 39 /* libhttp error codes. Defining them here is a temporary hack. */ 42 40 43 __errno_entry(EXT4_ERR_BAD_DX_DIR , -75000, "EXT4: Filesystem corrupted") // libext4 41 __errno_entry(HTTP_EMULTIPLE_HEADERS , 50, "HTTP: Multiple headers") 42 __errno_entry(HTTP_EMISSING_HEADER , 51, "HTTP: Missing header") 43 __errno_entry(HTTP_EPARSE , 52, "HTTP: Parse error") 44 45 /* libext4 error codes. Same as above. */ 46 47 __errno_entry(EXT4_ERR_BAD_DX_DIR , 60, "EXT4: Filesystem corrupted") 48 49 50 /* POSIX error codes + whatever nonstandard names crop up in third-party 51 * software. These are not used in HelenOS code, but are defined here in 52 * order to avoid nasty hacks in libposix. 53 * 54 * If you decide to use one of these in native HelenOS code, 55 * move it up to the first group. 56 */ 57 58 __errno_entry(E2BIG , 101, "Argument list too long") 59 __errno_entry(EACCES , 102, "Permission denied") 60 __errno_entry(EADDRINUSE , 103, "Address in use") 61 __errno_entry(EAFNOSUPPORT , 105, "Address family not supported") 62 __errno_entry(EALREADY , 107, "Connection already in progress") 63 __errno_entry(EBADMSG , 109, "Bad message") 64 __errno_entry(ECANCELED , 111, "Operation canceled") 65 __errno_entry(ECHILD , 112, "No child processes") 66 __errno_entry(ECONNABORTED , 113, "Connection aborted") 67 __errno_entry(ECONNREFUSED , 114, "Connection refused") 68 __errno_entry(ECONNRESET , 115, "Connection reset") 69 __errno_entry(EDEADLK , 116, "Resource deadlock would occur") 70 __errno_entry(EDESTADDRREQ , 117, "Destination address required") 71 __errno_entry(EDQUOT , 119, "Reserved") 72 __errno_entry(EFAULT , 121, "Bad address") 73 __errno_entry(EFBIG , 122, "File too large") 74 __errno_entry(EHOSTUNREACH , 123, "Host is unreachable") 75 __errno_entry(EIDRM , 124, "Identifier removed") 76 __errno_entry(EILSEQ , 125, "Illegal byte sequence") 77 __errno_entry(EINPROGRESS , 126, "Operation in progress") 78 __errno_entry(EISCONN , 130, "Socket is connected") 79 __errno_entry(ELOOP , 132, "Too many levels of symbolic links") 80 __errno_entry(EMSGSIZE , 135, "Message too large") 81 __errno_entry(EMULTIHOP , 136, "Reserved") 82 __errno_entry(ENETDOWN , 138, "Network is down") 83 __errno_entry(ENETRESET , 139, "Connection aborted by network") 84 __errno_entry(ENETUNREACH , 140, "Network unreachable") 85 __errno_entry(ENFILE , 141, "Too many files open in system") 86 __errno_entry(ENOBUFS , 142, "No buffer space available") 87 __errno_entry(ENODATA , 143, "No message is available on the STREAM head read queue") 88 __errno_entry(ENODEV , 144, "No such device") 89 __errno_entry(ENOEXEC , 146, "Executable file format error") 90 __errno_entry(ENOLCK , 147, "No locks available") 91 __errno_entry(ENOLINK , 148, "Reserved") 92 __errno_entry(ENOMSG , 150, "No message of the desired type") 93 __errno_entry(ENOPROTOOPT , 151, "Protocol not available") 94 __errno_entry(ENOSR , 153, "No STREAM resources.") 95 __errno_entry(ENOSTR , 154, "Not a STREAM") 96 __errno_entry(ENOSYS , 155, "Function not supported") 97 __errno_entry(ENOTCONN , 156, "The socket is not connected") 98 __errno_entry(ENOTRECOVERABLE , 159, "State not recoverable") 99 __errno_entry(ENOTSOCK , 160, "Not a socket") 100 __errno_entry(ENOTTY , 162, "Inappropriate I/O control operation") 101 __errno_entry(EOPNOTSUPP , 164, "Operation not supported") 102 __errno_entry(EOWNERDEAD , 166, "Previous owned died") 103 __errno_entry(EPIPE , 168, "Broken pipe") 104 __errno_entry(EPROTO , 169, "Protocol error") 105 __errno_entry(EPROTONOSUPPORT , 170, "Protocol not supported") 106 __errno_entry(EPROTOTYPE , 171, "Protocol wrong type for socket") 107 __errno_entry(EROFS , 173, "Read-only file system") 108 __errno_entry(ESPIPE , 174, "Invalid seek") 109 __errno_entry(ESRCH , 175, "No such process") 110 __errno_entry(ESTALE , 176, "Reserved") 111 __errno_entry(ETIME , 177, "Stream ioctl() timeout") 112 __errno_entry(ETIMEDOUT , 178, "Connection timed out") 113 __errno_entry(ETXTBSY , 179, "Text file busy") 114 __errno_entry(EWOULDBLOCK , 180, "Operation would block") -
uspace/lib/c/generic/vfs/vfs.c
r10de842 r0d0b319 566 566 return ENOENT; 567 567 } 568 569 // XXX: Workaround for GCC diagnostics. 570 *handle = -1; 568 571 569 572 int rc = vfs_walk(root, p, flags, handle); -
uspace/lib/posix/Makefile
r10de842 r0d0b319 63 63 source/ctype.c \ 64 64 source/dlfcn.c \ 65 source/errno.c \66 65 source/fcntl.c \ 67 66 source/fnmatch.c \ -
uspace/lib/posix/include/posix/stdlib.h
r10de842 r0d0b319 40 40 #define __POSIX_DEF__(x) x 41 41 #endif 42 43 #include "libc/stdlib.h" 42 44 43 45 #include "sys/types.h" -
uspace/lib/posix/source/fcntl.c
r10de842 r0d0b319 40 40 41 41 #include "libc/vfs/vfs.h" 42 #include "posix/errno.h" 42 43 #include <errno.h> 43 44 44 45 /** … … 103 104 int posix_open(const char *pathname, int posix_flags, ...) 104 105 { 105 int rc;106 106 posix_mode_t posix_mode = 0; 107 107 if (posix_flags & O_CREAT) { … … 136 136 137 137 int file; 138 rc = rcerrno(vfs_lookup, pathname, flags, &file); 139 if ( rc != EOK)138 139 if (failed(vfs_lookup(pathname, flags, &file))) 140 140 return -1; 141 141 142 rc = rcerrno(vfs_open, file, mode); 143 if (rc != EOK) { 142 if (failed(vfs_open(file, mode))) { 144 143 vfs_put(file); 145 144 return -1; … … 148 147 if (posix_flags & O_TRUNC) { 149 148 if (posix_flags & (O_RDWR | O_WRONLY)) { 150 rc = rcerrno(vfs_resize, file, 0); 151 if (rc != EOK) { 149 if (failed(vfs_resize(file, 0))) { 152 150 vfs_put(file); 153 151 return -1; -
uspace/lib/posix/source/internal/common.h
r10de842 r0d0b319 50 50 } while (0) 51 51 52 /* Convert negative errno to positive errno */ 53 #define negerrno(func, ...) ({ \ 54 int rc = func(__VA_ARGS__); \ 55 if (rc < 0) { \ 56 errno = -errno; \ 57 } \ 58 rc; \ 59 }) 60 61 /* Convert error code to positive errno and -1 return value */ 62 #define rcerrno(func, ...) ({ \ 63 int rc = func(__VA_ARGS__); \ 64 if (rc < 0) \ 65 errno = -rc; \ 66 rc; \ 67 }) 52 /* Checks if the value is a failing error code. 53 * If so, writes the error code to errno and returns true. 54 */ 55 static inline bool failed(int rc) { 56 if (rc != EOK) { 57 errno = rc; 58 return true; 59 } 60 return false; 61 } 68 62 69 63 extern aoff64_t posix_pos[MAX_OPEN_FILES]; -
uspace/lib/posix/source/locale.c
r10de842 r0d0b319 39 39 #include "posix/locale.h" 40 40 41 #include "posix/errno.h" 41 #include <errno.h> 42 42 43 #include "posix/limits.h" 43 44 #include "posix/string.h" -
uspace/lib/posix/source/pthread/keys.c
r10de842 r0d0b319 38 38 #include "posix/stdlib.h" 39 39 #include "posix/pthread.h" 40 #include "errno.h"40 #include <errno.h> 41 41 #include "../internal/common.h" 42 42 -
uspace/lib/posix/source/pthread/mutex.c
r10de842 r0d0b319 37 37 38 38 #include "posix/pthread.h" 39 #include "errno.h"39 #include <errno.h> 40 40 #include "../internal/common.h" 41 41 -
uspace/lib/posix/source/pwd.c
r10de842 r0d0b319 39 39 #include "posix/pwd.h" 40 40 #include "posix/string.h" 41 #include "posix/errno.h"41 #include <errno.h> 42 42 #include "posix/assert.h" 43 43 -
uspace/lib/posix/source/signal.c
r10de842 r0d0b319 41 41 #include "posix/stdlib.h" 42 42 #include "posix/string.h" 43 #include "posix/errno.h" 43 44 #include <errno.h> 44 45 45 46 #include "libc/fibril_synch.h" -
uspace/lib/posix/source/stdio.c
r10de842 r0d0b319 41 41 42 42 #include "posix/assert.h" 43 #include "posix/errno.h" 43 44 #include <errno.h> 45 44 46 #include "posix/stdlib.h" 45 47 #include "posix/string.h" … … 313 315 int posix_fflush(FILE *stream) 314 316 { 315 return negerrno(fflush,stream);317 return fflush(stream); 316 318 } 317 319 … … 344 346 const int fildes = *(int *) fd; 345 347 size_t wr; 346 int rc = vfs_write(fildes, &posix_pos[fildes], str, size, &wr); 347 if (rc != EOK) 348 return rc; 348 if (failed(vfs_write(fildes, &posix_pos[fildes], str, size, &wr))) 349 return -1; 349 350 return str_nlength(str, wr); 350 351 } … … 576 577 int posix_remove(const char *path) 577 578 { 578 if ( rcerrno(vfs_unlink_path, path) != EOK)579 if (failed(vfs_unlink_path(path))) 579 580 return -1; 580 581 else … … 591 592 int posix_rename(const char *old, const char *new) 592 593 { 593 int rc = rcerrno(vfs_rename_path, old, new); 594 if (rc != EOK) 594 if (failed(vfs_rename_path(old, new))) 595 595 return -1; 596 596 else … … 664 664 665 665 int orig_errno = errno; 666 errno = 0;666 errno = EOK; 667 667 /* Check if the file exists. */ 668 668 if (posix_access(result, F_OK) == -1) { -
uspace/lib/posix/source/stdio/scanf.c
r10de842 r0d0b319 37 37 38 38 #include "posix/assert.h" 39 #include "posix/errno.h" 39 40 #include <errno.h> 40 41 41 42 #include "posix/stdio.h" -
uspace/lib/posix/source/stdlib.c
r10de842 r0d0b319 40 40 #include "posix/stdlib.h" 41 41 42 #include "posix/errno.h" 42 #include <errno.h> 43 43 44 #include "posix/fcntl.h" 44 45 #include "posix/limits.h" -
uspace/lib/posix/source/stdlib/strtol.c
r10de842 r0d0b319 40 40 41 41 #include "posix/ctype.h" 42 #include "posix/errno.h" 42 43 #include <errno.h> 44 43 45 #include "posix/inttypes.h" 44 46 #include "posix/limits.h" -
uspace/lib/posix/source/stdlib/strtold.c
r10de842 r0d0b319 44 44 #include "posix/stdint.h" 45 45 #include "posix/strings.h" 46 #include "posix/errno.h" 46 47 #include <errno.h> 48 47 49 #include "posix/limits.h" 48 50 -
uspace/lib/posix/source/string.c
r10de842 r0d0b319 41 41 42 42 #include "posix/assert.h" 43 #include "posix/errno.h" 43 44 #include <errno.h> 45 44 46 #include "posix/limits.h" 45 47 #include "posix/stdlib.h" … … 615 617 char *posix_strerror(int errnum) 616 618 { 617 static const char *error_msgs[] = { 618 [E2BIG] = "[E2BIG] Argument list too long", 619 [EACCES] = "[EACCES] Permission denied", 620 [EADDRINUSE] = "[EADDRINUSE] Address in use", 621 [EADDRNOTAVAIL] = "[EADDRNOTAVAIL] Address not available", 622 [EAFNOSUPPORT] = "[EAFNOSUPPORT] Address family not supported", 623 [EAGAIN] = "[EAGAIN] Resource unavailable, try again", 624 [EALREADY] = "[EALREADY] Connection already in progress", 625 [EBADF] = "[EBADF] Bad file descriptor", 626 [EBADMSG] = "[EBADMSG] Bad message", 627 [EBUSY] = "[EBUSY] Device or resource busy", 628 [ECANCELED] = "[ECANCELED] Operation canceled", 629 [ECHILD] = "[ECHILD] No child processes", 630 [ECONNABORTED] = "[ECONNABORTED] Connection aborted", 631 [ECONNREFUSED] = "[ECONNREFUSED] Connection refused", 632 [ECONNRESET] = "[ECONNRESET] Connection reset", 633 [EDEADLK] = "[EDEADLK] Resource deadlock would occur", 634 [EDESTADDRREQ] = "[EDESTADDRREQ] Destination address required", 635 [EDOM] = "[EDOM] Mathematics argument out of domain of function", 636 [EDQUOT] = "[EDQUOT] Reserved", 637 [EEXIST] = "[EEXIST] File exists", 638 [EFAULT] = "[EFAULT] Bad address", 639 [EFBIG] = "[EFBIG] File too large", 640 [EHOSTUNREACH] = "[EHOSTUNREACH] Host is unreachable", 641 [EIDRM] = "[EIDRM] Identifier removed", 642 [EILSEQ] = "[EILSEQ] Illegal byte sequence", 643 [EINPROGRESS] = "[EINPROGRESS] Operation in progress", 644 [EINTR] = "[EINTR] Interrupted function", 645 [EINVAL] = "[EINVAL] Invalid argument", 646 [EIO] = "[EIO] I/O error", 647 [EISCONN] = "[EISCONN] Socket is connected", 648 [EISDIR] = "[EISDIR] Is a directory", 649 [ELOOP] = "[ELOOP] Too many levels of symbolic links", 650 [EMFILE] = "[EMFILE] File descriptor value too large", 651 [EMLINK] = "[EMLINK] Too many links", 652 [EMSGSIZE] = "[EMSGSIZE] Message too large", 653 [EMULTIHOP] = "[EMULTIHOP] Reserved", 654 [ENAMETOOLONG] = "[ENAMETOOLONG] Filename too long", 655 [ENETDOWN] = "[ENETDOWN] Network is down", 656 [ENETRESET] = "[ENETRESET] Connection aborted by network", 657 [ENETUNREACH] = "[ENETUNREACH] Network unreachable", 658 [ENFILE] = "[ENFILE] Too many files open in system", 659 [ENOBUFS] = "[ENOBUFS] No buffer space available", 660 [ENODATA] = "[ENODATA] No message is available on the STREAM head read queue", 661 [ENODEV] = "[ENODEV] No such device", 662 [ENOENT] = "[ENOENT] No such file or directory", 663 [ENOEXEC] = "[ENOEXEC] Executable file format error", 664 [ENOLCK] = "[ENOLCK] No locks available", 665 [ENOLINK] = "[ENOLINK] Reserved", 666 [ENOMEM] = "[ENOMEM] Not enough space", 667 [ENOMSG] = "[ENOMSG] No message of the desired type", 668 [ENOPROTOOPT] = "[ENOPROTOOPT] Protocol not available", 669 [ENOSPC] = "[ENOSPC] No space left on device", 670 [ENOSR] = "[ENOSR] No STREAM resources.", 671 [ENOSTR] = "[ENOSTR] Not a STREAM", 672 [ENOSYS] = "[ENOSYS] Function not supported", 673 [ENOTCONN] = "[ENOTCONN] The socket is not connected", 674 [ENOTDIR] = "[ENOTDIR] Not a directory", 675 [ENOTEMPTY] = "[ENOTEMPTY] Directory not empty", 676 [ENOTRECOVERABLE] = "[ENOTRECOVERABLE] State not recoverable", 677 [ENOTSOCK] = "[ENOTSOCK] Not a socket", 678 [ENOTSUP] = "[ENOTSUP] Not supported", 679 [ENOTTY] = "[ENOTTY] Inappropriate I/O control operation", 680 [ENXIO] = "[ENXIO] No such device or address", 681 [EOPNOTSUPP] = "[EOPNOTSUPP] Operation not supported", 682 [EOVERFLOW] = "[EOVERFLOW] Value too large to be stored in data type", 683 [EOWNERDEAD] = "[EOWNERDEAD] Previous owned died", 684 [EPERM] = "[EPERM] Operation not permitted", 685 [EPIPE] = "[EPIPE] Broken pipe", 686 [EPROTO] = "[EPROTO] Protocol error", 687 [EPROTONOSUPPORT] = "[EPROTONOSUPPORT] Protocol not supported", 688 [EPROTOTYPE] = "[EPROTOTYPE] Protocol wrong type for socket", 689 [ERANGE] = "[ERANGE] Result too large", 690 [EROFS] = "[EROFS] Read-only file system", 691 [ESPIPE] = "[ESPIPE] Invalid seek", 692 [ESRCH] = "[ESRCH] No such process", 693 [ESTALE] = "[ESTALE] Reserved", 694 [ETIME] = "[ETIME] Stream ioctl() timeout", 695 [ETIMEDOUT] = "[ETIMEDOUT] Connection timed out", 696 [ETXTBSY] = "[ETXTBSY] Text file busy", 697 [EWOULDBLOCK] = "[EWOULDBLOCK] Operation would block", 698 [EXDEV] = "[EXDEV] Cross-device link", 699 }; 700 701 return (char *) error_msgs[posix_abs(errnum)]; 619 // FIXME: move strerror() and strerror_r() to libc. 620 return (char *) str_error(errnum); 702 621 } 703 622 … … 722 641 } 723 642 724 return 0;643 return EOK; 725 644 } 726 645 -
uspace/lib/posix/source/sys/mman.c
r10de842 r0d0b319 59 59 int posix_munmap(void *start, size_t length) 60 60 { 61 return as_area_destroy(start); 61 int rc = as_area_destroy(start); 62 if (rc != EOK) { 63 errno = rc; 64 return -1; 65 } 66 return 0; 62 67 } 63 68 -
uspace/lib/posix/source/sys/stat.c
r10de842 r0d0b319 41 41 #include "libc/vfs/vfs.h" 42 42 43 #include "posix/errno.h"43 #include <errno.h> 44 44 #include "libc/mem.h" 45 45 … … 89 89 { 90 90 struct stat hst; 91 int rc = rcerrno(vfs_stat, fd, &hst); 92 if (rc < 0) 91 if (failed(vfs_stat(fd, &hst))) 93 92 return -1; 94 93 return stat_to_posix(st, &hst); … … 118 117 { 119 118 struct stat hst; 120 int rc = rcerrno(vfs_stat_path, path, &hst); 121 if (rc < 0) 119 if (failed(vfs_stat_path(path, &hst))) 122 120 return -1; 123 121 return stat_to_posix(st, &hst); … … 159 157 int posix_mkdir(const char *path, posix_mode_t mode) 160 158 { 161 int rc = rcerrno(vfs_link_path, path, KIND_DIRECTORY, NULL); 162 if (rc != EOK) 159 if (failed(vfs_link_path(path, KIND_DIRECTORY, NULL))) 163 160 return -1; 164 161 else -
uspace/lib/posix/source/sys/wait.c
r10de842 r0d0b319 42 42 #include "libc/task.h" 43 43 #include "posix/assert.h" 44 #include "posix/errno.h" 44 45 #include <errno.h> 46 45 47 #include "posix/limits.h" 46 48 #include "posix/signal.h" … … 100 102 int retval; 101 103 102 int rc = task_wait_task_id((task_id_t) pid, &texit, &retval); 103 104 if (rc < 0) { 104 if (failed(task_wait_task_id((task_id_t) pid, &texit, &retval))) { 105 105 /* Unable to retrieve status. */ 106 errno = -rc;107 106 return (posix_pid_t) -1; 108 107 } -
uspace/lib/posix/source/time.c
r10de842 r0d0b319 41 41 42 42 #include "posix/ctype.h" 43 #include "posix/errno.h" 43 44 #include <errno.h> 45 44 46 #include "posix/signal.h" 45 47 #include "posix/assert.h" … … 100 102 struct tm *restrict result) 101 103 { 102 int rc = time_utc2tm(*timer, result); 103 if (rc != EOK) { 104 errno = rc; 104 if (failed(time_utc2tm(*timer, result))) { 105 105 return NULL; 106 106 } … … 197 197 char *posix_ctime_r(const time_t *timer, char *buf) 198 198 { 199 int r = time_local2str(*timer, buf); 200 if (r != EOK) { 201 errno = r; 199 if (failed(time_local2str(*timer, buf))) { 202 200 return NULL; 203 201 } -
uspace/lib/posix/source/unistd.c
r10de842 r0d0b319 40 40 #include "posix/unistd.h" 41 41 42 #include "posix/errno.h" 42 #include <errno.h> 43 43 44 #include "posix/string.h" 44 45 #include "posix/fcntl.h" … … 52 53 #include <libarch/config.h> 53 54 55 // FIXME: replace with a hash table 54 56 aoff64_t posix_pos[MAX_OPEN_FILES]; 55 57 … … 126 128 char *posix_getcwd(char *buf, size_t size) 127 129 { 128 int rc = rcerrno(vfs_cwd_get, buf, size); 129 if (rc != EOK) 130 if (failed(vfs_cwd_get(buf, size))) 130 131 return NULL; 131 132 return buf; … … 139 140 int posix_chdir(const char *path) 140 141 { 141 int rc = rcerrno(vfs_cwd_set, path); 142 if (rc != EOK) 142 if (failed(vfs_cwd_set(path))) 143 143 return -1; 144 144 return 0; … … 196 196 { 197 197 posix_pos[fildes] = 0; 198 int rc = rcerrno(vfs_put, fildes); 199 if (rc != EOK) 198 if (failed(vfs_put(fildes))) 200 199 return -1; 201 200 else … … 214 213 { 215 214 size_t nread; 216 int rc; 217 218 rc = rcerrno(vfs_read, fildes, &posix_pos[fildes], buf, nbyte, &nread); 219 if (rc != EOK) 215 if (failed(vfs_read(fildes, &posix_pos[fildes], buf, nbyte, &nread))) 220 216 return -1; 221 217 return (ssize_t) nread; … … 233 229 { 234 230 size_t nwr; 235 int rc; 236 237 rc = rcerrno(vfs_write, fildes, &posix_pos[fildes], buf, nbyte, &nwr); 238 if (rc != EOK) 231 if (failed(vfs_write(fildes, &posix_pos[fildes], buf, nbyte, &nwr))) 239 232 return -1; 240 233 return nwr; … … 253 246 { 254 247 struct stat st; 255 int rc;256 248 257 249 switch (whence) { … … 263 255 break; 264 256 case SEEK_END: 265 rc = rcerrno(vfs_stat, fildes, &st); 266 if (rc != EOK) 257 if (failed(vfs_stat(fildes, &st))) 267 258 return -1; 268 259 posix_pos[fildes] = st.size + offset; … … 285 276 int posix_fsync(int fildes) 286 277 { 287 if ( rcerrno(vfs_sync, fildes) != EOK)278 if (failed(vfs_sync(fildes))) 288 279 return -1; 289 280 else … … 300 291 int posix_ftruncate(int fildes, posix_off_t length) 301 292 { 302 if ( rcerrno(vfs_resize, fildes, (aoff64_t) length) != EOK)293 if (failed(vfs_resize(fildes, (aoff64_t) length))) 303 294 return -1; 304 295 else … … 314 305 int posix_rmdir(const char *path) 315 306 { 316 if ( rcerrno(vfs_unlink_path, path) != EOK)307 if (failed(vfs_unlink_path(path))) 317 308 return -1; 318 309 else … … 328 319 int posix_unlink(const char *path) 329 320 { 330 if ( rcerrno(vfs_unlink_path, path) != EOK)321 if (failed(vfs_unlink_path(path))) 331 322 return -1; 332 323 else … … 356 347 { 357 348 int file; 358 int rc = vfs_clone(fildes, fildes2, false, &file); 359 if (rc != EOK) { 360 errno = rc < 0 ? -rc : rc; 349 if (failed(vfs_clone(fildes, fildes2, false, &file))) { 361 350 return -1; 362 351 } -
uspace/lib/posix/test/scanf.c
r10de842 r0d0b319 30 30 #define __POSIX_DEF__(x) posix_##x 31 31 32 #include "posix/errno.h" 32 #include <errno.h> 33 33 34 #include "posix/stdio.h" 34 35
Note:
See TracChangeset
for help on using the changeset viewer.