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


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

Rename statfs() to vfs_statfs_path() and provide relativized vfs_statfs()

File:
1 edited

Legend:

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

    rfe91f66 rb5b5d84  
    4444#include <stdio.h>
    4545#include <sys/stat.h>
    46 #include <sys/statfs.h>
    4746#include <sys/types.h>
    4847#include <ipc/services.h>
     
    10841083
    10851084        struct statfs stfs;
    1086         if (statfs(path, &stfs) == EOK)
     1085        if (vfs_statfs_path(path, &stfs) == EOK)
    10871086                str_cpy(ent->fs_name, sizeof(ent->fs_name), stfs.fs_name);
    10881087        else
     
    11641163/** Get filesystem statistics.
    11651164 *
     1165 * @param file File located on the queried file system
     1166 * @param st Buffer for storing information
     1167 * @return 0 on success. On error -1 is returned and errno is set.
     1168 */
     1169int vfs_statfs(int file, struct statfs *st)
     1170{
     1171        sysarg_t rc, ret;
     1172        aid_t req;
     1173
     1174        async_exch_t *exch = vfs_exchange_begin();
     1175
     1176        req = async_send_1(exch, VFS_IN_STATFS, file, NULL);
     1177        rc = async_data_read_start(exch, (void *) st, sizeof(*st));
     1178
     1179        vfs_exchange_end(exch);
     1180        async_wait_for(req, &ret);
     1181
     1182        rc = (ret != EOK ? ret : rc);
     1183
     1184        return rc;
     1185}
     1186/** Get filesystem statistics.
     1187 *
    11661188 * @param path Mount point path
    11671189 * @param st Buffer for storing information
    1168  * @return 0 on success. On error -1 is returned and errno is set.
    1169  */
    1170 int statfs(const char *path, struct statfs *st)
    1171 {
    1172         int fd = vfs_lookup(path, 0);
    1173         if (fd < 0) {
    1174                 errno = fd;
    1175                 return -1;
    1176         }
    1177        
    1178         sysarg_t rc, ret;
    1179         aid_t req;
    1180 
    1181         async_exch_t *exch = vfs_exchange_begin();
    1182 
    1183         req = async_send_1(exch, VFS_IN_STATFS, fd, NULL);
    1184         rc = async_data_read_start(exch, (void *) st, sizeof(*st));
    1185 
    1186         vfs_exchange_end(exch);
    1187         async_wait_for(req, &ret);
    1188         close(fd);
    1189 
    1190         rc = (ret != EOK ? ret : rc);
    1191         if (rc != EOK) {
    1192                 errno = rc;
    1193                 return -1;
    1194         }
    1195 
    1196         return 0;
     1190 * @return EOK on success or a negative error code otherwise.
     1191 */
     1192int vfs_statfs_path(const char *path, struct statfs *st)
     1193{
     1194        int file = vfs_lookup(path, 0);
     1195        if (file < 0)
     1196                return file;
     1197       
     1198        int rc = vfs_statfs(file, st);
     1199
     1200        close(file);
     1201
     1202        return rc;
    11971203}
    11981204
Note: See TracChangeset for help on using the changeset viewer.