Changeset ce04ea44 in mainline
- Timestamp:
- 2017-04-02T12:27:14Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d4067a7
- Parents:
- 163fc09
- Location:
- uspace
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cat/cat.c
r163fc09 rce04ea44 251 251 } 252 252 253 bytes = read(fd, &pos, buff + copied_bytes, bytes_to_read);253 bytes = vfs_read(fd, &pos, buff + copied_bytes, bytes_to_read); 254 254 copied_bytes = 0; 255 255 -
uspace/app/bdsh/cmds/modules/cmp/cmp.c
r163fc09 rce04ea44 94 94 ssize_t size; 95 95 do { 96 size = read(fd[i], &pos[i],96 size = vfs_read(fd[i], &pos[i], 97 97 buffer[i] + offset[i], 98 98 CMP_BUFLEN - offset[i]); 99 99 if (size < 0) { 100 rc = errno;100 rc = size; 101 101 printf("Error reading from %s\n", 102 102 fn[i]); -
uspace/app/bdsh/cmds/modules/cp/cp.c
r163fc09 rce04ea44 413 413 } 414 414 415 while ((bytes = read(fd1, &posr, buff, blen)) > 0) {416 if ((bytes = write(fd2, &posw, buff, bytes)) < 0)415 while ((bytes = vfs_read(fd1, &posr, buff, blen)) > 0) { 416 if ((bytes = vfs_write(fd2, &posw, buff, bytes)) < 0) 417 417 break; 418 418 copied += bytes; … … 420 420 421 421 if (bytes < 0) { 422 printf("\nError copying %s, (%d)\n", src, errno);422 printf("\nError copying %s, (%d)\n", src, bytes); 423 423 copied = bytes; 424 424 } -
uspace/app/bdsh/cmds/modules/mkfile/mkfile.c
r163fc09 rce04ea44 166 166 167 167 pos = file_size - 1; 168 rc2 = write(fd, &pos, &byte, sizeof(char));168 rc2 = vfs_write(fd, &pos, &byte, sizeof(char)); 169 169 if (rc2 < 0) { 170 170 vfs_put(fd); … … 183 183 while (total_written < file_size) { 184 184 to_write = min(file_size - total_written, BUFFER_SIZE); 185 rc = write(fd, &pos, buffer, to_write);185 rc = vfs_write(fd, &pos, buffer, to_write); 186 186 if (rc <= 0) { 187 187 printf("%s: Error writing file (%d).\n", cmdname, errno); -
uspace/app/sysinst/futil.c
r163fc09 rce04ea44 72 72 73 73 do { 74 nr = read(sf, &posr, buf, BUF_SIZE);74 nr = vfs_read(sf, &posr, buf, BUF_SIZE); 75 75 if (nr == 0) 76 76 break; … … 78 78 return EIO; 79 79 80 nw = write(df, &posw, buf, nr);80 nw = vfs_write(df, &posw, buf, nr); 81 81 if (nw <= 0) 82 82 return EIO; … … 178 178 } 179 179 180 nr = read(sf, (aoff64_t []) { 0 }, data, fsize);180 nr = vfs_read(sf, (aoff64_t []) { 0 }, data, fsize); 181 181 if (nr != (ssize_t)fsize) { 182 182 vfs_put(sf); -
uspace/app/taskdump/elf_core.c
r163fc09 rce04ea44 207 207 } 208 208 209 rc = write(fd, &pos, &elf_hdr, sizeof(elf_hdr));209 rc = vfs_write(fd, &pos, &elf_hdr, sizeof(elf_hdr)); 210 210 if (rc != sizeof(elf_hdr)) { 211 211 printf("Failed writing ELF header.\n"); … … 215 215 216 216 for (i = 0; i < n_ph; ++i) { 217 rc = write(fd, &pos, &p_hdr[i], sizeof(p_hdr[i]));217 rc = vfs_write(fd, &pos, &p_hdr[i], sizeof(p_hdr[i])); 218 218 if (rc != sizeof(p_hdr[i])) { 219 219 printf("Failed writing program header.\n"); … … 232 232 note.type = NT_PRSTATUS; 233 233 234 rc = write(fd, &pos, ¬e, sizeof(elf_note_t));234 rc = vfs_write(fd, &pos, ¬e, sizeof(elf_note_t)); 235 235 if (rc != sizeof(elf_note_t)) { 236 236 printf("Failed writing note header.\n"); … … 239 239 } 240 240 241 rc = write(fd, &pos, "CORE", note.namesz);241 rc = vfs_write(fd, &pos, "CORE", note.namesz); 242 242 if (rc != (ssize_t) note.namesz) { 243 243 printf("Failed writing note header.\n"); … … 248 248 pos = ALIGN_UP(pos, word_size); 249 249 250 rc = write(fd, &pos, &pr_status, sizeof(elf_prstatus_t));250 rc = vfs_write(fd, &pos, &pr_status, sizeof(elf_prstatus_t)); 251 251 if (rc != sizeof(elf_prstatus_t)) { 252 252 printf("Failed writing register data.\n"); … … 310 310 } 311 311 312 rc = write(fd, pos, buffer, to_copy);312 rc = vfs_write(fd, pos, buffer, to_copy); 313 313 if (rc != (ssize_t) to_copy) { 314 314 printf("Failed writing memory contents.\n"); -
uspace/app/taskdump/symtab.c
r163fc09 rce04ea44 88 88 } 89 89 90 rc = read(fd, &pos, &elf_hdr, sizeof(elf_header_t));90 rc = vfs_read(fd, &pos, &elf_hdr, sizeof(elf_header_t)); 91 91 if (rc != sizeof(elf_header_t)) { 92 92 printf("failed reading elf header\n"); … … 306 306 aoff64_t pos = elf_hdr->e_shoff + idx * sizeof(elf_section_header_t); 307 307 308 rc = read(fd, &pos, sec_hdr, sizeof(elf_section_header_t));308 rc = vfs_read(fd, &pos, sec_hdr, sizeof(elf_section_header_t)); 309 309 if (rc != sizeof(elf_section_header_t)) 310 310 return EIO; … … 335 335 } 336 336 337 rc = read(fd, &pos, *ptr, size);337 rc = vfs_read(fd, &pos, *ptr, size); 338 338 if (rc != (ssize_t) size) { 339 339 printf("failed reading chunk\n"); -
uspace/app/tester/mm/pager1.c
r163fc09 rce04ea44 53 53 (void) vfs_unlink_path(TEST_FILE); 54 54 55 if ( write(fd, (aoff64_t []) {0}, text, sizeof(text)) != sizeof(text)) {55 if (vfs_write(fd, (aoff64_t []) {0}, text, sizeof(text)) < 0) { 56 56 vfs_put(fd); 57 57 return NULL; -
uspace/app/tester/vfs/vfs1.c
r163fc09 rce04ea44 85 85 86 86 size_t size = sizeof(text); 87 ssize_t cnt = write(fd0, &pos, text, size);87 ssize_t cnt = vfs_write(fd0, &pos, text, size); 88 88 if (cnt < 0) 89 89 return "write() failed"; … … 94 94 char buf[BUF_SIZE]; 95 95 TPRINTF("read..\n"); 96 while ((cnt = read(fd0, &pos, buf, BUF_SIZE))) {96 while ((cnt = vfs_read(fd0, &pos, buf, BUF_SIZE))) { 97 97 TPRINTF("read returns %zd\n", cnt); 98 98 if (cnt < 0) -
uspace/app/viewer/viewer.c
r163fc09 rce04ea44 126 126 } 127 127 128 ssize_t rd = read(fd, (aoff64_t []) {0}, tga, stat.size);128 ssize_t rd = vfs_read(fd, (aoff64_t []) {0}, tga, stat.size); 129 129 if ((rd < 0) || (rd != (ssize_t) stat.size)) { 130 130 free(tga); -
uspace/app/websrv/websrv.c
r163fc09 rce04ea44 240 240 aoff64_t pos = 0; 241 241 while (true) { 242 ssize_t nr = read(fd, &pos, fbuf, BUFFER_SIZE);242 ssize_t nr = vfs_read(fd, &pos, fbuf, BUFFER_SIZE); 243 243 if (nr == 0) 244 244 break; -
uspace/drv/bus/isa/isa.c
r163fc09 rce04ea44 281 281 } 282 282 283 r = read(fd, (aoff64_t []) {0}, buf, len);283 r = vfs_read(fd, (aoff64_t []) {0}, buf, len); 284 284 if (r < 0) { 285 285 ddf_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path); -
uspace/lib/bithenge/src/file.c
r163fc09 rce04ea44 78 78 return ELIMIT; 79 79 80 ssize_t amount_read = read(blob->fd, &offset, buffer, *size);80 ssize_t amount_read = vfs_read(blob->fd, &offset, buffer, *size); 81 81 if (amount_read < 0) 82 82 return errno; -
uspace/lib/c/generic/elf/elf_mod.c
r163fc09 rce04ea44 138 138 int i, rc; 139 139 140 rc = read(elf->fd, &pos, header, sizeof(elf_header_t));140 rc = vfs_read(elf->fd, &pos, header, sizeof(elf_header_t)); 141 141 if (rc != sizeof(elf_header_t)) { 142 142 DPRINTF("Read error.\n"); … … 197 197 198 198 pos = header->e_phoff + i * sizeof(elf_segment_header_t); 199 rc = read(elf->fd, &pos, &segment_hdr,199 rc = vfs_read(elf->fd, &pos, &segment_hdr, 200 200 sizeof(elf_segment_header_t)); 201 201 if (rc != sizeof(elf_segment_header_t)) { … … 216 216 217 217 pos = header->e_shoff + i * sizeof(elf_section_header_t); 218 rc = read(elf->fd, &pos, §ion_hdr,218 rc = vfs_read(elf->fd, &pos, §ion_hdr, 219 219 sizeof(elf_section_header_t)); 220 220 if (rc != sizeof(elf_section_header_t)) { … … 387 387 */ 388 388 pos = entry->p_offset; 389 rc = read(elf->fd, &pos, seg_ptr, entry->p_filesz);389 rc = vfs_read(elf->fd, &pos, seg_ptr, entry->p_filesz); 390 390 if (rc < 0) { 391 391 DPRINTF("read error\n"); -
uspace/lib/c/generic/io/io.c
r163fc09 rce04ea44 434 434 return 0; 435 435 436 ssize_t rd = read(stream->fd, &stream->pos, buf, size * nmemb);436 ssize_t rd = vfs_read(stream->fd, &stream->pos, buf, size * nmemb); 437 437 if (rd < 0) { 438 /* errno was set by read() */438 errno = rd; 439 439 stream->error = true; 440 440 rd = 0; … … 472 472 } 473 473 } else { 474 wr = write(stream->fd, &stream->pos, buf, size * nmemb);474 wr = vfs_write(stream->fd, &stream->pos, buf, size * nmemb); 475 475 if (wr < 0) { 476 /* errno was set by write() */476 errno = wr; 477 477 stream->error = true; 478 478 wr = 0; … … 496 496 stream->buf_head = stream->buf_tail = stream->buf; 497 497 498 rc = read(stream->fd, &stream->pos, stream->buf, stream->buf_size);498 rc = vfs_read(stream->fd, &stream->pos, stream->buf, stream->buf_size); 499 499 if (rc < 0) { 500 /* errno was set by read() */500 errno = rc; 501 501 stream->error = true; 502 502 return; -
uspace/lib/c/generic/vfs/vfs.c
r163fc09 rce04ea44 395 395 * return success with zero bytes read. 396 396 * 397 * @param fil desFile descriptor397 * @param file File descriptor 398 398 * @param pos Position to read from 399 399 * @param buf Buffer … … 403 403 * @return EOK on success, non-zero error code on error. 404 404 */ 405 static int _read_short(int fildes, aoff64_t pos, void *buf, size_t nbyte,405 int vfs_read_short(int file, aoff64_t pos, void *buf, size_t nbyte, 406 406 ssize_t *nread) 407 407 { … … 415 415 async_exch_t *exch = vfs_exchange_begin(); 416 416 417 req = async_send_3(exch, VFS_IN_READ, fil des, LOWER32(pos),417 req = async_send_3(exch, VFS_IN_READ, file, LOWER32(pos), 418 418 UPPER32(pos), &answer); 419 419 rc = async_data_read_start(exch, (void *) buf, nbyte); … … 438 438 * may be lower, but greater than zero. 439 439 * 440 * @param fil desFile descriptor440 * @param file File descriptor 441 441 * @param pos Position to write to 442 442 * @param buf Buffer … … 446 446 * @return EOK on success, non-zero error code on error. 447 447 */ 448 static int _write_short(int fildes, aoff64_t pos, const void *buf, size_t nbyte,448 int vfs_write_short(int file, aoff64_t pos, const void *buf, size_t nbyte, 449 449 ssize_t *nwritten) 450 450 { … … 458 458 async_exch_t *exch = vfs_exchange_begin(); 459 459 460 req = async_send_3(exch, VFS_IN_WRITE, fil des, LOWER32(pos),460 req = async_send_3(exch, VFS_IN_WRITE, file, LOWER32(pos), 461 461 UPPER32(pos), &answer); 462 462 rc = async_data_write_start(exch, (void *) buf, nbyte); … … 486 486 * @param nbytes Number of bytes to read 487 487 * 488 * @return On success, non negative number of bytes read.489 * On failure, -1 and sets errno.490 */ 491 ssize_t read(int fildes, aoff64_t *pos, void *buf, size_t nbyte)488 * @return On success, non-negative number of bytes red. 489 * On failure, a negative error code. 490 */ 491 ssize_t vfs_read(int file, aoff64_t *pos, void *buf, size_t nbyte) 492 492 { 493 493 ssize_t cnt = 0; … … 500 500 nread += cnt; 501 501 *pos += cnt; 502 rc = _read_short(fildes, *pos, bp, nbyte - nread, &cnt);502 rc = vfs_read_short(file, *pos, bp, nbyte - nread, &cnt); 503 503 } while (rc == EOK && cnt > 0 && (nbyte - nread - cnt) > 0); 504 504 505 if (rc != EOK) { 506 errno = rc; 507 return -1; 508 } 505 if (rc != EOK) 506 return rc; 509 507 510 508 *pos += cnt; … … 516 514 * This function fails if it cannot write exactly @a len bytes to the file. 517 515 * 518 * @param fil desFile descriptor516 * @param file File descriptor 519 517 * @param pos Pointer to position to write to 520 518 * @param buf Data, @a nbytes bytes long 521 519 * @param nbytes Number of bytes to write 522 520 * 523 * @return On success, non negative number of bytes written.524 * On failure, -1 and sets errno.525 */ 526 ssize_t write(int fildes, aoff64_t *pos, const void *buf, size_t nbyte)521 * @return On success, non-negative number of bytes written. 522 * On failure, a negative error code. 523 */ 524 ssize_t vfs_write(int file, aoff64_t *pos, const void *buf, size_t nbyte) 527 525 { 528 526 ssize_t cnt = 0; … … 535 533 nwritten += cnt; 536 534 *pos += cnt; 537 rc = _write_short(fildes, *pos, bp, nbyte - nwritten, &cnt);535 rc = vfs_write_short(file, *pos, bp, nbyte - nwritten, &cnt); 538 536 } while (rc == EOK && ((ssize_t )nbyte - nwritten - cnt) > 0); 539 537 540 if (rc != EOK) { 541 errno = rc; 542 return -1; 543 } 538 if (rc != EOK) 539 return rc; 544 540 545 541 *pos += cnt; … … 681 677 ssize_t len = 0; 682 678 683 rc = _read_short(dirp->fd, dirp->pos, &dirp->res.d_name[0],679 rc = vfs_read_short(dirp->fd, dirp->pos, &dirp->res.d_name[0], 684 680 NAME_MAX + 1, &len); 685 681 if (rc != EOK) { -
uspace/lib/c/include/unistd.h
r163fc09 rce04ea44 58 58 #define getpagesize() (PAGE_SIZE) 59 59 60 extern ssize_t write(int, aoff64_t *, const void *, size_t);61 extern ssize_t read(int, aoff64_t *, void *, size_t);62 63 60 extern char *getcwd(char *, size_t); 64 61 extern int chdir(const char *); -
uspace/lib/c/include/vfs/vfs.h
r163fc09 rce04ea44 96 96 extern int vfs_open(int, int); 97 97 extern int vfs_put(int); 98 extern int vfs_read_short(int, aoff64_t, void *, size_t, ssize_t *); 99 extern ssize_t vfs_read(int, aoff64_t *, void *, size_t); 98 100 extern int vfs_rename_path(const char *, const char *); 99 101 extern int vfs_resize(int, aoff64_t); … … 110 112 extern int vfs_unmount_path(const char *); 111 113 extern int vfs_walk(int, const char *, int); 112 114 extern int vfs_write_short(int, aoff64_t, const void *, size_t, ssize_t *); 115 extern ssize_t vfs_write(int, aoff64_t *, const void *, size_t); 113 116 114 117 #endif -
uspace/lib/pcut/src/os/helenos.c
r163fc09 rce04ea44 215 215 216 216 aoff64_t pos = 0; 217 read(tempfile, &pos, extra_output_buffer, OUTPUT_BUFFER_SIZE);217 vfs_read(tempfile, &pos, extra_output_buffer, OUTPUT_BUFFER_SIZE); 218 218 219 219 leave_close_tempfile: -
uspace/lib/posix/source/stdio.c
r163fc09 rce04ea44 344 344 { 345 345 const int fildes = *(int *) fd; 346 ssize_t wr = write(fildes, &posix_pos[fildes], str, size);346 ssize_t wr = vfs_write(fildes, &posix_pos[fildes], str, size); 347 347 if (wr < 0) 348 return errno;348 return wr; 349 349 return str_nlength(str, wr); 350 350 } … … 372 372 373 373 const int fildes = *(int *) fd; 374 if ( write(fildes, &posix_pos[fildes], buf, sz) != (ssize_t) sz)374 if (vfs_write(fildes, &posix_pos[fildes], buf, sz) < 0) 375 375 break; 376 376 -
uspace/lib/posix/source/unistd.c
r163fc09 rce04ea44 196 196 ssize_t posix_read(int fildes, void *buf, size_t nbyte) 197 197 { 198 return negerrno(read, fildes, &posix_pos[fildes], buf, nbyte); 198 ssize_t size = rcerrno(vfs_read, fildes, &posix_pos[fildes], buf, nbyte); 199 if (size < 0) 200 return -1; 201 return size; 199 202 } 200 203 … … 209 212 ssize_t posix_write(int fildes, const void *buf, size_t nbyte) 210 213 { 211 return negerrno(write, fildes, &posix_pos[fildes], buf, nbyte); 214 ssize_t size = rcerrno(vfs_write, fildes, &posix_pos[fildes], buf, nbyte); 215 if (size < 0) 216 return -1; 217 return size; 212 218 } 213 219 -
uspace/srv/devman/match.c
r163fc09 rce04ea44 229 229 } 230 230 231 ssize_t read_bytes = read(fd, (aoff64_t []) {0}, buf, len);231 ssize_t read_bytes = vfs_read(fd, (aoff64_t []) {0}, buf, len); 232 232 if (read_bytes <= 0) { 233 233 log_msg(LOG_DEFAULT, LVL_ERROR, "Unable to read file '%s' (%d).", conf_path,
Note:
See TracChangeset
for help on using the changeset viewer.