Project

General

Profile

Bug #4062 » leaks_share.c

Marcel Telka, 2013-08-20 03:02 PM

 
1

    
2
#include <libzfs.h>
3

    
4
static void printerr(libzfs_handle_t *hlib, const char *msg)
5
{
6
    printf("%s: error=%d\n%s\n%s\n",
7
            msg,
8
            libzfs_errno(hlib),
9
            libzfs_error_description(hlib),
10
            libzfs_error_action(hlib));
11
}
12

    
13

    
14
int main(int argc, char *argv[])
15
{
16
    const char *dataset;
17
    libzfs_handle_t *hlib;
18
    zfs_handle_t *hzfs;
19

    
20
    if (argc != 2) {
21
        printf("usage: leaks_share <dataset>\n");
22
        return 1;
23
    }
24

    
25
    dataset = argv[1];
26

    
27
    hlib = libzfs_init();
28
    if (zfs_create(hlib, dataset, ZFS_TYPE_FILESYSTEM, NULL) == 0) {
29
        printf("create %s ok\n", dataset);
30
        hzfs = zfs_open(hlib, dataset, ZFS_TYPE_FILESYSTEM);
31
        if (hzfs) {
32
            printf("open %s ok\n", dataset);
33
            if (zfs_prop_set(hzfs, "sharenfs", "on") == 0) {
34
                printf("share %s ok\n", dataset);
35
            } else {
36
                printerr(hlib, "zfs_open()");
37
            }
38
            zfs_close(hzfs);
39
        } else {
40
            printerr(hlib, "zfs_open()");
41
        }
42
    } else {
43
        printerr(hlib, "zfs_create()");
44
    }
45

    
46
    printf("job done, sleeping...\n");
47
    sleep(10);
48

    
49
    libzfs_fini(hlib);
50

    
51
    return 0;
52
}
(2-2/2)