From 46100e3f6e21a5eb8fbb4d843d4c7fee368b31f5 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 18 May 2007 00:16:02 -0400 Subject: [PATCH] Add -g option to the blkid program to garbage collect the blkid.tab file Signed-off-by: "Theodore Ts'o" --- misc/ChangeLog | 5 +++++ misc/blkid.8.in | 5 ++++- misc/blkid.c | 14 ++++++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/misc/ChangeLog b/misc/ChangeLog index b26f6f2c..6cb755ea 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,3 +1,8 @@ +2007-05-18 Theodore Tso + + * blkid.c (main): Add -g option to blkid which will garbage + collect the cache. + 2007-05-07 Eric Sandeen * mke2fs.c (PRS): Make defaults more sane when /etc/mke2fs.conf diff --git a/misc/blkid.8.in b/misc/blkid.8.in index 32578264..44a833d6 100644 --- a/misc/blkid.8.in +++ b/misc/blkid.8.in @@ -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 diff --git a/misc/blkid.c b/misc/blkid.c index c02de714..57cfd1a4 100644 --- a/misc/blkid.c +++ b/misc/blkid.c @@ -38,10 +38,11 @@ static void usage(int error) print_version(out); fprintf(out, - "usage:\t%s [-c ] [-hl] [-o format] " + "usage:\t%s [-c ] [-ghl] [-o format] " "[-s ] [-t ]\n [-v] [-w ] [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) {