~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to qa/btrfs/create_async_snap.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-07-16 09:56:24 UTC
  • mfrom: (0.3.11)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120716095624-azr2w4hbhei1rxmx
Tags: upstream-0.48
ImportĀ upstreamĀ versionĀ 0.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
#include <unistd.h>
 
3
#include <sys/types.h>
 
4
#include <sys/stat.h>
 
5
#include <fcntl.h>
 
6
#include <errno.h>
 
7
#include <stdio.h>
 
8
#include <sys/ioctl.h>
 
9
#include <string.h>
 
10
 
 
11
#include <linux/ioctl.h>
 
12
#include <linux/types.h>
 
13
#include "../../src/os/btrfs_ioctl.h"
 
14
 
 
15
struct btrfs_ioctl_vol_args_v2 va;
 
16
 
 
17
int main(int argc, char **argv)
 
18
{
 
19
        int fd;
 
20
        int r;
 
21
 
 
22
        if (argc != 3) {
 
23
                printf("usage: %s <source subvol> <name>\n", argv[0]);
 
24
                return 1;
 
25
        }
 
26
        printf("creating snap ./%s from %s\n", argv[2], argv[1]);
 
27
        fd = open(".", O_RDONLY);
 
28
        va.fd = open(argv[1], O_RDONLY);
 
29
        va.flags = BTRFS_SUBVOL_CREATE_ASYNC;
 
30
        strcpy(va.name, argv[2]);
 
31
        r = ioctl(fd, BTRFS_IOC_SNAP_CREATE_V2, (unsigned long long)&va);
 
32
        printf("result %d\n", r ? -errno:0);
 
33
        return r;
 
34
}