13 #include "kerncompat.h"
16 #define BLKGETSIZE64 0
17 #define BTRFS_IOC_SNAP_CREATE 0
18 #define BTRFS_IOC_ADD_DISK 0
19 #define BTRFS_VOL_NAME_MAX 255
20 struct btrfs_ioctl_vol_args
{ char name
[BTRFS_VOL_NAME_MAX
]; };
21 static inline int ioctl(int fd
, int define
, void *arg
) { return 0; }
24 void print_usage(void)
26 printf("usage: btrfsctl [ -s snapshot_name ] dir\n");
30 int main(int ac
, char **av
)
35 struct btrfs_ioctl_vol_args args
;
40 unsigned long command
= 0;
43 for (i
= 1; i
< ac
- 1; i
++) {
44 if (strcmp(av
[i
], "-s") == 0) {
45 if (i
+ 1 >= ac
- 1) {
46 fprintf(stderr
, "-s requires an arg");
51 if (len
== 0 || len
>= BTRFS_VOL_NAME_MAX
) {
53 "snapshot name zero length or too long\n");
56 if (strchr(name
, '/')) {
58 "error: / not allowed in names\n");
61 command
= BTRFS_IOC_SNAP_CREATE
;
65 fprintf(stderr
, "no valid commands given\n");
69 ret
= stat(fname
, &st
);
74 if (S_ISDIR(st
.st_mode
)) {
75 dirstream
= opendir(fname
);
80 fd
= dirfd(dirstream
);
82 fd
= open(fname
, O_RDWR
);
87 strcpy(args
.name
, name
);
88 ret
= ioctl(fd
, command
, &args
);
89 printf("ioctl returns %d\n", ret
);