HOWTO: create a thick logical snapshot from C

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I want to create the snapshot like this command, but from C.

lvcreate -s -c 512k -n snap -L 1G testvg/lvol1

Just to try; I compiled this program, but it can't resolve the references
-------
#include "lvm2app.h"

int snaplv(char *vgname, char *lvname)
{
        int rc;
        lvm_t handle;
        vg_t vg;
        lv_t lv;
        lv_t lvsnap;
        char msg[200];
        char *snap_name="snap";
        struct lvm_lv_create_params *lvcp = NULL;
        uint64_t max_snap_size = 1*1024*1024*1024;

        handle = lvm_init(NULL);

        if(!handle)
                return -1;

        vg = lvm_vg_open(handle, vgname, "r", 0);
        if(!vg && lvm_errno(handle))
        {
                lvm_quit(handle);
                return -1;
        }

        lv = lvm_lv_from_name(vg, lvname);
        if(!lv)
        {
                lvm_vg_close(vg);
                lvm_quit(handle);

                return -1;
        }

        lvsnap = lvm_lv_snapshot(lv, strdup(snap_name), max_snap_size);
        lvm_vg_close(vg);
        lvm_quit(handle);

        return 0;
}

void main(void)
{
        snaplv("testvg","test");
}
--------------------------------
Compiling gives error

[root@centos64 ~]# gcc -llvm2app snaplv.c
snaplv.c: In function ‘snaplv’:
snaplv.c:36: warning: assignment makes pointer from integer without a cast
/tmp/ccvgg1K0.o: In function `snaplv':
snaplv.c:(.text+0x105): undefined reference to `lvm_lv_snapshot'
collect2: ld returned 1 exit status
[root@centos64 ~]#

-----------------------------

Can anyone share an idea how to do this from C; without using system()

Regards Tomas
_______________________________________________
linux-lvm mailing list
linux-lvm@redhat.com
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

[Index of Archives]     [Gluster Users]     [Kernel Development]     [Linux Clusters]     [Device Mapper]     [Security]     [Bugtraq]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]

  Powered by Linux