[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] allow filenames with vgcfgrestore -l



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Simple patch to permit a metadata backup file to be specified on the
vgcfgrestore command line using -f when listing backups, for e.g.:

vgcfgrestore -l -f /tmp/VolGroup

LVM1 allowed this behavior and it's been requested a couple of times on
the mailing list.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFGZzzk6YSQoMYUY94RAi+gAJ9xiDIQhdcV1a+78ko9TEaGijVTvgCgrag+
u1Fmzww3vn68W4AJ7CUvKfA=
=V+OQ
-----END PGP SIGNATURE-----
Allow filenames with vgcfgrestore -l
Index: lib/format_text/archive.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/format_text/archive.c,v
retrieving revision 1.25
diff -u -r1.25 archive.c
--- lib/format_text/archive.c	25 Jan 2007 14:37:48 -0000	1.25
+++ lib/format_text/archive.c	6 Jun 2007 22:38:33 -0000
@@ -362,6 +362,22 @@
 	return 1;
 }
 
+int archive_list_file(struct cmd_context *cmd, const char *file)
+{
+	struct archive_file af;
+
+	af.path = (char *)file;
+
+	if (!path_exists(af.path)) {
+		log_err("Archive file %s not found.", af.path);
+		return 0;
+	}
+
+	_display_archive(cmd, &af);
+
+	return 1;
+}
+
 int backup_list(struct cmd_context *cmd, const char *dir, const char *vgname)
 {
 	struct archive_file af;
Index: lib/format_text/archiver.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/format_text/archiver.c,v
retrieving revision 1.5
diff -u -r1.5 archiver.c
--- lib/format_text/archiver.c	21 Aug 2006 12:54:52 -0000	1.5
+++ lib/format_text/archiver.c	6 Jun 2007 22:38:34 -0000
@@ -148,6 +148,17 @@
 	return r1 && r2;
 }
 
+int archive_display_file(struct cmd_context *cmd, const char *file)
+{
+	int r;
+
+	init_partial(1);
+	r = archive_list_file(cmd, file);
+	init_partial(0);
+
+	return r;
+}
+
 int backup_init(struct cmd_context *cmd, const char *dir)
 {
 	if (!(cmd->backup_params = dm_pool_zalloc(cmd->libmem,
Index: lib/format_text/archiver.h
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/format_text/archiver.h,v
retrieving revision 1.1
diff -u -r1.1 archiver.h
--- lib/format_text/archiver.h	17 May 2005 13:46:37 -0000	1.1
+++ lib/format_text/archiver.h	6 Jun 2007 22:38:34 -0000
@@ -38,6 +38,7 @@
 void archive_enable(struct cmd_context *cmd, int flag);
 int archive(struct volume_group *vg);
 int archive_display(struct cmd_context *cmd, const char *vg_name);
+int archive_display_file(struct cmd_context *cmd, const char *file);
 
 int backup_init(struct cmd_context *cmd, const char *dir);
 void backup_exit(struct cmd_context *cmd);
Index: lib/format_text/format-text.h
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/format_text/format-text.h,v
retrieving revision 1.20
diff -u -r1.20 format-text.h
--- lib/format_text/format-text.h	11 May 2006 17:58:58 -0000	1.20
+++ lib/format_text/format-text.h	6 Jun 2007 22:38:34 -0000
@@ -33,6 +33,7 @@
  * Displays a list of vg backups in a particular archive directory.
  */
 int archive_list(struct cmd_context *cmd, const char *dir, const char *vgname);
+int archive_list_file(struct cmd_context *cmd, const char *file);
 int backup_list(struct cmd_context *cmd, const char *dir, const char *vgname);
 
 /*
Index: tools/vgcfgrestore.c
===================================================================
RCS file: /cvs/lvm2/LVM2/tools/vgcfgrestore.c,v
retrieving revision 1.13
diff -u -r1.13 vgcfgrestore.c
--- tools/vgcfgrestore.c	9 Mar 2007 20:47:41 -0000	1.13
+++ tools/vgcfgrestore.c	6 Jun 2007 22:38:35 -0000
@@ -19,26 +19,27 @@
 {
 	char *vg_name;
 
-	if (argc != 1) {
+	if (argc == 1) {
+		vg_name = skip_dev_dir(cmd, argv[0], NULL);
+		if (!validate_name(vg_name)) {
+			log_error("Volume group name \"%s\" is invalid", vg_name);
+			return ECMD_FAILED;
+		}
+	} else if (!(arg_count(cmd, list_ARG) && arg_count(cmd, file_ARG))) {
 		log_err("Please specify a *single* volume group to restore.");
 		return ECMD_FAILED;
 	}
 
-	vg_name = skip_dev_dir(cmd, argv[0], NULL);
-
-	if (!validate_name(vg_name)) {
-		log_error("Volume group name \"%s\" is invalid", vg_name);
-		return ECMD_FAILED;
-	}
-
 	/*
 	 * FIXME: overloading the -l arg for now to display a
 	 * list of archive files for a particular vg
 	 */
 	if (arg_count(cmd, list_ARG)) {
-		if (!archive_display(cmd, vg_name))
+		if (!(arg_count(cmd,file_ARG) ?
+			archive_display_file(cmd,
+					arg_str_value(cmd, file_ARG, "")) :
+			archive_display(cmd, vg_name)))
 			return ECMD_FAILED;
-
 		return ECMD_PROCESSED;
 	}
 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]