use list_for_each_safe in garbage collection
PATCH 1/1 use list_for_each_safe in garbage collection
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.
Signed-off-by Eric Sandeen <[email protected]>
---
lib/blkid/cache.c +2 -2
@@ -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 ;
misc/blkid.8.in +2 -1
@@ -61,7 +61,8 @@ scanned but not necessarily available at .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.