Skip to contentSkip to conversation

blkid: add support to the -w option

PATCH New Peng Tao 1 participant 1 message Sep 28, 2009

lore
Share & tools
lore

Peng Tao

author
#0 lore raw

PATCH 1/1 blkid: add support to the -w option

blkid -w should write an alternative cache file but it is not implemented. The patch makes it work properly.

Addresses-Launchpad-bug: #316322

---
 lib/blkid/blkid.h |    1 +
 lib/blkid/cache.c |   13 +++++++++++++
 misc/blkid.c      |    1 +
 3 files changed, 15 insertions(+), 0 deletions(-)
lib/blkid/blkid.h +1 -0
index 81f3098..7f66261 100644
@@ -51,6 +51,7 @@ typedef struct blkid_struct_dev_iterate *blkid_dev_iterate;
 extern void blkid_put_cache(blkid_cache cache);
 extern int blkid_get_cache(blkid_cache *cache, const char *filename);
 extern void blkid_gc_cache(blkid_cache cache);
+extern void blkid_set_cachefile(blkid_cache cache, const char *filename);
 
 /* dev.c */
 extern const char *blkid_dev_devname(blkid_dev dev);
lib/blkid/cache.c +13 -0
index 2b81886..4676375 100644
@@ -175,6 +175,19 @@ void blkid_gc_cache(blkid_cache cache)
 	}
 }
 
+void blkid_set_cachefile(blkid_cache cache, const char *filename)
+{
+	if (!cache || !filename)
+		return;
+
+	if (! strcmp(cache->bic_filename, filename))
+		return;
+	free(cache->bic_filename);
+	cache->bic_filename = blkid_strdup(filename);
+	/* Always mark cache file changed if another cache file is specified */
+	cache->bic_flags |= BLKID_BIC_FL_CHANGED;
+}
+
 
 #ifdef TEST_PROGRAM
 int main(int argc, char** argv)
misc/blkid.c +1 -0
index 388abad..5540da7 100644
@@ -417,6 +417,7 @@ int main(int argc, char **argv)
 			err = 0;
 		}
 	}
+	blkid_set_cachefile(cache, write);
 
 exit:
 	free(search_type);
Signature · 1 line
1.6.5.rc2.262.g5224f