Skip to contentSkip to conversation

btrfs-progs: cmds: subvolume: add -p option on creating subvol

PATCH New Sidong Yang 1 participant 1 message Mar 4, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 btrfs-progs: cmds: subvolume: add -p option on creating subvol

This patch resolves github issue #429. Add an option that create parent directories when it creates subvolumes on nonexisting parents. This option tokenizes dstdir and checks each paths whether it's existing directory and make directory for creating subvolume.

---
v2: fixed the case using realpath() that path nonexists, added description on docs.
v3: added longopt, used strncpy_null than strcpy, use perm 0777
v4: removed trailing whitespace, fix doc and comment.

---
 Documentation/btrfs-subvolume.rst |  5 +++-
 cmds/subvolume.c                  | 43 +++++++++++++++++++++++++++++--
 2 files changed, 45 insertions(+), 3 deletions(-)
Documentation/btrfs-subvolume.rst +4 -1
index 4591d4bb..ef9aa1cc 100644
@@ -49,7 +49,7 @@ do not affect the files in the original subvolume.
 SUBCOMMAND
 -----------
 
-create [-i <qgroupid>] [<dest>/]<name>
+create [-i <qgroupid>] [-p|--parents] [<dest>/]<name>
         Create a subvolume *name* in *dest*.
 
         If *dest* is not given, subvolume *name* will be created in the current
@@ -61,6 +61,9 @@ create [-i <qgroupid>] [<dest>/]<name>
                 Add the newly created subvolume to a qgroup. This option can be given multiple
                 times.
 
+        -p|--parents
+                Make any missing parent directories for each argument.
+
 delete [options] [<subvolume> [<subvolume>...]], delete -i|--subvolid <subvolid> <path>
         Delete the subvolume(s) from the filesystem.
 
cmds/subvolume.c +41 -2

76 lines not on this page · raw message

Signature · 1 line
2.25.1