From: Zdenek Kabelac <zkabelac@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH 4/7] Add _tag_copy() to allocate memory and copy a tag in {lv|vg}_change_tag()
Date: Wed, 17 Feb 2010 09:16:13 +0100 [thread overview]
Message-ID: <4B7BA5CD.9010104@redhat.com> (raw)
In-Reply-To: <1266349189-23166-5-git-send-email-dwysocha@redhat.com>
On 16.2.2010 20:39, Dave Wysochanski wrote:
> We need to allocate memory for the tag and copy the tag value before we
> add it to the list of tags. We could put this inside lvm2app since the
> tools keep their memory around until vg_write/vg_commit is called.
> Call _tag_copy() from {vg|lv}_change_tag(). We need to copy the tag passed
> in by the caller to ensure the memory until the {vg|lv} handle is released.
>
> Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
> ---
> lib/metadata/metadata.c | 22 ++++++++++++++++++++--
> 1 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
> index 2b8a1be..e0d63c3 100644
> --- a/lib/metadata/metadata.c
> +++ b/lib/metadata/metadata.c
> @@ -665,8 +665,22 @@ int vg_reduce(struct volume_group *vg, char *pv_name)
> return 0;
> }
>
> +static char *_tag_copy(struct dm_pool *p, const char *tag)
> +{
> + char *tag_new;
> +
> + /* FIXME: verify tag length */
> + if (!(tag_new = dm_pool_alloc(p, strlen(tag)))) {
strlen(tag) + 1
(for '\0')
But better way is to use directly dm_pool_strdup() - and avoid whole
_tag_copy() function.
> + log_error("Failed to alloc memory for tag %s.", tag);
> + return NULL;
> + }
> + strcpy(tag_new, tag);
> + return tag_new;
> +}
> +
prev parent reply other threads:[~2010-02-17 8:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-16 19:39 [PATCH 0/7] Add vg/lv tag addition/deletion to lvm2app Dave Wysochanski
2010-02-16 19:39 ` [PATCH 1/7] Refactor _vgchange_tag() to vg_change_tag() library function Dave Wysochanski
2010-02-16 19:39 ` [PATCH 2/7] Refactor vgcreate to call new vg_change_tag() function Dave Wysochanski
2010-02-16 19:39 ` [PATCH 3/7] Refactor lvchange_tag() to call lv_change_tag() library function Dave Wysochanski
2010-02-16 19:39 ` [PATCH 4/7] Add _tag_copy() to allocate memory and copy a tag in {lv|vg}_change_tag() Dave Wysochanski
2010-02-16 19:39 ` [PATCH 5/7] Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag() Dave Wysochanski
2010-02-16 19:39 ` [PATCH 6/7] Add lvm_lv_get_tags(), lvm_lv_add_tag(), and lvm_lv_remove_tag() Dave Wysochanski
2010-02-16 19:39 ` [PATCH 7/7] Update lvm2app interactive unit test for vg/lv tags Dave Wysochanski
2010-02-17 8:42 ` Zdenek Kabelac
2010-02-17 8:16 ` Zdenek Kabelac [this message]
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=4B7BA5CD.9010104@redhat.com \
--to=zkabelac@redhat.com \
--cc=lvm-devel@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.