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/liblvm .exported_symbols lvm.h lvm_vg.c Date: Thu, 23 Jul 2009 23:39:00 -0000 [thread overview] Message-ID: <20090723233903.20533.qmail@sourceware.org> (raw) CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2009-07-23 23:39:02 Modified files: liblvm : .exported_symbols lvm.h lvm_vg.c Log message: Add lvm_vg_list_{pvs|lvs} - return lists of pv/lv handles for a vg. - Use vgmem pool to allocate a list of lvm_*_list structs - Allocate a new list each call (list may have changed since last call) - Add to liblvm's exported symbols Signed-off-by: Dave Wysochanski <dwysocha@redhat.com> Acked-by: Thomas Woerner <twoerner@redhat.com> Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5 --- LVM2/liblvm/.exported_symbols 2009/07/22 22:24:16 1.4 +++ LVM2/liblvm/.exported_symbols 2009/07/23 23:39:02 1.5 @@ -10,3 +10,5 @@ lvm_vg_remove lvm_errno lvm_errmsg +lvm_vg_list_pvs +lvm_vg_list_lvs --- LVM2/liblvm/lvm.h 2009/07/23 23:37:24 1.8 +++ LVM2/liblvm/lvm.h 2009/07/23 23:39:02 1.9 @@ -44,6 +44,13 @@ lv_t *lv; } lv_list_t; +/** + * Return a list of LV handles for a given VG handle. + * + * \return A list of lv_list_t structures containing lv handles for this vg. + * If no LVs exist on the given VG, NULL is returned. + */ +struct dm_list *lvm_vg_list_lvs(vg_t *vg); struct lvm; /* internal data */ @@ -225,4 +232,12 @@ vg_t *lvm_vg_open(lvm_t libh, const char *vgname, const char *mode, uint32_t flags); +/** + * Return a list of PV handles for a given VG handle. + * + * \return A list of pv_list_t structures containing pv handles for this vg. + * If no PVs exist on the given VG, NULL is returned. + */ +struct dm_list *lvm_vg_list_pvs(vg_t *vg); + #endif /* _LIB_LVM_H */ --- LVM2/liblvm/lvm_vg.c 2009/07/23 01:20:22 1.4 +++ LVM2/liblvm/lvm_vg.c 2009/07/23 23:39:02 1.5 @@ -114,3 +114,55 @@ return vg; } + +struct dm_list *lvm_vg_list_pvs(vg_t *vg) +{ + struct dm_list *list; + pv_list_t *pvs; + struct pv_list *pvl; + + if (dm_list_empty(&vg->pvs)) + return NULL; + + if (!(list = dm_pool_zalloc(vg->vgmem, sizeof(*list)))) { + log_error("Memory allocation fail for dm_list.\n"); + return NULL; + } + dm_list_init(list); + + dm_list_iterate_items(pvl, &vg->pvs) { + if (!(pvs = dm_pool_zalloc(vg->vgmem, sizeof(*pvs)))) { + log_error("Memory allocation fail for lvm_pv_list.\n"); + return NULL; + } + pvs->pv = pvl->pv; + dm_list_add(list, &pvs->list); + } + return list; +} + +struct dm_list *lvm_vg_list_lvs(vg_t *vg) +{ + struct dm_list *list; + lv_list_t *lvs; + struct lv_list *lvl; + + if (dm_list_empty(&vg->lvs)) + return NULL; + + if (!(list = dm_pool_zalloc(vg->vgmem, sizeof(*list)))) { + log_error("Memory allocation fail for dm_list.\n"); + return NULL; + } + dm_list_init(list); + + dm_list_iterate_items(lvl, &vg->lvs) { + if (!(lvs = dm_pool_zalloc(vg->vgmem, sizeof(*lvs)))) { + log_error("Memory allocation fail for lvm_lv_list.\n"); + return NULL; + } + lvs->lv = lvl->lv; + dm_list_add(list, &lvs->list); + } + return list; +}
next reply other threads:[~2009-07-23 23:39 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-07-23 23:39 wysochanski [this message] -- strict thread matches above, loose matches on Subject: below -- 2009-07-27 17:44 wysochanski 2009-07-26 16:05 wysochanski 2009-07-24 12:48 wysochanski 2009-07-24 12:47 wysochanski 2009-07-22 22:24 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=20090723233903.20533.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: linkBe 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).