linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peng Tao <bergwolf@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: Theodore Ts'o <tytso@mit.edu>, Peng Tao <bergwolf@gmail.com>
Subject: [PATCH] blkid: add support to the -w option
Date: Mon, 28 Sep 2009 18:53:48 +0800	[thread overview]
Message-ID: <1254135228-28428-1-git-send-email-bergwolf@gmail.com> (raw)

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

Addresses-Launchpad-bug: #316322

Signed-off-by: Peng Tao <bergwolf@gmail.com>
---
 lib/blkid/blkid.h |    1 +
 lib/blkid/cache.c |   13 +++++++++++++
 misc/blkid.c      |    1 +
 3 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/lib/blkid/blkid.h b/lib/blkid/blkid.h
index 81f3098..7f66261 100644
--- a/lib/blkid/blkid.h
+++ b/lib/blkid/blkid.h
@@ -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);
diff --git a/lib/blkid/cache.c b/lib/blkid/cache.c
index 2b81886..4676375 100644
--- a/lib/blkid/cache.c
+++ b/lib/blkid/cache.c
@@ -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)
diff --git a/misc/blkid.c b/misc/blkid.c
index 388abad..5540da7 100644
--- a/misc/blkid.c
+++ b/misc/blkid.c
@@ -417,6 +417,7 @@ int main(int argc, char **argv)
 			err = 0;
 		}
 	}
+	blkid_set_cachefile(cache, write);
 
 exit:
 	free(search_type);
-- 
1.6.5.rc2.262.g5224f


                 reply	other threads:[~2009-09-28 10:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1254135228-28428-1-git-send-email-bergwolf@gmail.com \
    --to=bergwolf@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).