From patchwork Mon Sep 28 10:53:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 34375 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id EE176B7334 for ; Mon, 28 Sep 2009 20:54:13 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752284AbZI1KyI (ORCPT ); Mon, 28 Sep 2009 06:54:08 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752330AbZI1KyH (ORCPT ); Mon, 28 Sep 2009 06:54:07 -0400 Received: from mail-pz0-f191.google.com ([209.85.222.191]:33132 "EHLO mail-pz0-f191.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752284AbZI1KyH (ORCPT ); Mon, 28 Sep 2009 06:54:07 -0400 Received: by pzk29 with SMTP id 29so2314869pzk.33 for ; Mon, 28 Sep 2009 03:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=+DPtBx6dxmNJnAEt287t89+S2Mbq/EG81WBDHVIobqY=; b=ADqCBlXpidPGR87p5kj9X80hwgFUxU3w9p9hdFlD67jQPofpw0h/YFqxujiHr+6kJ7 r5qu2BEZTEa5nSzIs1skgmgK+HrS1vaRZIz9C9X1tHNOj3yw43V/LGpGq6kP9enUNTr4 r9VcPVQ3ggtWoVMxKNa88k9LaR4m9JtYJV2WM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=GNTTGbGrJivtQqCp+9SvBCGuVXPqcMI7/ctH+kswt2BfwuagCdYOVnq2D1RW5i/pDR KCOJuAH+AHRC0NBQOawK44+TtHCTYRjs11sCMGv0LJTT1StxknbbPcXdX+ImlINZ0+R0 7GOigrRVtgHsXH8YfLp7tm5ta5JQwbfqx8J1s= Received: by 10.115.38.40 with SMTP id q40mr5643921waj.95.1254135251148; Mon, 28 Sep 2009 03:54:11 -0700 (PDT) Received: from localhost.localdomain ([147.243.236.28]) by mx.google.com with ESMTPS id 22sm2263900pzk.10.2009.09.28.03.54.09 (version=SSLv3 cipher=RC4-MD5); Mon, 28 Sep 2009 03:54:10 -0700 (PDT) From: Peng Tao To: linux-ext4@vger.kernel.org Cc: Theodore Ts'o , Peng Tao Subject: [PATCH] blkid: add support to the -w option Date: Mon, 28 Sep 2009 18:53:48 +0800 Message-Id: <1254135228-28428-1-git-send-email-bergwolf@gmail.com> X-Mailer: git-send-email 1.6.5.rc2.262.g5224f Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- 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);