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;
42 for (i
= 1; i
< ac
- 1; i
++) {
43 if (strcmp(av
[i
], "-s") == 0) {
44 if (i
+ 1 >= ac
- 1) {
45 fprintf(stderr
, "-s requires an arg");
49 if (strlen(name
) >= BTRFS_VOL_NAME_MAX
) {
50 fprintf(stderr
, "snapshot name is too long\n");
53 command
= BTRFS_IOC_SNAP_CREATE
;
55 if (strcmp(av
[i
], "-a") == 0) {
56 if (i
+ 1 >= ac
- 1) {
57 fprintf(stderr
, "-a requires an arg");
61 if (strlen(name
) >= BTRFS_VOL_NAME_MAX
) {
62 fprintf(stderr
, "device name is too long\n");
65 command
= BTRFS_IOC_ADD_DISK
;
69 fprintf(stderr
, "no valid commands given\n");
73 printf("fname is %s\n", fname
);
74 ret
= stat(fname
, &st
);
79 if (S_ISDIR(st
.st_mode
)) {
80 dirstream
= opendir(fname
);
85 fd
= dirfd(dirstream
);
87 fd
= open(fname
, O_RDWR
);
92 strcpy(args
.name
, name
);
93 ret
= ioctl(fd
, command
, &args
);
94 printf("ioctl returns %d\n", ret
);