Changeset 58898d1d in mainline for uspace/lib/posix/source
- Timestamp:
- 2017-03-24T20:31:54Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8e9b2534
- Parents:
- c9e3692
- Location:
- uspace/lib/posix/source
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/source/internal/common.h
rc9e3692 r58898d1d 38 38 #include <stdio.h> 39 39 #include <stdlib.h> 40 #include <sys/types.h> 41 #include <vfs/vfs.h> 40 42 41 43 #define not_implemented() do { \ … … 57 59 }) 58 60 61 extern aoff64_t posix_pos[MAX_OPEN_FILES]; 62 59 63 #endif /* LIBPOSIX_COMMON_H_ */ 60 64 -
uspace/lib/posix/source/stdio.c
rc9e3692 r58898d1d 344 344 static int _dprintf_str_write(const char *str, size_t size, void *fd) 345 345 { 346 ssize_t wr = write(*(int *) fd, str, size); 346 const int fildes = *(int *) fd; 347 ssize_t wr = write(fildes, &posix_pos[fildes], str, size); 347 348 if (wr < 0) 348 349 return errno; … … 371 372 } 372 373 373 if (write(*(int *) fd, buf, sz) != (ssize_t) sz) { 374 const int fildes = *(int *) fd; 375 if (write(fildes, &posix_pos[fildes], buf, sz) != (ssize_t) sz) 374 376 break; 375 }376 377 377 378 chars++; -
uspace/lib/posix/source/unistd.c
rc9e3692 r58898d1d 47 47 #include "libc/stats.h" 48 48 #include "libc/malloc.h" 49 #include "libc/vfs/vfs.h" 50 #include "libc/sys/stat.h" 51 52 aoff64_t posix_pos[MAX_OPEN_FILES]; 49 53 50 54 /* Array of environment variable strings (NAME=VALUE). */ … … 175 179 int posix_close(int fildes) 176 180 { 181 posix_pos[fildes] = 0; 177 182 return negerrno(close, fildes); 178 183 } … … 188 193 ssize_t posix_read(int fildes, void *buf, size_t nbyte) 189 194 { 190 return negerrno(read, fildes, buf, nbyte);195 return negerrno(read, fildes, &posix_pos[fildes], buf, nbyte); 191 196 } 192 197 … … 201 206 ssize_t posix_write(int fildes, const void *buf, size_t nbyte) 202 207 { 203 return negerrno(write, fildes, buf, nbyte);208 return negerrno(write, fildes, &posix_pos[fildes], buf, nbyte); 204 209 } 205 210 … … 215 220 posix_off_t posix_lseek(int fildes, posix_off_t offset, int whence) 216 221 { 217 return negerrno(lseek, fildes, offset, whence); 222 struct stat st; 223 224 switch (whence) { 225 case SEEK_SET: 226 posix_pos[fildes] = offset; 227 break; 228 case SEEK_CUR: 229 posix_pos[fildes] += offset; 230 break; 231 case SEEK_END: 232 if (fstat(fildes, &st) != EOK) { 233 errno = -errno; 234 return -1; 235 } 236 posix_pos[fildes] = st.size + offset; 237 break; 238 } 239 return posix_pos[fildes]; 218 240 } 219 241
Note:
See TracChangeset
for help on using the changeset viewer.