Changeset e8f0158 in mainline


Ignore:
Timestamp:
2013-07-11T21:17:42Z (11 years ago)
Author:
Manuele Conti <conti.ma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d0a1e9b6
Parents:
67632f7
Message:

Change statfs structure fields [64bit].
Add total_block and free_block operation for ext4fs.

Location:
uspace
Files:
3 edited

Legend:

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

    r67632f7 re8f0158  
    3838#include <stdlib.h>
    3939#include <unistd.h>
     40#include <stdint.h>
    4041#include <sys/statfs.h>
    4142#include <errno.h>
     
    4748#define HEADER_TABLE "Filesystem    512-blocks      Used      Available  Used%  Mounted on"
    4849
    49 #define PERCENTAGE(x, tot) ((long) (100L * (x) / (tot))) 
     50#define PERCENTAGE(x, tot) ((unsigned long long) (100L * (x) / (tot))) 
    5051
    5152int main(int argc, char *argv[])
     
    6061                    link);
    6162                statfs(mtab_ent->mp, &st);
    62                 printf("block size:%ld\n", st.f_bsize);
    63                 printf("%13s %15lld %9lld %9lld %3ld%% %s\n",
     63                printf("block size:%lu\n", (unsigned long)st.f_bsize);
     64                printf("%13s %15llu %9llu %9llu %3llu%% %s\n",
    6465                        mtab_ent->fs_name,
    65                         (long long) st.f_blocks * st.f_bsize,
    66                         (long long) (st.f_blocks - st.f_bfree) * st.f_bsize,
    67                         (long long) st.f_bfree * st.f_bsize,
     66                        (unsigned long long) st.f_blocks * st.f_bsize,
     67                        (unsigned long long) (st.f_blocks - st.f_bfree) * st.f_bsize,
     68                        (unsigned long long) st.f_bfree * st.f_bsize,
    6869                        (st.f_blocks)?PERCENTAGE(st.f_blocks - st.f_bfree, st.f_blocks):0L,
    6970                        mtab_ent->mp);
  • uspace/lib/c/include/sys/statfs.h

    r67632f7 re8f0158  
    3939
    4040struct statfs {
    41         short   f_type;     /* type of file system  */
    42         long    f_bsize;    /* fundamental file system block size */
    43         long    f_blocks;   /* total data blocks in file system */
    44         long    f_bfree;    /* free blocks in fs */
     41        uint32_t    f_type;     /* type of file system  */
     42        uint32_t    f_bsize;    /* fundamental file system block size */
     43        uint64_t    f_blocks;   /* total data blocks in file system */
     44        uint64_t    f_bfree;    /* free blocks in fs */
    4545};
    4646
  • uspace/srv/fs/ext4fs/ext4fs_ops.c

    r67632f7 re8f0158  
    102102static service_id_t ext4fs_service_get(fs_node_t *node);
    103103static long ext4fs_size_block(service_id_t);
     104static long ext4fs_total_block(service_id_t);
     105static long ext4fs_free_block(service_id_t);
    104106
    105107/* Static variables */
     
    847849        if (NULL == inst)
    848850                return ENOENT;
     851
    849852        ext4_superblock_t *sb = inst->filesystem->superblock;
    850853        uint32_t block_size = ext4_superblock_get_block_size(sb);
     854
    851855        return block_size;
     856}
     857
     858long ext4fs_total_block(service_id_t service_id)
     859{
     860        ext4fs_instance_t *inst;
     861        int rc = ext4fs_instance_get(service_id, &inst);
     862        if (rc != EOK)
     863                return rc;
     864        if (NULL == inst)
     865                return ENOENT;
     866
     867        ext4_superblock_t *sb = inst->filesystem->superblock;
     868        uint32_t block_count = ext4_superblock_get_blocks_count(sb);
     869
     870        return block_count;
     871}
     872
     873long ext4fs_free_block(service_id_t service_id)
     874{
     875        ext4fs_instance_t *inst;
     876        int rc = ext4fs_instance_get(service_id, &inst);
     877        if (rc != EOK)
     878                return rc;
     879        if (NULL == inst)
     880                return ENOENT;
     881
     882        ext4_superblock_t *sb = inst->filesystem->superblock;
     883        uint32_t block_count = ext4_superblock_get_free_blocks_count(sb);
     884
     885        return block_count;
    852886}
    853887
     
    872906        .is_file = ext4fs_is_file,
    873907        .service_get = ext4fs_service_get,
    874         .size_block = ext4fs_size_block
     908        .size_block = ext4fs_size_block,
     909        .total_block = ext4fs_total_block,
     910        .free_block = ext4fs_free_block
    875911};
    876912
Note: See TracChangeset for help on using the changeset viewer.