@@ -616,7 +616,7 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
616616static DEFINE_COMMAND_WITH_FLAGS (subvolume_delete , "delete ", CMD_DRY_RUN ) ;
617617
618618static 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> }" ,
620620 "" ,
621621 "Create a snapshot of a <subvolume>. Call it <name> and place it in the <subdir>." ,
622622 "(<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[] = {
625625 "When only <subdir> is given, the subvolume will be named the basename of <subvolume>." ,
626626 "" ,
627627 OPTLINE ("-r" , "make the new snapshot readonly" ),
628+ OPTLINE ("-R" , "recursively snapshot subvolumes beneath the source; this option cannot be combined with -r" ),
628629 OPTLINE ("-i <qgroupid>" , "Add the new snapshot to a qgroup (a quota group). This option can be given multiple times." ),
629630 HELPINFO_INSERT_GLOBALS ,
630631 HELPINFO_INSERT_QUIET ,
@@ -642,7 +643,7 @@ static int cmd_subvolume_snapshot(const struct cmd_struct *cmd, int argc, char *
642643
643644 optind = 0 ;
644645 while (1 ) {
645- int c = getopt (argc , argv , "i:r " );
646+ int c = getopt (argc , argv , "i:rR " );
646647 if (c < 0 )
647648 break ;
648649
@@ -657,11 +658,21 @@ static int cmd_subvolume_snapshot(const struct cmd_struct *cmd, int argc, char *
657658 case 'r' :
658659 flags |= BTRFS_UTIL_CREATE_SNAPSHOT_READ_ONLY ;
659660 break ;
661+ case 'R' :
662+ flags |= BTRFS_UTIL_CREATE_SNAPSHOT_RECURSIVE ;
663+ break ;
660664 default :
661665 usage_unknown_option (cmd , argv );
662666 }
663667 }
664668
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+
665676 if (check_argc_exact (argc - optind , 2 )) {
666677 retval = 1 ;
667678 goto out ;
0 commit comments