Btrfs-progs: make printing subvol extensible to newer layouts
[platform/upstream/btrfs-progs.git] / cmds-subvolume.c
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public
4  * License v2 as published by the Free Software Foundation.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9  * General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the
13  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
14  * Boston, MA 021110-1307, USA.
15  */
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <unistd.h>
21 #include <sys/ioctl.h>
22 #include <errno.h>
23 #include <sys/stat.h>
24 #include <libgen.h>
25 #include <limits.h>
26 #include <getopt.h>
27
28 #include "kerncompat.h"
29 #include "ioctl.h"
30 #include "qgroup.h"
31
32 #include "ctree.h"
33 #include "commands.h"
34 #include "btrfs-list.h"
35 #include "utils.h"
36
37 static const char * const subvolume_cmd_group_usage[] = {
38         "btrfs subvolume <command> <args>",
39         NULL
40 };
41
42 /*
43  * test if path is a directory
44  * this function return
45  * 0-> path exists but it is not a directory
46  * 1-> path exists and it is  a directory
47  * -1 -> path is unaccessible
48  */
49 static int test_isdir(char *path)
50 {
51         struct stat     st;
52         int             res;
53
54         res = stat(path, &st);
55         if(res < 0 )
56                 return -1;
57
58         return S_ISDIR(st.st_mode);
59 }
60
61 static const char * const cmd_subvol_create_usage[] = {
62         "btrfs subvolume create [<dest>/]<name>",
63         "Create a subvolume",
64         "Create a subvolume <name> in <dest>.  If <dest> is not given",
65         "subvolume <name> will be created in the current directory.",
66         NULL
67 };
68
69 static int cmd_subvol_create(int argc, char **argv)
70 {
71         int     res, fddst, len, e;
72         char    *newname;
73         char    *dstdir;
74         char    *dst;
75         struct btrfs_qgroup_inherit *inherit = NULL;
76
77         optind = 1;
78         while (1) {
79                 int c = getopt(argc, argv, "c:i:r");
80                 if (c < 0)
81                         break;
82
83                 switch (c) {
84                 case 'c':
85                         res = qgroup_inherit_add_copy(&inherit, optarg, 0);
86                         if (res)
87                                 return res;
88                         break;
89                 case 'i':
90                         res = qgroup_inherit_add_group(&inherit, optarg);
91                         if (res)
92                                 return res;
93                         break;
94                 default:
95                         usage(cmd_subvol_create_usage);
96                 }
97         }
98
99         if (check_argc_exact(argc - optind, 1))
100                 usage(cmd_subvol_create_usage);
101
102         dst = argv[optind];
103
104         res = test_isdir(dst);
105         if(res >= 0 ){
106                 fprintf(stderr, "ERROR: '%s' exists\n", dst);
107                 return 12;
108         }
109
110         newname = strdup(dst);
111         newname = basename(newname);
112         dstdir = strdup(dst);
113         dstdir = dirname(dstdir);
114
115         if( !strcmp(newname,".") || !strcmp(newname,"..") ||
116              strchr(newname, '/') ){
117                 fprintf(stderr, "ERROR: uncorrect subvolume name ('%s')\n",
118                         newname);
119                 return 14;
120         }
121
122         len = strlen(newname);
123         if (len == 0 || len >= BTRFS_VOL_NAME_MAX) {
124                 fprintf(stderr, "ERROR: subvolume name too long ('%s)\n",
125                         newname);
126                 return 14;
127         }
128
129         fddst = open_file_or_dir(dstdir);
130         if (fddst < 0) {
131                 fprintf(stderr, "ERROR: can't access to '%s'\n", dstdir);
132                 return 12;
133         }
134
135         printf("Create subvolume '%s/%s'\n", dstdir, newname);
136         if (inherit) {
137                 struct btrfs_ioctl_vol_args_v2  args;
138
139                 memset(&args, 0, sizeof(args));
140                 strncpy(args.name, newname, BTRFS_SUBVOL_NAME_MAX);
141                 args.name[BTRFS_SUBVOL_NAME_MAX-1] = 0;
142                 args.flags |= BTRFS_SUBVOL_QGROUP_INHERIT;
143                 args.size = qgroup_inherit_size(inherit);
144                 args.qgroup_inherit = inherit;
145
146                 res = ioctl(fddst, BTRFS_IOC_SUBVOL_CREATE_V2, &args);
147         } else {
148                 struct btrfs_ioctl_vol_args     args;
149
150                 memset(&args, 0, sizeof(args));
151                 strncpy(args.name, newname, BTRFS_SUBVOL_NAME_MAX);
152                 args.name[BTRFS_SUBVOL_NAME_MAX-1] = 0;
153
154                 res = ioctl(fddst, BTRFS_IOC_SUBVOL_CREATE, &args);
155         }
156
157         e = errno;
158
159         close(fddst);
160
161         if(res < 0 ){
162                 fprintf( stderr, "ERROR: cannot create subvolume - %s\n",
163                         strerror(e));
164                 return 11;
165         }
166         free(inherit);
167
168         return 0;
169 }
170
171 /*
172  * test if path is a subvolume:
173  * this function return
174  * 0-> path exists but it is not a subvolume
175  * 1-> path exists and it is  a subvolume
176  * -1 -> path is unaccessible
177  */
178 int test_issubvolume(char *path)
179 {
180         struct stat     st;
181         int             res;
182
183         res = stat(path, &st);
184         if(res < 0 )
185                 return -1;
186
187         return (st.st_ino == 256) && S_ISDIR(st.st_mode);
188 }
189
190 static const char * const cmd_subvol_delete_usage[] = {
191         "btrfs subvolume delete <subvolume> [<subvolume>...]",
192         "Delete subvolume(s)",
193         NULL
194 };
195
196 static int cmd_subvol_delete(int argc, char **argv)
197 {
198         int     res, fd, len, e, cnt = 1, ret = 0;
199         struct btrfs_ioctl_vol_args     args;
200         char    *dname, *vname, *cpath;
201         char    *path;
202
203         if (argc < 2)
204                 usage(cmd_subvol_delete_usage);
205
206 again:
207         path = argv[cnt];
208
209         res = test_issubvolume(path);
210         if(res<0){
211                 fprintf(stderr, "ERROR: error accessing '%s'\n", path);
212                 ret = 12;
213                 goto out;
214         }
215         if(!res){
216                 fprintf(stderr, "ERROR: '%s' is not a subvolume\n", path);
217                 ret = 13;
218                 goto out;
219         }
220
221         cpath = realpath(path, 0);
222         dname = strdup(cpath);
223         dname = dirname(dname);
224         vname = strdup(cpath);
225         vname = basename(vname);
226         free(cpath);
227
228         if( !strcmp(vname,".") || !strcmp(vname,"..") ||
229              strchr(vname, '/') ){
230                 fprintf(stderr, "ERROR: incorrect subvolume name ('%s')\n",
231                         vname);
232                 ret = 14;
233                 goto out;
234         }
235
236         len = strlen(vname);
237         if (len == 0 || len >= BTRFS_VOL_NAME_MAX) {
238                 fprintf(stderr, "ERROR: snapshot name too long ('%s)\n",
239                         vname);
240                 ret = 14;
241                 goto out;
242         }
243
244         fd = open_file_or_dir(dname);
245         if (fd < 0) {
246                 close(fd);
247                 fprintf(stderr, "ERROR: can't access to '%s'\n", dname);
248                 ret = 12;
249                 goto out;
250         }
251
252         printf("Delete subvolume '%s/%s'\n", dname, vname);
253         strncpy(args.name, vname, BTRFS_PATH_NAME_MAX);
254         args.name[BTRFS_PATH_NAME_MAX-1] = 0;
255         res = ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &args);
256         e = errno;
257
258         close(fd);
259
260         if(res < 0 ){
261                 fprintf( stderr, "ERROR: cannot delete '%s/%s' - %s\n",
262                         dname, vname, strerror(e));
263                 ret = 11;
264                 goto out;
265         }
266
267 out:
268         cnt++;
269         if (cnt < argc)
270                 goto again;
271
272         return ret;
273 }
274
275 static const char * const cmd_subvol_list_usage[] = {
276         "btrfs subvolume list [-aopurts] [-g [+|-]value] [-c [+|-]value] "
277         "[--sort=gen,ogen,rootid,path] <path>",
278         "List subvolumes (and snapshots)",
279         "",
280         "-p           print parent ID",
281         "-a           print all the subvolumes in the filesystem and",
282         "             distinguish absolute and relative path with respect",
283         "             to the given <path>",
284         "-o           print only subvolumes bellow specified path",
285         "-u           print the uuid of subvolumes (and snapshots)",
286         "-q           print the parent uuid of the snapshots",
287         "-t           print the result as a table",
288         "-s           list snapshots only in the filesystem",
289         "-r           list readonly subvolumes (including snapshots)",
290         "-g [+|-]value",
291         "             filter the subvolumes by generation",
292         "             (+value: >= value; -value: <= value; value: = value)",
293         "-c [+|-]value",
294         "             filter the subvolumes by ogeneration",
295         "             (+value: >= value; -value: <= value; value: = value)",
296         "--sort=gen,ogen,rootid,path",
297         "             list the subvolume in order of gen, ogen, rootid or path",
298         "             you also can add '+' or '-' in front of each items.",
299         "             (+:ascending, -:descending, ascending default)",
300         NULL,
301 };
302
303 static int cmd_subvol_list(int argc, char **argv)
304 {
305         struct btrfs_list_filter_set *filter_set;
306         struct btrfs_list_comparer_set *comparer_set;
307         u64 flags = 0;
308         int fd;
309         u64 top_id;
310         int ret;
311         int c;
312         char *subvol;
313         int is_tab_result = 0;
314         int is_list_all = 0;
315         int is_only_in_path = 0;
316         struct option long_options[] = {
317                 {"sort", 1, NULL, 'S'},
318                 {0, 0, 0, 0}
319         };
320
321         filter_set = btrfs_list_alloc_filter_set();
322         comparer_set = btrfs_list_alloc_comparer_set();
323
324         optind = 1;
325         while(1) {
326                 c = getopt_long(argc, argv,
327                                     "aopqsurg:c:t", long_options, NULL);
328                 if (c < 0)
329                         break;
330
331                 switch(c) {
332                 case 'p':
333                         btrfs_list_setup_print_column(BTRFS_LIST_PARENT);
334                         break;
335                 case 'a':
336                         is_list_all = 1;
337                         break;
338                 case 'o':
339                         is_only_in_path = 1;
340                         break;
341                 case 't':
342                         is_tab_result = 1;
343                         break;
344                 case 's':
345                         btrfs_list_setup_filter(&filter_set,
346                                                 BTRFS_LIST_FILTER_SNAPSHOT_ONLY,
347                                                 0);
348                         btrfs_list_setup_print_column(BTRFS_LIST_OGENERATION);
349                         btrfs_list_setup_print_column(BTRFS_LIST_OTIME);
350
351                 case 'u':
352                         btrfs_list_setup_print_column(BTRFS_LIST_UUID);
353                         break;
354                 case 'q':
355                         btrfs_list_setup_print_column(BTRFS_LIST_PUUID);
356                         break;
357                 case 'r':
358                         flags |= BTRFS_ROOT_SUBVOL_RDONLY;
359                         break;
360                 case 'g':
361                         btrfs_list_setup_print_column(BTRFS_LIST_GENERATION);
362                         ret = btrfs_list_parse_filter_string(optarg,
363                                                         &filter_set,
364                                                         BTRFS_LIST_FILTER_GEN);
365                         if (ret)
366                                 usage(cmd_subvol_list_usage);
367                         break;
368
369                 case 'c':
370                         btrfs_list_setup_print_column(BTRFS_LIST_OGENERATION);
371                         ret = btrfs_list_parse_filter_string(optarg,
372                                                         &filter_set,
373                                                         BTRFS_LIST_FILTER_CGEN);
374                         if (ret)
375                                 usage(cmd_subvol_list_usage);
376                         break;
377                 case 'S':
378                         ret = btrfs_list_parse_sort_string(optarg,
379                                                            &comparer_set);
380                         if (ret)
381                                 usage(cmd_subvol_list_usage);
382                         break;
383
384                 default:
385                         usage(cmd_subvol_list_usage);
386                 }
387         }
388
389         if (flags)
390                 btrfs_list_setup_filter(&filter_set, BTRFS_LIST_FILTER_FLAGS,
391                                         flags);
392
393         if (check_argc_exact(argc - optind, 1))
394                 usage(cmd_subvol_list_usage);
395
396         subvol = argv[optind];
397
398         ret = test_issubvolume(subvol);
399         if (ret < 0) {
400                 fprintf(stderr, "ERROR: error accessing '%s'\n", subvol);
401                 return 12;
402         }
403         if (!ret) {
404                 fprintf(stderr, "ERROR: '%s' is not a subvolume\n", subvol);
405                 return 13;
406         }
407
408         fd = open_file_or_dir(subvol);
409         if (fd < 0) {
410                 fprintf(stderr, "ERROR: can't access '%s'\n", subvol);
411                 return 12;
412         }
413
414         top_id = btrfs_list_get_path_rootid(fd);
415
416         if (is_list_all)
417                 btrfs_list_setup_filter(&filter_set,
418                                         BTRFS_LIST_FILTER_FULL_PATH,
419                                         top_id);
420         else if (is_only_in_path)
421                 btrfs_list_setup_filter(&filter_set,
422                                         BTRFS_LIST_FILTER_TOPID_EQUAL,
423                                         top_id);
424
425         /* by default we shall print the following columns*/
426         btrfs_list_setup_print_column(BTRFS_LIST_OBJECTID);
427         btrfs_list_setup_print_column(BTRFS_LIST_GENERATION);
428         btrfs_list_setup_print_column(BTRFS_LIST_TOP_LEVEL);
429         btrfs_list_setup_print_column(BTRFS_LIST_PATH);
430
431         if (is_tab_result)
432                 ret = btrfs_list_subvols_print(fd, filter_set, comparer_set,
433                                 BTRFS_LIST_LAYOUT_TABLE,
434                                 !is_list_all && !is_only_in_path);
435         else
436                 ret = btrfs_list_subvols_print(fd, filter_set, comparer_set,
437                                 BTRFS_LIST_LAYOUT_DEFAULT,
438                                 !is_list_all && !is_only_in_path);
439         if (ret)
440                 return 19;
441         return 0;
442 }
443
444 static const char * const cmd_snapshot_usage[] = {
445         "btrfs subvolume snapshot [-r] <source> [<dest>/]<name>",
446         "Create a snapshot of the subvolume",
447         "Create a writable/readonly snapshot of the subvolume <source> with",
448         "the name <name> in the <dest> directory",
449         "",
450         "-r     create a readonly snapshot",
451         NULL
452 };
453
454 static int cmd_snapshot(int argc, char **argv)
455 {
456         char    *subvol, *dst;
457         int     res, fd, fddst, len, e, readonly = 0;
458         char    *newname;
459         char    *dstdir;
460         struct btrfs_ioctl_vol_args_v2  args;
461         struct btrfs_qgroup_inherit *inherit = NULL;
462
463         optind = 1;
464         memset(&args, 0, sizeof(args));
465         while (1) {
466                 int c = getopt(argc, argv, "c:i:r");
467                 if (c < 0)
468                         break;
469
470                 switch (c) {
471                 case 'c':
472                         res = qgroup_inherit_add_copy(&inherit, optarg, 0);
473                         if (res)
474                                 return res;
475                         break;
476                 case 'i':
477                         res = qgroup_inherit_add_group(&inherit, optarg);
478                         if (res)
479                                 return res;
480                         break;
481                 case 'r':
482                         readonly = 1;
483                         break;
484                 case 'x':
485                         res = qgroup_inherit_add_copy(&inherit, optarg, 1);
486                         if (res)
487                                 return res;
488                         break;
489                 default:
490                         usage(cmd_snapshot_usage);
491                 }
492         }
493
494         if (check_argc_exact(argc - optind, 2))
495                 usage(cmd_snapshot_usage);
496
497         subvol = argv[optind];
498         dst = argv[optind + 1];
499
500         res = test_issubvolume(subvol);
501         if(res<0){
502                 fprintf(stderr, "ERROR: error accessing '%s'\n", subvol);
503                 return 12;
504         }
505         if(!res){
506                 fprintf(stderr, "ERROR: '%s' is not a subvolume\n", subvol);
507                 return 13;
508         }
509
510         res = test_isdir(dst);
511         if(res == 0 ){
512                 fprintf(stderr, "ERROR: '%s' exists and it is not a directory\n", dst);
513                 return 12;
514         }
515
516         if(res>0){
517                 newname = strdup(subvol);
518                 newname = basename(newname);
519                 dstdir = dst;
520         }else{
521                 newname = strdup(dst);
522                 newname = basename(newname);
523                 dstdir = strdup(dst);
524                 dstdir = dirname(dstdir);
525         }
526
527         if( !strcmp(newname,".") || !strcmp(newname,"..") ||
528              strchr(newname, '/') ){
529                 fprintf(stderr, "ERROR: incorrect snapshot name ('%s')\n",
530                         newname);
531                 return 14;
532         }
533
534         len = strlen(newname);
535         if (len == 0 || len >= BTRFS_VOL_NAME_MAX) {
536                 fprintf(stderr, "ERROR: snapshot name too long ('%s)\n",
537                         newname);
538                 return 14;
539         }
540
541         fddst = open_file_or_dir(dstdir);
542         if (fddst < 0) {
543                 fprintf(stderr, "ERROR: can't access to '%s'\n", dstdir);
544                 return 12;
545         }
546
547         fd = open_file_or_dir(subvol);
548         if (fd < 0) {
549                 close(fddst);
550                 fprintf(stderr, "ERROR: can't access to '%s'\n", dstdir);
551                 return 12;
552         }
553
554         if (readonly) {
555                 args.flags |= BTRFS_SUBVOL_RDONLY;
556                 printf("Create a readonly snapshot of '%s' in '%s/%s'\n",
557                        subvol, dstdir, newname);
558         } else {
559                 printf("Create a snapshot of '%s' in '%s/%s'\n",
560                        subvol, dstdir, newname);
561         }
562
563         args.fd = fd;
564         if (inherit) {
565                 args.flags |= BTRFS_SUBVOL_QGROUP_INHERIT;
566                 args.size = qgroup_inherit_size(inherit);
567                 args.qgroup_inherit = inherit;
568         }
569         strncpy(args.name, newname, BTRFS_SUBVOL_NAME_MAX);
570         args.name[BTRFS_SUBVOL_NAME_MAX-1] = 0;
571         res = ioctl(fddst, BTRFS_IOC_SNAP_CREATE_V2, &args);
572         e = errno;
573
574         close(fd);
575         close(fddst);
576
577         if(res < 0 ){
578                 fprintf( stderr, "ERROR: cannot snapshot '%s' - %s\n",
579                         subvol, strerror(e));
580                 return 11;
581         }
582         free(inherit);
583
584         return 0;
585 }
586
587 static const char * const cmd_subvol_get_default_usage[] = {
588         "btrfs subvolume get-default <path>",
589         "Get the default subvolume of a filesystem",
590         NULL
591 };
592
593 static int cmd_subvol_get_default(int argc, char **argv)
594 {
595         int fd;
596         int ret;
597         char *subvol;
598         struct btrfs_list_filter_set *filter_set;
599         u64 default_id;
600
601         if (check_argc_exact(argc, 2))
602                 usage(cmd_subvol_get_default_usage);
603
604         subvol = argv[1];
605
606         ret = test_issubvolume(subvol);
607         if (ret < 0) {
608                 fprintf(stderr, "ERROR: error accessing '%s'\n", subvol);
609                 return 12;
610         }
611         if (!ret) {
612                 fprintf(stderr, "ERROR: '%s' is not a subvolume\n", subvol);
613                 return 13;
614         }
615
616         fd = open_file_or_dir(subvol);
617         if (fd < 0) {
618                 fprintf(stderr, "ERROR: can't access '%s'\n", subvol);
619                 return 12;
620         }
621
622         ret = btrfs_list_get_default_subvolume(fd, &default_id);
623         if (ret) {
624                 fprintf(stderr, "ERROR: can't perform the search - %s\n",
625                         strerror(errno));
626                 return ret;
627         }
628
629         if (default_id == 0) {
630                 fprintf(stderr, "ERROR: 'default' dir item not found\n");
631                 return ret;
632         }
633
634         /* no need to resolve roots if FS_TREE is default */
635         if (default_id == BTRFS_FS_TREE_OBJECTID) {
636                 printf("ID 5 (FS_TREE)\n");
637                 return ret;
638         }
639
640         filter_set = btrfs_list_alloc_filter_set();
641         btrfs_list_setup_filter(&filter_set, BTRFS_LIST_FILTER_ROOTID,
642                                 default_id);
643
644         /* by default we shall print the following columns*/
645         btrfs_list_setup_print_column(BTRFS_LIST_OBJECTID);
646         btrfs_list_setup_print_column(BTRFS_LIST_GENERATION);
647         btrfs_list_setup_print_column(BTRFS_LIST_TOP_LEVEL);
648         btrfs_list_setup_print_column(BTRFS_LIST_PATH);
649
650         ret = btrfs_list_subvols_print(fd, filter_set, NULL,
651                 BTRFS_LIST_LAYOUT_DEFAULT, 1);
652         if (ret)
653                 return 19;
654         return 0;
655 }
656
657 static const char * const cmd_subvol_set_default_usage[] = {
658         "btrfs subvolume set-default <subvolid> <path>",
659         "Set the default subvolume of a filesystem",
660         NULL
661 };
662
663 static int cmd_subvol_set_default(int argc, char **argv)
664 {
665         int     ret=0, fd, e;
666         u64     objectid;
667         char    *path;
668         char    *subvolid;
669
670         if (check_argc_exact(argc, 3))
671                 usage(cmd_subvol_set_default_usage);
672
673         subvolid = argv[1];
674         path = argv[2];
675
676         fd = open_file_or_dir(path);
677         if (fd < 0) {
678                 fprintf(stderr, "ERROR: can't access to '%s'\n", path);
679                 return 12;
680         }
681
682         objectid = (unsigned long long)strtoll(subvolid, NULL, 0);
683         if (errno == ERANGE) {
684                 fprintf(stderr, "ERROR: invalid tree id (%s)\n",subvolid);
685                 return 30;
686         }
687         ret = ioctl(fd, BTRFS_IOC_DEFAULT_SUBVOL, &objectid);
688         e = errno;
689         close(fd);
690         if( ret < 0 ){
691                 fprintf(stderr, "ERROR: unable to set a new default subvolume - %s\n",
692                         strerror(e));
693                 return 30;
694         }
695         return 0;
696 }
697
698 static const char * const cmd_find_new_usage[] = {
699         "btrfs subvolume find-new <path> <lastgen>",
700         "List the recently modified files in a filesystem",
701         NULL
702 };
703
704 static int cmd_find_new(int argc, char **argv)
705 {
706         int fd;
707         int ret;
708         char *subvol;
709         u64 last_gen;
710
711         if (check_argc_exact(argc, 3))
712                 usage(cmd_find_new_usage);
713
714         subvol = argv[1];
715         last_gen = atoll(argv[2]);
716
717         ret = test_issubvolume(subvol);
718         if (ret < 0) {
719                 fprintf(stderr, "ERROR: error accessing '%s'\n", subvol);
720                 return 12;
721         }
722         if (!ret) {
723                 fprintf(stderr, "ERROR: '%s' is not a subvolume\n", subvol);
724                 return 13;
725         }
726
727         fd = open_file_or_dir(subvol);
728         if (fd < 0) {
729                 fprintf(stderr, "ERROR: can't access '%s'\n", subvol);
730                 return 12;
731         }
732         ret = btrfs_list_find_updated_files(fd, 0, last_gen);
733         if (ret)
734                 return 19;
735         return 0;
736 }
737
738 const struct cmd_group subvolume_cmd_group = {
739         subvolume_cmd_group_usage, NULL, {
740                 { "create", cmd_subvol_create, cmd_subvol_create_usage, NULL, 0 },
741                 { "delete", cmd_subvol_delete, cmd_subvol_delete_usage, NULL, 0 },
742                 { "list", cmd_subvol_list, cmd_subvol_list_usage, NULL, 0 },
743                 { "snapshot", cmd_snapshot, cmd_snapshot_usage, NULL, 0 },
744                 { "get-default", cmd_subvol_get_default,
745                         cmd_subvol_get_default_usage, NULL, 0 },
746                 { "set-default", cmd_subvol_set_default,
747                         cmd_subvol_set_default_usage, NULL, 0 },
748                 { "find-new", cmd_find_new, cmd_find_new_usage, NULL, 0 },
749                 { 0, 0, 0, 0, 0 }
750         }
751 };
752
753 int cmd_subvolume(int argc, char **argv)
754 {
755         return handle_command_group(&subvolume_cmd_group, argc, argv);
756 }