Add -g option to the blkid program to garbage collect the blkid.tab file

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2007-05-18 00:16:02 -04:00
parent 7292355283
commit 46100e3f6e
3 changed files with 19 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2007-05-18 Theodore Tso <tytso@mit.edu>
* blkid.c (main): Add -g option to blkid which will garbage
collect the cache.
2007-05-07 Eric Sandeen <sandeen@redhat.com>
* mke2fs.c (PRS): Make defaults more sane when /etc/mke2fs.conf

View File

@ -11,7 +11,7 @@ blkid \- command\-line utility to locate/print block device attributes
.SH SYNOPSIS
.B blkid
[
.B \-hlv
.B \-ghlv
]
[
[
@ -60,6 +60,9 @@ If you want to start with a clean cache (i.e. don't report devices previously
scanned but not necessarily available at this time), specify
.IR /dev/null.
.TP
.B \-g
Perform a garbage collection pass on the blkid cache.
.TP
.B \-h
Display a usage message and exit.
.TP

View File

@ -38,10 +38,11 @@ static void usage(int error)
print_version(out);
fprintf(out,
"usage:\t%s [-c <file>] [-hl] [-o format] "
"usage:\t%s [-c <file>] [-ghl] [-o format] "
"[-s <tag>] [-t <token>]\n [-v] [-w <file>] [dev ...]\n"
"\t-c\tcache file (default: /etc/blkid.tab, /dev/null = none)\n"
"\t-h\tprint this usage message and exit\n"
"\t-g\tgarbage collect the blkid cache\n"
"\t-s\tshow specified tag(s) (default show all tags)\n"
"\t-t\tfind device with a specific token (NAME=value pair)\n"
"\t-l\tlookup the the first device with arguments specified by -t\n"
@ -103,10 +104,10 @@ int main(int argc, char **argv)
int err = 4;
unsigned int i;
int output_format = 0;
int lookup = 0;
int lookup = 0, gc = 0;
int c;
while ((c = getopt (argc, argv, "c:f:hlo:s:t:w:v")) != EOF)
while ((c = getopt (argc, argv, "c:f:ghlo:s:t:w:v")) != EOF)
switch (c) {
case 'c':
if (optarg && !*optarg)
@ -119,6 +120,9 @@ int main(int argc, char **argv)
case 'l':
lookup++;
break;
case 'g':
gc = 1;
break;
case 'o':
if (!strcmp(optarg, "value"))
output_format = OUTPUT_VALUE_ONLY;
@ -178,7 +182,9 @@ int main(int argc, char **argv)
goto exit;
err = 2;
if (lookup) {
if (gc) {
blkid_gc_cache(cache);
} else if (lookup) {
blkid_dev dev;
if (!search_type) {