2 * Copyright (C) 2007 Oracle. All rights reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 021110-1307, USA.
20 #include <sys/ioctl.h>
21 #include <sys/mount.h>
26 #include <sys/types.h>
31 #include "kerncompat.h"
34 #define BLKGETSIZE64 0
35 #define BTRFS_IOC_SNAP_CREATE 0
36 #define BTRFS_IOC_ADD_DISK 0
37 #define BTRFS_VOL_NAME_MAX 255
38 struct btrfs_ioctl_vol_args
{ char name
[BTRFS_VOL_NAME_MAX
]; };
39 static inline int ioctl(int fd
, int define
, void *arg
) { return 0; }
42 void print_usage(void)
44 printf("usage: btrfsctl [ -s snapshot_name ] dir\n");
48 int main(int ac
, char **av
)
53 struct btrfs_ioctl_vol_args args
;
58 unsigned long command
= 0;
61 for (i
= 1; i
< ac
- 1; i
++) {
62 if (strcmp(av
[i
], "-s") == 0) {
63 if (i
+ 1 >= ac
- 1) {
64 fprintf(stderr
, "-s requires an arg");
69 if (len
== 0 || len
>= BTRFS_VOL_NAME_MAX
) {
71 "snapshot name zero length or too long\n");
74 if (strchr(name
, '/')) {
76 "error: / not allowed in names\n");
79 command
= BTRFS_IOC_SNAP_CREATE
;
83 fprintf(stderr
, "no valid commands given\n");
87 ret
= stat(fname
, &st
);
92 if (S_ISDIR(st
.st_mode
)) {
93 dirstream
= opendir(fname
);
98 fd
= dirfd(dirstream
);
100 fd
= open(fname
, O_RDWR
);
105 strcpy(args
.name
, name
);
106 ret
= ioctl(fd
, command
, &args
);
107 printf("ioctl returns %d\n", ret
);