| 1 | #include <wasi/api.h> |
| 2 | #include <errno.h> |
| 3 | |
| 4 | off_t __wasilibc_tell(int fildes) { |
| 5 | __wasi_filesize_t offset; |
| 6 | __wasi_errno_t error = __wasi_fd_tell(fildes, &offset); |
| 7 | if (error != 0) { |
| 8 | // lseek returns ESPIPE on when called on a pipe, socket, or fifo, |
| 9 | // which on WASI would translate into ENOTCAPABLE. |
| 10 | errno = error == ENOTCAPABLE ? ESPIPE : error; |
| 11 | return -1; |
| 12 | } |
| 13 | return offset; |
| 14 | } |