Changeset da0fef6 in mainline for uspace/app/bithenge/file.c
- Timestamp:
- 2012-06-23T18:24:21Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 03b2b2c
- Parents:
- d5070ef
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bithenge/file.c
rd5070ef rda0fef6 39 39 #include <errno.h> 40 40 #include <fcntl.h> 41 #include <macros.h>42 41 #include <stdio.h> 43 42 #include <stdlib.h> 44 43 #include <sys/stat.h> 44 #include <sys/types.h> 45 #include <unistd.h> 45 46 #include "blob.h" 46 47 #include "file.h" 48 #include "os.h" 47 49 48 50 typedef struct { … … 76 78 if (offset > blob->size) 77 79 return ELIMIT; 78 *size = min(*size, blob->size - offset); 79 int rc = lseek(blob->fd, offset, SEEK_SET); 80 if (rc != EOK) 81 return rc; 82 return read(blob->fd, buffer, *size); 80 if (lseek(blob->fd, offset, SEEK_SET) < 0) 81 return errno; 82 83 ssize_t amount_read; 84 aoff64_t remaining_size = *size; 85 *size = 0; 86 do { 87 amount_read = read(blob->fd, buffer, remaining_size); 88 if (amount_read < 0) 89 return errno; 90 buffer += amount_read; 91 *size += amount_read; 92 remaining_size -= amount_read; 93 } while (remaining_size && amount_read); 94 return EOK; 83 95 } 84 96 … … 125 137 } 126 138 blob->fd = fd; 139 #ifdef __HELENOS__ 127 140 blob->size = stat.size; 141 #else 142 blob->size = stat.st_size; 143 #endif 128 144 blob->needs_close = needs_close; 129 145 *out = bithenge_blob_as_node(blob_from_file(blob));
Note:
See TracChangeset
for help on using the changeset viewer.