mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
New API: btrfs_qgroup_create
btrfs_qgroup_create creates a new qgroup. Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
This commit is contained in:
committed by
Richard W.M. Jones
parent
a325f887b3
commit
1144c692dc
@@ -1120,3 +1120,36 @@ do_btrfs_qgroup_limit (const char *subvolume, int64_t size)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
do_btrfs_qgroup_create (const char *qgroupid, const char *subvolume)
|
||||
{
|
||||
const size_t MAX_ARGS = 64;
|
||||
const char *argv[MAX_ARGS];
|
||||
size_t i = 0;
|
||||
CLEANUP_FREE char *subvolume_buf = NULL;
|
||||
CLEANUP_FREE char *err = NULL;
|
||||
CLEANUP_FREE char *out = NULL;
|
||||
int r;
|
||||
|
||||
subvolume_buf = sysroot_path (subvolume);
|
||||
if (subvolume_buf == NULL) {
|
||||
reply_with_perror ("malloc");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ADD_ARG (argv, i, str_btrfs);
|
||||
ADD_ARG (argv, i, "qgroup");
|
||||
ADD_ARG (argv, i, "create");
|
||||
ADD_ARG (argv, i, qgroupid);
|
||||
ADD_ARG (argv, i, subvolume_buf);
|
||||
ADD_ARG (argv, i, NULL);
|
||||
|
||||
r = commandv (&out, &err, argv);
|
||||
if (r == -1) {
|
||||
reply_with_error ("%s: %s", subvolume, err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12153,6 +12153,23 @@ Trash all qgroup numbers and scan the metadata again with the current config." }
|
||||
Limit the size of a subvolume which's path is C<subvolume>. C<size>
|
||||
can have suffix of G, M, or K. " };
|
||||
|
||||
{ defaults with
|
||||
name = "btrfs_qgroup_create";
|
||||
style = RErr, [String "qgroupid"; Pathname "subvolume"], [];
|
||||
proc_nr = Some 430;
|
||||
optional = Some "btrfs"; camel_name = "BTRFSQgroupCreate";
|
||||
tests = [
|
||||
InitPartition, Always, TestRun (
|
||||
[["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
|
||||
["mount"; "/dev/sda1"; "/"];
|
||||
["btrfs_quota_enable"; "/"; "true"];
|
||||
["btrfs_subvolume_create"; "/sub1"; "NOARG"];
|
||||
["btrfs_qgroup_create"; "0/1000"; "/sub1"]]), [];
|
||||
];
|
||||
shortdesc = "create a subvolume quota group";
|
||||
longdesc = "\
|
||||
Create a quota group (qgroup) for subvolume at C<subvolume>." };
|
||||
|
||||
]
|
||||
|
||||
(* Non-API meta-commands available only in guestfish.
|
||||
|
||||
@@ -1 +1 @@
|
||||
429
|
||||
430
|
||||
|
||||
Reference in New Issue
Block a user