All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH 11/14] Add lvm_vg_get_property() generic vg property function.
Date: Tue, 12 Oct 2010 10:40:24 +0200	[thread overview]
Message-ID: <4CB41EF8.9010706@redhat.com> (raw)
In-Reply-To: <1286810078-25769-12-git-send-email-dwysocha@redhat.com>

Dne 11.10.2010 17:14, Dave Wysochanski napsal(a):
> Add a generic VG property function to lvm2app.  Call the internal library
> vg_get_property() function.  Strings are dup'd internally.
> 
> Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
> ---
>  liblvm/lvm2app.h |   42 ++++++++++++++++++++++++++++++++++++++++++
>  liblvm/lvm_vg.c  |   19 +++++++++++++++++++
>  2 files changed, 61 insertions(+), 0 deletions(-)
> 
> diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h
> index 47d3417..b5008c1 100644
> --- a/liblvm/lvm2app.h
> +++ b/liblvm/lvm2app.h
> @@ -168,6 +168,22 @@ typedef struct lvm_str_list {
>  	const char *str;
>  } lvm_str_list_t;
>  
> +/**
> + * Property Value
> + *
> + * This structure defines a single LVM property value for an LVM object.
> + * The structures are returned by functions such as
> + * lvm_vg_get_property() and lvm_vg_set_property().
> + */
> +typedef struct lvm_property_value {
> +	unsigned is_writeable;
> +	unsigned is_string;
> +	union {
> +		char *s_val;

are we going to support return of modifiable strings - or const would fit here
?  (IMHO I still think, we are duplicating way too many things on return...)

> +		uint64_t n_val;
> +	} v;
> +} lvm_property_value_t;
> +


> +int lvm_vg_get_property(const vg_t vg, const char *name,
> +			struct lvm_property_value *value)
> +{
> +	struct lvm_property_type prop;
> +
> +	strncpy(prop.id, name, LVM_PROPERTY_NAME_LEN);

Hmmm why doing a copy here instead of passing/assigning  'name' ptr somewhere?


> +	if (!vg_get_property(vg, &prop))
> +		return -1;

As this is public interface - I'd add check for valid 'value' pointer.

if (value) return 0;   // might indicate, property exists and is queriable,
but user is not interested in the result.


> +	value->is_writeable = prop.is_writeable;
> +	value->is_string = prop.is_string;
> +	if (value->is_string)
> +		value->v.s_val = prop.v.s_val;
> +	else
> +		value->v.n_val = prop.v.n_val;
> +	return 0;
> +}
> +
>  struct dm_list *lvm_list_vg_names(lvm_t libh)
>  {
>  	return get_vgnames((struct cmd_context *)libh, 0);


Zdenek



  reply	other threads:[~2010-10-12  8:40 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-11 15:14 [PATCH 00/14] Add lvm lv properties and lvm2app interfaces for pv/vg/lv Dave Wysochanski
2010-10-11 15:14 ` [PATCH 01/14] Add some lv 'get' functions that require no refactoring Dave Wysochanski
2010-10-11 18:00   ` Petr Rockai
2010-10-11 15:14 ` [PATCH 02/14] Refactor and add code for (lv) 'lv_path' get function Dave Wysochanski
2010-10-11 18:09   ` Petr Rockai
2010-10-12 14:29     ` Dave Wysochanski
2010-10-12 15:52       ` Petr Rockai
2010-10-11 15:14 ` [PATCH 03/14] Refactor and add code for (lv) 'origin_size' " Dave Wysochanski
2010-10-11 18:13   ` Petr Rockai
2010-10-12 14:22     ` Dave Wysochanski
2010-10-11 15:14 ` [PATCH 04/14] Refactor and add code for (lv) 'move_pv' " Dave Wysochanski
2010-10-11 18:21   ` Petr Rockai
2010-10-12 14:52     ` Dave Wysochanski
2010-10-11 15:14 ` [PATCH 05/14] Refactor and add code for (lv) 'convert_lv' " Dave Wysochanski
2010-10-11 18:25   ` Petr Rockai
2010-10-12 15:14     ` Dave Wysochanski
2010-10-12 15:55       ` Petr Rockai
2010-10-12 16:09         ` Dave Wysochanski
2010-10-11 15:14 ` [PATCH 06/14] Refactor and add code for (lv) 'lv_kernel_{major|minor}' get functions Dave Wysochanski
2010-10-11 18:27   ` Petr Rockai
2010-10-11 15:14 ` [PATCH 07/14] Refactor and add code for (lv) 'mirror_log' get function Dave Wysochanski
2010-10-11 18:29   ` Petr Rockai
2010-10-12 15:28     ` Dave Wysochanski
2010-10-11 15:14 ` [PATCH 08/14] Refactor and add code for (lv) 'modules' " Dave Wysochanski
2010-10-11 15:14 ` [PATCH 09/14] Refactor and add code for (lv) 'lv_name' " Dave Wysochanski
2010-10-11 18:36   ` Petr Rockai
2010-10-12 15:43     ` Dave Wysochanski
2010-10-11 15:14 ` [PATCH 10/14] Refactor and add code for (lv) 'lv_origin' " Dave Wysochanski
2010-10-11 15:14 ` [PATCH 11/14] Add lvm_vg_get_property() generic vg property function Dave Wysochanski
2010-10-12  8:40   ` Zdenek Kabelac [this message]
2010-10-12 10:51     ` Petr Rockai
2010-10-12 11:05     ` Petr Rockai
2010-10-15 14:18       ` Dave Wysochanski
2010-10-12 11:04   ` Petr Rockai
2010-10-11 15:14 ` [PATCH 12/14] Add lvm_pv_get_property() generic function to obtain value of any pv property Dave Wysochanski
2010-10-11 15:14 ` [PATCH 13/14] Add lvm_lv_get_property() generic function to obtain value of any lv property Dave Wysochanski
2010-10-11 15:14 ` [PATCH 14/14] Add interactive tests for lvm_{pv|vg|lv}_get_property() Dave Wysochanski

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=4CB41EF8.9010706@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.