Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b5b5d84 in mainline


Ignore:
Timestamp:
2017-03-30T18:58:28Z (5 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
23a0368
Parents:
fe91f66
Message:

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

Location:
uspace
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/df/df.c

    rfe91f66 rb5b5d84  
    4040#include <stdint.h>
    4141#include <getopt.h>
    42 #include <sys/statfs.h>
    4342#include <errno.h>
    4443#include <adt/list.h>
     
    124123        print_header();
    125124        list_foreach(mtab_list, link, mtab_ent_t, mtab_ent) {
    126                 if (statfs(mtab_ent->mp, &st) == 0) {
     125                if (vfs_statfs_path(mtab_ent->mp, &st) == 0) {
    127126                        print_statfs(&st, mtab_ent->fs_name, mtab_ent->mp);
    128127                } else {
  • 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
  • uspace/lib/c/include/vfs/vfs.h

    rfe91f66 rb5b5d84  
    4949};
    5050
     51struct statfs {
     52        char fs_name[FS_NAME_MAXLEN + 1];
     53        uint32_t f_bsize;    /* fundamental file system block size */
     54        uint64_t f_blocks;   /* total data blocks in file system */
     55        uint64_t f_bfree;    /* free blocks in fs */
     56};
     57
    5158extern char *vfs_absolutize(const char *, size_t *);
    5259
     
    7279extern int vfs_root(void);
    7380extern void vfs_root_set(int);
     81extern int vfs_statfs(int, struct statfs *);
     82extern int vfs_statfs_path(const char *, struct statfs *);
    7483
    7584int vfs_mount(int, const char *, service_id_t, const char *, unsigned, unsigned, int *);
  • uspace/lib/fs/libfs.c

    rfe91f66 rb5b5d84  
    4545#include <str.h>
    4646#include <sys/stat.h>
    47 #include <sys/statfs.h>
    4847#include <stdlib.h>
    4948#include <fibril_synch.h>
    5049#include <ipc/vfs.h>
     50#include <vfs/vfs.h>
    5151
    5252#define on_error(rc, action) \
Note: See TracChangeset for help on using the changeset viewer.