Changeset dc87f3fd in mainline
- Timestamp:
- 2011-03-28T20:19:16Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- df147c7
- Parents:
- fd89cf9
- git-author:
- Vojtech Horky <> (2011-03-28 20:19:16)
- git-committer:
- Jiri Svoboda <jiri@…> (2011-03-28 20:19:16)
- Location:
- uspace/srv/devman
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
rfd89cf9 rdc87f3fd 266 266 } 267 267 268 if (read(fd, buf, len) <= 0) { 268 ssize_t read_bytes = safe_read(fd, buf, len); 269 if (read_bytes <= 0) { 269 270 printf(NAME ": unable to read file '%s'.\n", conf_path); 270 271 goto cleanup; 271 272 } 272 buf[ len] = 0;273 buf[read_bytes] = 0; 273 274 274 275 suc = parse_match_ids(buf, ids); -
uspace/srv/devman/util.c
rfd89cf9 rdc87f3fd 111 111 } 112 112 113 ssize_t safe_read(int fd, void *buffer, size_t size) 114 { 115 if (size == 0) { 116 return 0; 117 } 118 119 uint8_t *buf_ptr = (uint8_t *) buffer; 120 121 size_t total_read = 0; 122 while (total_read < size) { 123 ssize_t bytes_read = read(fd, buf_ptr, size - total_read); 124 if (bytes_read < 0) { 125 /* Error. */ 126 return bytes_read; 127 } else if (bytes_read == 0) { 128 /* Possibly end of file. */ 129 break; 130 } else { 131 /* Read at least something. */ 132 buf_ptr += bytes_read; 133 total_read += bytes_read; 134 } 135 } 136 137 return (ssize_t) total_read; 138 } 139 113 140 /** @} 114 141 */ -
uspace/srv/devman/util.h
rfd89cf9 rdc87f3fd 47 47 extern void replace_char(char *, char, char); 48 48 49 extern ssize_t safe_read(int, void *, size_t); 50 49 51 #endif 50 52
Note:
See TracChangeset
for help on using the changeset viewer.