OSDN Git Service

Add -g option to the blkid program to garbage collect the blkid.tab file
authorTheodore Ts'o <tytso@mit.edu>
Fri, 18 May 2007 04:16:02 +0000 (00:16 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 18 May 2007 04:16:02 +0000 (00:16 -0400)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/ChangeLog
misc/blkid.8.in
misc/blkid.c

index b26f6f2..6cb755e 100644 (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
index 3257826..44a833d 100644 (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
index c02de71..57cfd1a 100644 (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) {