| | 12 | |
| | 13 | A BeOS-compatible replacement for lseek() is: |
| | 14 | {{{ |
| | 15 | #include <config.h> |
| | 16 | |
| | 17 | /* Specification. */ |
| | 18 | #include <unistd.h> |
| | 19 | |
| | 20 | #include <stdlib.h> |
| | 21 | #include <sys/types.h> |
| | 22 | #include <sys/stat.h> |
| | 23 | #include <errno.h> |
| | 24 | |
| | 25 | #undef lseek |
| | 26 | |
| | 27 | off_t |
| | 28 | rpl_lseek (int fd, off_t offset, int whence) |
| | 29 | { |
| | 30 | int rc; |
| | 31 | struct stat st; |
| | 32 | if (fstat(fd, &st) < 0) |
| | 33 | { |
| | 34 | //fstat sets errno |
| | 35 | return -1; |
| | 36 | } |
| | 37 | if (S_ISFIFO(st.st_mode)) |
| | 38 | { |
| | 39 | errno = ESPIPE; |
| | 40 | return -1; |
| | 41 | } |
| | 42 | return lseek (fd, offset, whence);; |
| | 43 | } |
| | 44 | }}} |
| | 45 | |
| | 46 | This needs to be merged with in the m4/lseek.m4 script (I think). |
| | 47 | |
| | 48 | After replacing lseek with the above code, make check still reports 3 failed tests: |
| | 49 | |
| | 50 | {{{ |
| | 51 | ftell result is wrong after fseeko: 17. |
| | 52 | FAIL: test-fflush |
| | 53 | }}} |
| | 54 | I'm not sure whether the problem is with fseeko or ftell. |
| | 55 | |
| | 56 | {{{ |
| | 57 | FAIL: test-ftello.sh |
| | 58 | }}} |
| | 59 | ftell and ftello should return -1 for pipes. On BeOS, they don't. |
| | 60 | |
| | 61 | {{{ |
| | 62 | test-lseek.c:52: assertion failed |
| | 63 | Abort |
| | 64 | FAIL: test-lseek.sh |
| | 65 | }}} |
| | 66 | Haven't investigated this yet. |