Whamcloud - gitweb
blkid: use list_for_each_safe in garbage collection
authorEric Sandeen <sandeen@redhat.com>
Sat, 21 Jun 2008 03:32:49 +0000 (22:32 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 29 Jun 2008 02:17:20 +0000 (22:17 -0400)
We need to use list_for_each_safe in case a device gets removed from
the list during garbage collection.

Also make the manpage slightly more informative about
what the -g garbage collection option does.

Addresses-Debian-Bug: #487758, #487783

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/blkid/cache.c
misc/blkid.8.in

index 1508d0f..efd4656 100644 (file)
@@ -154,13 +154,13 @@ void blkid_put_cache(blkid_cache cache)
 
 void blkid_gc_cache(blkid_cache cache)
 {
-       struct list_head *p;
+       struct list_head *p, *pnext;
        struct stat st;
 
        if (!cache)
                return;
 
-       list_for_each(p, &cache->bic_devs) {
+       list_for_each_safe(p, pnext, &cache->bic_devs) {
                blkid_dev dev = list_entry(p, struct blkid_struct_dev, bid_devs);
                if (!p)
                        break;
index 42ad0d7..8a4e971 100644 (file)
@@ -61,7 +61,8 @@ scanned but not necessarily available at this time), specify
 .IR /dev/null.
 .TP
 .B \-g
-Perform a garbage collection pass on the blkid cache.
+Perform a garbage collection pass on the blkid cache to remove
+devices which no longer exist.
 .TP
 .B \-h
 Display a usage message and exit.