Changeset ce04ea44 in mainline for uspace/lib/c/generic/vfs/vfs.c


Ignore:
Timestamp:
2017-04-02T12:27:14Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d4067a7
Parents:
163fc09
Message:

Rename read() to vfs_read() and write() to vfs_write()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/vfs/vfs.c

    r163fc09 rce04ea44  
    395395 * return success with zero bytes read.
    396396 *
    397  * @param fildes File descriptor
     397 * @param file File descriptor
    398398 * @param pos Position to read from
    399399 * @param buf Buffer
     
    403403 * @return EOK on success, non-zero error code on error.
    404404 */
    405 static int _read_short(int fildes, aoff64_t pos, void *buf, size_t nbyte,
     405int vfs_read_short(int file, aoff64_t pos, void *buf, size_t nbyte,
    406406    ssize_t *nread)
    407407{
     
    415415        async_exch_t *exch = vfs_exchange_begin();
    416416       
    417         req = async_send_3(exch, VFS_IN_READ, fildes, LOWER32(pos),
     417        req = async_send_3(exch, VFS_IN_READ, file, LOWER32(pos),
    418418            UPPER32(pos), &answer);
    419419        rc = async_data_read_start(exch, (void *) buf, nbyte);
     
    438438 * may be lower, but greater than zero.
    439439 *
    440  * @param fildes File descriptor
     440 * @param file File descriptor
    441441 * @param pos Position to write to
    442442 * @param buf Buffer
     
    446446 * @return EOK on success, non-zero error code on error.
    447447 */
    448 static int _write_short(int fildes, aoff64_t pos, const void *buf, size_t nbyte,
     448int vfs_write_short(int file, aoff64_t pos, const void *buf, size_t nbyte,
    449449    ssize_t *nwritten)
    450450{
     
    458458        async_exch_t *exch = vfs_exchange_begin();
    459459       
    460         req = async_send_3(exch, VFS_IN_WRITE, fildes, LOWER32(pos),
     460        req = async_send_3(exch, VFS_IN_WRITE, file, LOWER32(pos),
    461461            UPPER32(pos), &answer);
    462462        rc = async_data_write_start(exch, (void *) buf, nbyte);
     
    486486 * @param nbytes        Number of bytes to read
    487487 *
    488  * @return              On success, nonnegative 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 */
     491ssize_t vfs_read(int file, aoff64_t *pos, void *buf, size_t nbyte)
    492492{
    493493        ssize_t cnt = 0;
     
    500500                nread += cnt;
    501501                *pos += cnt;
    502                 rc = _read_short(fildes, *pos, bp, nbyte - nread, &cnt);
     502                rc = vfs_read_short(file, *pos, bp, nbyte - nread, &cnt);
    503503        } while (rc == EOK && cnt > 0 && (nbyte - nread - cnt) > 0);
    504504       
    505         if (rc != EOK) {
    506                 errno = rc;
    507                 return -1;
    508         }
     505        if (rc != EOK)
     506                return rc;
    509507       
    510508        *pos += cnt;
     
    516514 * This function fails if it cannot write exactly @a len bytes to the file.
    517515 *
    518  * @param fildes        File descriptor
     516 * @param fil        File descriptor
    519517 * @param pos           Pointer to position to write to
    520518 * @param buf           Data, @a nbytes bytes long
    521519 * @param nbytes        Number of bytes to write
    522520 *
    523  * @return              On success, nonnegative 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 */
     524ssize_t vfs_write(int file, aoff64_t *pos, const void *buf, size_t nbyte)
    527525{
    528526        ssize_t cnt = 0;
     
    535533                nwritten += cnt;
    536534                *pos += cnt;
    537                 rc = _write_short(fildes, *pos, bp, nbyte - nwritten, &cnt);
     535                rc = vfs_write_short(file, *pos, bp, nbyte - nwritten, &cnt);
    538536        } while (rc == EOK && ((ssize_t )nbyte - nwritten - cnt) > 0);
    539537
    540         if (rc != EOK) {
    541                 errno = rc;
    542                 return -1;
    543         }
     538        if (rc != EOK)
     539                return rc;
    544540
    545541        *pos += cnt;
     
    681677        ssize_t len = 0;
    682678       
    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],
    684680            NAME_MAX + 1, &len);
    685681        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.