1 #include "stdio_impl.h"
2 #include <unistd.h>
3
4 #if 0
5 static off64_t __stdio_lseek64(int fd, int offsetHigh, int offsetLow, off64_t *result, int whence)
6 {
7 off64_t ret;
8 struct file *filep = NULL;
9 off64_t offset = ((off64_t)offsetHigh << 32) + (uint)offsetLow; /* 32: offsetHigh is high 32 bits */
10
11 /* Get the file structure corresponding to the file descriptor. */
12 ret = fs_getfilep(fd, &filep);
13 if (ret < 0) {
14 /* The errno value has already been set */
15 return (off64_t)-get_errno();
16 }
17
18 /* libc seekdir function should set the whence to SEEK_SET, so we can discard
19 * the whence argument here */
20 if (filep->f_oflags & O_DIRECTORY) {
21 /* defensive coding */
22 if (filep->f_dir == NULL) {
23 return (off64_t)-EINVAL;
24 }
25 if (offsetLow == 0) {
26 rewinddir(filep->f_dir);
27 } else {
28 seekdir(filep->f_dir, offsetLow);
29 }
30 ret = telldir(filep->f_dir);
31 if (ret < 0) {
32 return (off64_t)-get_errno();
33 }
34 goto out;
35 }
36
37 /* Then let file_seek do the real work */
38 ret = file_seek64(filep, offset, whence);
39 if (ret < 0) {
40 return (off64_t)-get_errno();
41 }
42
43 out:
44 *result = ret;
45
46 return 0;
47 }
48 #endif
__stdio_seek(FILE * f,off_t off,int whence)49 off_t __stdio_seek(FILE *f, off_t off, int whence)
50 {
51 off_t result = 0;
52 return lseek(f->fd, (unsigned int)off, whence) ? -1 : result;
53 }
54