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


Ignore:
Timestamp:
2017-03-08T09:56:06Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5126f80
Parents:
bb9ec2d
Message:

Implement statfs() using _vfs_walk()

File:
1 edited

Legend:

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

    rbb9ec2d ra737667e  
    11241124int statfs(const char *path, struct statfs *st)
    11251125{
    1126         sysarg_t rc, rc_orig;
     1126        size_t pa_size;
     1127        char *pa = vfs_absolutize(path, &pa_size);
     1128        if (!pa) {
     1129                errno = ENOMEM;
     1130                return -1;
     1131        }
     1132       
     1133        int fd = _vfs_walk(-1, pa, 0);
     1134        if (fd < 0) {
     1135                free(pa);
     1136                errno = fd;
     1137                return -1;
     1138        }
     1139
     1140        free(pa);
     1141       
     1142        sysarg_t rc, ret;
    11271143        aid_t req;
    1128         size_t pa_size;
    1129 
    1130         char *pa = vfs_absolutize(path, &pa_size);
    1131         if (pa == NULL) {
    1132                 errno = ENOMEM;
    1133                 return -1;
    1134         }
    1135 
    1136         async_exch_t *exch = vfs_exchange_begin();
    1137 
    1138         req = async_send_0(exch, VFS_IN_STATFS, NULL);
    1139         rc = async_data_write_start(exch, pa, pa_size);
    1140         if (rc != EOK)
    1141                 goto exit;
    1142 
     1144
     1145        async_exch_t *exch = vfs_exchange_begin();
     1146
     1147        req = async_send_1(exch, VFS_IN_STATFS, fd, NULL);
    11431148        rc = async_data_read_start(exch, (void *) st, sizeof(*st));
    11441149
    1145 exit:
    1146         vfs_exchange_end(exch);
    1147         free(pa);
    1148         async_wait_for(req, &rc_orig);
    1149         rc = (rc_orig != EOK ? rc_orig : rc);
    1150 
     1150        vfs_exchange_end(exch);
     1151        async_wait_for(req, &ret);
     1152        close(fd);
     1153
     1154        rc = (ret != EOK ? ret : rc);
    11511155        if (rc != EOK) {
    11521156                errno = rc;
Note: See TracChangeset for help on using the changeset viewer.