Changeset ce04ea44 in mainline for uspace/lib/c/generic/vfs/vfs.c
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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) {
Note:
See TracChangeset
for help on using the changeset viewer.