public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: wysochanski@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2/tools lvcreate.c
Date: Sun, 26 Jul 2009 02:30:00 -0000	[thread overview]
Message-ID: <20090726023057.15665.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 02:30:57

Modified files:
	tools          : lvcreate.c 

Log message:
	Refactor _lvcreate - move *_ARG into _lvcreate_params and get 'cmd' from 'vg'.
	
	A couple simple refactorings of _lvcreate - should be no functional change.
	Move tags_ARG parsing into _lvcreate_params.  Also use lp->voriginsize
	instread of arg_count().  These refactorings make it easier to move the
	bulk of _lvcreate into the library.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.199&r2=1.200

--- LVM2/tools/lvcreate.c	2009/07/15 20:02:48	1.199
+++ LVM2/tools/lvcreate.c	2009/07/26 02:30:57	1.200
@@ -53,6 +53,7 @@
 
 	int pv_count;
 	char **pvs;
+	const char *tag;
 };
 
 static int _lvcreate_name_params(struct lvcreate_params *lp,
@@ -525,6 +526,12 @@
 		return 0;
 	}
 
+	if (arg_count(cmd, addtag_ARG) &&
+	    !(lp->tag = arg_str_value(cmd, addtag_ARG, NULL))) {
+		log_error("Failed to get tag");
+		return 0;
+	}
+
 	lp->pv_count = argc;
 	lp->pvs = argv;
 
@@ -593,14 +600,14 @@
 	return lv;
 }
 
-static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
+static int _lvcreate(struct volume_group *vg,
 		     struct lvcreate_params *lp)
 {
+	struct cmd_context *cmd = vg->cmd;
 	uint32_t size_rest;
 	uint32_t status = 0;
 	struct logical_volume *lv, *org = NULL;
 	struct dm_list *pvh;
-	const char *tag = NULL;
 	int origin_active = 0;
 	char lv_name_buf[128];
 	const char *lv_name;
@@ -722,7 +729,7 @@
 		/* Must zero cow */
 		status |= LVM_WRITE;
 
-		if (arg_count(cmd, virtualsize_ARG))
+		if (lp->voriginsize)
 			origin_active = 1;
 		else {
 
@@ -806,12 +813,7 @@
 		lv_name = &lv_name_buf[0];
 	}
 
-	if (arg_count(cmd, addtag_ARG)) {
-		if (!(tag = arg_str_value(cmd, addtag_ARG, NULL))) {
-			log_error("Failed to get tag");
-			return 0;
-		}
-
+	if (lp->tag) {
 		if (!(vg->fid->fmt->features & FMT_TAGS)) {
 			log_error("Volume group %s does not support tags",
 				  vg->name);
@@ -846,9 +848,9 @@
 			    lv->minor);
 	}
 
-	if (tag && !str_list_add(cmd->mem, &lv->tags, tag)) {
+	if (lp->tag && !str_list_add(cmd->mem, &lv->tags, lp->tag)) {
 		log_error("Failed to add tag %s to %s/%s",
-			  tag, lv->vg->name, lv->name);
+			  lp->tag, lv->vg->name, lv->name);
 		return 0;
 	}
 
@@ -1000,7 +1002,7 @@
 		return ECMD_FAILED;
 	}
 
-	if (!_lvcreate(cmd, vg, &lp))
+	if (!_lvcreate(vg, &lp))
 		r = ECMD_FAILED;
 
 	unlock_and_release_vg(cmd, vg, lp.vg_name);


             reply	other threads:[~2009-07-26  2:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-26  2:30 wysochanski [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-03-02 20:18 zkabelac
2012-02-01  1:54 agk
2011-11-10 12:40 zkabelac
2011-11-10 12:39 zkabelac
2011-09-27 12:37 agk
2011-09-07  9:25 zkabelac
2011-09-06 15:35 agk
2011-03-25 21:56 jbrassow
2010-10-25 12:05 zkabelac
2010-05-11 21:40 jbrassow
2009-07-26  2:32 wysochanski
2009-07-26  2:32 wysochanski
2009-07-26  2:32 wysochanski
2009-07-26  2:31 wysochanski
2009-07-26  2:31 wysochanski
2009-06-06 22:06 mbroz
2009-05-27 13:07 agk
2009-04-26  8:12 prajnoha
2008-07-17 15:19 wysochanski
2008-01-16 15:26 agk
2007-10-01 15:01 wysochanski
2007-09-24 13:29 wysochanski
2006-10-16 16:47 agk
2005-11-12 22:00 agk
2005-10-28 14:38 agk
2005-09-30 22:20 agk

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=20090726023057.15665.qmail@sourceware.org \
    --to=wysochanski@sourceware.org \
    --cc=lvm-devel@redhat.com \
    --cc=lvm2-cvs@sourceware.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).