Changeset f4cbf9dd in mainline


Ignore:
Timestamp:
2013-07-19T22:16:59Z (11 years ago)
Author:
Manuele Conti <conti.ma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
17a0fb8
Parents:
330df83
Message:

Add unit_size option.

File:
1 edited

Legend:

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

    r330df83 rf4cbf9dd  
    4747#define NAME  "df"
    4848
    49 #define HEADER_TABLE "Filesystem     512-blocks           Used      Available Used% Mounted on"
     49#define HEADER_TABLE "Filesystem     %4u-blocks           Used      Available Used%% Mounted on\n"
    5050
    5151#define PERCENTAGE(x, tot) ((unsigned long long) (100L * (x) / (tot))) 
     
    5454                (unsigned long long) ((x) / ((bk) / (fsbk))) : \
    5555                (unsigned long long) ((x) * ((fsbk) / (bk))))
     56
     57static unsigned int unit_size;
    5658
    5759static void print_statfs(struct statfs *, char *, char *);
     
    6365        struct statfs st;
    6466       
     67        unit_size = 512;
     68
    6569        /******************************************/
    6670        /*   Parse command line options...        */
    6771        /******************************************/
    68         while ((optres = getopt(argc, argv, ":hi")) != -1) {
     72        while ((optres = getopt(argc, argv, ":hib:")) != -1) {
    6973                switch(optres) {
    7074                case 'h':
     
    7276
    7377                case 'i':
     78                        break;
     79
     80                case 'b':
     81                        str_uint32_t(optarg, NULL, 0, 0, &unit_size);
    7482                        break;
    7583   
     
    103111        LIST_INITIALIZE(mtab_list);
    104112        get_mtab_list(&mtab_list);
    105         printf("%s\n", HEADER_TABLE);
     113        printf(HEADER_TABLE, unit_size);
    106114        list_foreach(mtab_list, cur) {
    107115                mtab_ent_t *mtab_ent = list_get_instance(cur, mtab_ent_t,
     
    117125{
    118126        printf("%10s", name);
    119         printf(" %14llu %14llu %14llu %4llu%% %s\n",
    120                 FSBK_TO_BK(st->f_blocks, st->f_bsize, 512),                              /* Blocks     */
    121                 FSBK_TO_BK(st->f_blocks - st->f_bfree, st->f_bsize, 512),                /* Used       */
    122                 FSBK_TO_BK(st->f_bfree, st->f_bsize, 512),                               /* Available  */
    123                 (st->f_blocks)?PERCENTAGE(st->f_blocks - st->f_bfree, st->f_blocks):0L,  /* Used%      */
    124                 mountpoint                                                               /* Mounted on */
     127        printf(" %15llu %14llu %14llu %4llu%% %s\n",
     128                FSBK_TO_BK(st->f_blocks, st->f_bsize, unit_size),                              /* Blocks     */
     129                FSBK_TO_BK(st->f_blocks - st->f_bfree, st->f_bsize, unit_size),                /* Used       */
     130                FSBK_TO_BK(st->f_bfree, st->f_bsize, unit_size),                               /* Available  */
     131                (st->f_blocks)?PERCENTAGE(st->f_blocks - st->f_bfree, st->f_blocks):0L,        /* Used%      */
     132                mountpoint                                                                     /* Mounted on */
    125133        );
    126134}
Note: See TracChangeset for help on using the changeset viewer.