Changeset 23a0368 in mainline for uspace/lib/c/generic/vfs/vfs.c


Ignore:
Timestamp:
2017-03-30T19:52:23Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ae7bfbbd
Parents:
b5b5d84
Message:

Rename stat() to vfs_stat_path() and fstat() to vfs_stat()

File:
1 edited

Legend:

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

    rb5b5d84 r23a0368  
    641641/** Get file status.
    642642 *
    643  * @param fildes File descriptor
     643 * @param file File descriptor
    644644 * @param stat Place to store file information
    645645 *
    646  * @return 0 on success, -1 on error and sets errno.
    647  */
    648 int fstat(int fildes, struct stat *stat)
     646 * @return EOK on success or a negative error code otherwise.
     647 */
     648int vfs_stat(int file, struct stat *stat)
    649649{
    650650        sysarg_t rc;
     
    653653        async_exch_t *exch = vfs_exchange_begin();
    654654       
    655         req = async_send_1(exch, VFS_IN_STAT, fildes, NULL);
     655        req = async_send_1(exch, VFS_IN_STAT, file, NULL);
    656656        rc = async_data_read_start(exch, (void *) stat, sizeof(struct stat));
    657657        if (rc != EOK) {
     
    663663                if (rc_orig != EOK)
    664664                        rc = rc_orig;
    665                 if (rc != EOK) {
    666                         errno = rc;
    667                         return -1;
    668                 }
    669665               
    670                 return 0;
     666                return rc;
    671667        }
    672668       
     
    674670        async_wait_for(req, &rc);
    675671       
    676         if (rc != EOK) {
    677                 errno = rc;
    678                 return -1;
    679         }
    680        
    681         return 0;
     672        return rc;
    682673}
    683674
     
    687678 * @param stat Place to store file information
    688679 *
    689  * @return 0 on success, -1 on error and sets errno.
    690  */
    691 int stat(const char *path, struct stat *stat)
    692 {
    693         int fd = vfs_lookup(path, 0);
    694         if (fd < 0) {
    695                 errno = fd;
    696                 return -1;
    697         }
    698        
    699         int rc = fstat(fd, stat);
    700         if (rc != EOK) {
    701                 close(fd);
    702                 errno = rc;
    703                 rc = -1;
    704         } else
    705                 rc = close(fd);
     680 * @return EOK on success or a negative error code otherwise.
     681 */
     682int vfs_stat_path(const char *path, struct stat *stat)
     683{
     684        int file = vfs_lookup(path, 0);
     685        if (file < 0)
     686                return file;
     687       
     688        int rc = vfs_stat(file, stat);
     689
     690        close(file);
    706691
    707692        return rc;
     
    10571042 * @return On success returns session pointer. On error returns @c NULL.
    10581043 */
    1059 async_sess_t *vfs_fd_session(int fildes, iface_t iface)
     1044async_sess_t *vfs_fd_session(int file, iface_t iface)
    10601045{
    10611046        struct stat stat;
    1062         int rc = fstat(fildes, &stat);
     1047        int rc = vfs_stat(file, &stat);
    10631048        if (rc != 0)
    10641049                return NULL;
     
    11221107                child = pa;
    11231108
    1124                 rc = stat(child, &st);
     1109                rc = vfs_stat_path(child, &st);
    11251110                if (rc != 0) {
    11261111                        free(child);
     
    11521137        struct stat st;
    11531138
    1154         int rc = stat("/", &st);
     1139        int rc = vfs_stat_path("/", &st);
    11551140        if (rc != 0)
    11561141                return rc;
     
    11651150 * @param file File located on the queried file system
    11661151 * @param st Buffer for storing information
    1167  * @return 0 on success. On error -1 is returned and errno is set.
     1152 * @return EOK on success or a negative error code otherwise.
    11681153 */
    11691154int vfs_statfs(int file, struct statfs *st)
Note: See TracChangeset for help on using the changeset viewer.