From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18644 invoked by alias); 8 Aug 2007 18:00:38 -0000 Received: (qmail 18574 invoked by uid 9657); 8 Aug 2007 18:00:37 -0000 Date: Wed, 08 Aug 2007 18:00:00 -0000 Message-ID: <20070808180037.18571.qmail@sourceware.org> From: wysochanski@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2/lib/metadata lv_manip.c Mailing-List: contact lvm2-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: lvm2-cvs-owner@sourceware.org X-SW-Source: 2007-08/txt/msg00012.txt.bz2 CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2007-08-08 18:00:37 Modified files: lib/metadata : lv_manip.c Log message: Remove extra checks for sub LV renaming. Patch by Jun'ichi Nomura . Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122 --- LVM2/lib/metadata/lv_manip.c 2007/08/07 18:55:38 1.121 +++ LVM2/lib/metadata/lv_manip.c 2007/08/08 18:00:36 1.122 @@ -1491,25 +1491,7 @@ } /* - * Returns a pointer to LV name suffix. - * Returns NULL if the LV doesn't have suffix. - */ -static char *_sub_lv_name_suffix(const char *lvname) -{ - char *s; - - if ((s = strstr(lvname, "_mimage"))) - return s; - - if ((s = strstr(lvname, "_mlog"))) - return s; - - return NULL; -} - -/* * Rename sub LV. - * If a new name for the sub LV cannot be determined, 1 is returned. * 'lv_name_old' and 'lv_name_new' are old and new names of the main LV. */ static int _rename_sub_lv(struct cmd_context *cmd, @@ -1519,14 +1501,18 @@ char *suffix, *new_name; size_t len; - /* Rename only if the lv has known suffix */ - if (!(suffix = _sub_lv_name_suffix(lv->name))) - return 1; - - /* Make sure that lv->name is exactly a lv_name_old + suffix */ - len = suffix - lv->name; - if (strlen(lv_name_old) != len || strncmp(lv->name, lv_name_old, len)) - return 1; + /* + * A sub LV name starts with lv_name_old + '_'. + * The suffix follows lv_name_old and includes '_'. + */ + len = strlen(lv_name_old); + if (strncmp(lv->name, lv_name_old, len) || lv->name[len] != '_') { + log_error("Cannot rename \"%s\": name format not recognized " + "for internal LV \"%s\"", + lv_name_old, lv->name); + return 0; + } + suffix = lv->name + len; /* * Compose a new name for sub lv: