From 772b89d34212e4b36c2025c80304e166bc25a2f3 Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Fri, 20 Jun 2008 22:32:49 -0500 Subject: [PATCH] blkid: 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. Addresses-Debian-Bug: #487758, #487783 Signed-off-by: Eric Sandeen Signed-off-by: Theodore Ts'o --- lib/blkid/cache.c | 4 ++-- misc/blkid.8.in | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/blkid/cache.c b/lib/blkid/cache.c index 1508d0f86..efd4656e3 100644 --- a/lib/blkid/cache.c +++ b/lib/blkid/cache.c @@ -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; diff --git a/misc/blkid.8.in b/misc/blkid.8.in index 42ad0d711..8a4e9718f 100644 --- a/misc/blkid.8.in +++ b/misc/blkid.8.in @@ -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. -- 2.47.2