@@ -616,7 +616,7 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
616
616
static DEFINE_COMMAND_WITH_FLAGS (subvolume_delete , "delete ", CMD_DRY_RUN ) ;
617
617
618
618
static const char * const cmd_subvolume_snapshot_usage [] = {
619
- "btrfs subvolume snapshot [-r] [-i <qgroupid>] <subvolume> { <subdir>/<name> | <subdir> }" ,
619
+ "btrfs subvolume snapshot [-r|-R ] [-i <qgroupid>] <subvolume> { <subdir>/<name> | <subdir> }" ,
620
620
"" ,
621
621
"Create a snapshot of a <subvolume>. Call it <name> and place it in the <subdir>." ,
622
622
"(<subvolume> will look like a new sub-directory, but is actually a btrfs subvolume" ,
@@ -625,6 +625,7 @@ static const char * const cmd_subvolume_snapshot_usage[] = {
625
625
"When only <subdir> is given, the subvolume will be named the basename of <subvolume>." ,
626
626
"" ,
627
627
OPTLINE ("-r" , "make the new snapshot readonly" ),
628
+ OPTLINE ("-R|--recursive" , "recursively snapshot subvolumes beneath the source; this option cannot be combined with -r" ),
628
629
OPTLINE ("-i <qgroupid>" , "Add the new snapshot to a qgroup (a quota group). This option can be given multiple times." ),
629
630
HELPINFO_INSERT_GLOBALS ,
630
631
HELPINFO_INSERT_QUIET ,
@@ -642,7 +643,7 @@ static int cmd_subvolume_snapshot(const struct cmd_struct *cmd, int argc, char *
642
643
643
644
optind = 0 ;
644
645
while (1 ) {
645
- int c = getopt (argc , argv , "i:r " );
646
+ int c = getopt (argc , argv , "i:rR " );
646
647
if (c < 0 )
647
648
break ;
648
649
@@ -657,11 +658,21 @@ static int cmd_subvolume_snapshot(const struct cmd_struct *cmd, int argc, char *
657
658
case 'r' :
658
659
flags |= BTRFS_UTIL_CREATE_SNAPSHOT_READ_ONLY ;
659
660
break ;
661
+ case 'R' :
662
+ flags |= BTRFS_UTIL_CREATE_SNAPSHOT_RECURSIVE ;
663
+ break ;
660
664
default :
661
665
usage_unknown_option (cmd , argv );
662
666
}
663
667
}
664
668
669
+ if ((flags & BTRFS_UTIL_CREATE_SNAPSHOT_READ_ONLY ) &&
670
+ (flags & BTRFS_UTIL_CREATE_SNAPSHOT_RECURSIVE )) {
671
+ error ("-r and -R cannot be combined" );
672
+ retval = 1 ;
673
+ goto out ;
674
+ }
675
+
665
676
if (check_argc_exact (argc - optind , 2 )) {
666
677
retval = 1 ;
667
678
goto out ;
0 commit comments