[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Du feature request - group reporting
From: |
Daniel Gall |
Subject: |
Du feature request - group reporting |
Date: |
Thu, 25 Jan 2018 13:11:15 -0500 |
It is interestingly me that POSIX specifies groups but does not specify that
reporting tools will contemplate sub-aggregating output by group. Please
consider the following diff patch to du.c or something like it. I of course
checked your list of rejected features for du and found nothing remotely
similar in the list.
Thank you
Dan.
A diff patch against du from coreutils 8.26:
coreutils-8.26> !diff
diff src/du.c src/du.c.bak
38d37
< #include "grp.h"
65,67d63
< /* If true, display group size info. */
< bool opt_group_sizes = false;
<
87c83
< uintmax_t *group_size;
---
>
97d92
< uintmax_t i = 0;
100,105d94
< if (opt_group_sizes)
< {
< for (i=0; i<65535; i++){
< a->group_size[i] = 0;
< }
< }
112c101
< duinfo_set (struct duinfo *a, uintmax_t size, struct timespec tmax, uintmax_t
gid)
---
> duinfo_set (struct duinfo *a, uintmax_t size, struct timespec tmax)
114,116d102
< uintmax_t i = 0;
< uintmax_t gid_u = (uintmax_t)gid;
< uintmax_t gid_s;
119,134d104
< if (opt_group_sizes)
< {
< if (gid_u > 65534)
< {
< gid_s = 65534;
< }
< else
< {
< gid_s = gid_u;
< }
< if (gid_s >=0 && gid_s <=65534)
< {
< a->group_size[gid_s] = size;
< }
< }
<
142d111
< uintmax_t i = 0;
146,152d114
< if (opt_group_sizes)
< {
< for (i=0; i<65535; i++){
< sum = a->group_size[i] + b->group_size[i];
< a->group_size[i] = a->group_size[i] <= sum ? sum : UINTMAX_MAX;
< }
< }
267d228
< {"group-reporting", no_argument, NULL, 'g'},
359d319
< -g, --group-reporting also print group subtotals\n\
454,471c414
< if (opt_group_sizes)
< {
< uintmax_t i=0;
< struct group *g;
< for (i=0; i<65535; i++){
< if (pdui->group_size[i] > 0)
< {
< g = getgrgid(i);
< printf (",");
< if (g == NULL){
< printf (" %d:", i);
< }else{
< printf(" %s:", g->gr_name);
< }
< print_only_size(pdui->group_size[i]);
< }
< }
< }
---
>
566,574d508
< if(opt_group_sizes)
< {
< dui.group_size = xcalloc (65536, sizeof (uintmax_t));
< dui_to_print.group_size = xcalloc (65536, sizeof (uintmax_t));
< if (dui.group_size == NULL || dui_to_print.group_size == NULL)
< {
< return false;
< }
< }
599,609d532
< if(opt_group_sizes)
< {
< if (dui.group_size != NULL)
< {
< free(dui.group_size);
< }
< if (dui_to_print.group_size != NULL)
< {
< free(dui_to_print.group_size);
< }
< }
639,649d561
< if(opt_group_sizes)
< {
< if (dui.group_size != NULL)
< {
< free(dui.group_size);
< }
< if (dui_to_print.group_size != NULL)
< {
< free(dui_to_print.group_size);
< }
< }
656,666d567
< if(opt_group_sizes)
< {
< if (dui.group_size != NULL)
< {
< free(dui.group_size);
< }
< if (dui_to_print.group_size != NULL)
< {
< free(dui_to_print.group_size);
< }
< }
676,686d576
< if(opt_group_sizes)
< {
< if (dui.group_size != NULL)
< {
< free(dui.group_size);
< }
< if (dui_to_print.group_size != NULL)
< {
< free(dui_to_print.group_size);
< }
< }
696a587
>
703,704c594
< : get_stat_ctime (sb)),
< sb->st_gid);
---
> : get_stat_ctime (sb)));
707,722c597
< /*dui_to_print = dui;*/
< if (opt_group_sizes)
< {
< duinfo_set (&dui_to_print,
< (apparent_size
< ? MAX (0, sb->st_size)
< : (uintmax_t) ST_NBLOCKS (*sb) * ST_NBLOCKSIZE),
< (time_type == time_mtime ? get_stat_mtime (sb)
< : time_type == time_atime ? get_stat_atime (sb)
< : get_stat_ctime (sb)),
< sb->st_gid);
< }
< else
< {
< dui_to_print = dui;
< }
---
> dui_to_print = dui;
726d600
< size_t i;
729,744d602
< if (dulvl == NULL)
< {
< return false;
< }
< if(opt_group_sizes)
< {
< for (i=0; i<n_alloc; i++)
< {
< dulvl[i].ent.group_size = xcalloc (65536, sizeof (uintmax_t));
< dulvl[i].subdir.group_size = xcalloc (65536, sizeof
(uintmax_t));
< if (dulvl[i].ent.group_size == NULL ||
dulvl[i].subdir.group_size == NULL)
< {
< return false;
< }
< }
< }
763,775d620
< if(opt_group_sizes)
< {
< for (i=n_alloc; i<level*2; i++)
< {
< dulvl[i].ent.group_size = xcalloc (65536, sizeof
(uintmax_t));
< dulvl[i].subdir.group_size = xcalloc (65536, sizeof
(uintmax_t));
< if (dulvl[i].ent.group_size == NULL ||
dulvl[i].subdir.group_size == NULL)
< {
< return false;
< }
<
< }
< }
802a648
>
823,833c669
< if(opt_group_sizes)
< {
< if (dui.group_size != NULL)
< {
< free(dui.group_size);
< }
< if (dui_to_print.group_size != NULL)
< {
< free(dui_to_print.group_size);
< }
< }
---
>
923c759
< int c = getopt_long (argc, argv, "0abgd:chHklmst:xB:DLPSX:",
---
> int c = getopt_long (argc, argv, "0abd:chHklmst:xB:DLPSX:",
973,981d808
< case 'g':
< tot_dui.group_size = xcalloc (65536, sizeof (uintmax_t));
< if (tot_dui.group_size == NULL)
< {
< ok = false;
< }
< opt_group_sizes = true;
< break;
<
1101a929
>
Sent from my iPhone
- Du feature request - group reporting,
Daniel Gall <=