From 418b15a6be815edba7a871692386e1625c10f1ce Mon Sep 17 00:00:00 2001 From: Bobbi Webber-Manners Date: Thu, 5 Mar 2020 20:44:43 -0500 Subject: [PATCH] Added -z, zero free blocks option --- bobbi/sortdir.c#b00008 | 57 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/bobbi/sortdir.c#b00008 b/bobbi/sortdir.c#b00008 index ff78daa..c17b7ac 100644 --- a/bobbi/sortdir.c#b00008 +++ b/bobbi/sortdir.c#b00008 @@ -1,7 +1,6 @@ /* * Bobbi January-February 2020 * - * TODO: Tool for 'extending' volume dir to more than 4 blocks * TODO: Trimming unused directory blocks * TODO: Make a version that doesn't need GNO - eliminate call to stat() */ @@ -152,6 +151,7 @@ static uchar dowrite = 0; /* -w write option */ static uchar doverbose = 0; /* -v verbose option */ static uchar dodebug = 0; /* -V very verbose option */ static uchar do_ctime = 0; /* -k ctime option */ +static uchar dozero = 0; /* -z zero free blocks option */ static char sortopts[5] = ""; /* -s:abc list of sort options */ static char caseopts[2] = ""; /* -c:x case conversion option */ static char fixopts[2] = ""; /* -f:x fix mode option */ @@ -209,7 +209,9 @@ int writedir(uchar device); void freeblocks(void); void usage(void); void processdir(uint device, uint blocknum); -void checkfreeandused(void); +void checkfreeandused(uchar device); +void zeroblock(uchar device, uint blocknum); +void zerofreeblocks(uchar device, uint freeblks); /* Horizontal line */ void hline(void) { @@ -1526,6 +1528,7 @@ void usage(void) { printf(" -D Whole-disk mode (implies -r)\n"); printf(" -w Enable writing to disk\n"); printf(" -c Use create time rather than modify time\n"); + printf(" -z Zero free space\n"); printf(" -v Verbose output\n"); printf(" -V Verbose debugging output\n"); printf(" -h This help\n"); @@ -1612,7 +1615,7 @@ done: * If we have visited all files and directories on the volume, every * block should either be marked free or marked used. */ -void checkfreeandused(void) { +void checkfreeandused(uchar device) { printf("Total blocks on volume\t%u\n", totblks); uint freeblks = 0; for (uint i=0; i