New API: mklost_and_found

This commit is contained in:
Richard W.M. Jones
2012-11-02 09:32:52 +00:00
parent 4cfc277674
commit f56bc8edd5
4 changed files with 43 additions and 2 deletions

1
TODO
View File

@@ -57,7 +57,6 @@ Ideas for extra commands
e2image
e2undo
filefrag
mklost+found
SELinux:
chcat

View File

@@ -1178,3 +1178,30 @@ error:
if (err) free (err);
return -1;
}
int
do_mklost_and_found (const char *mountpoint)
{
char *cmd;
int r;
if (asprintf_nowarn (&cmd, "cd %R && mklost+found", mountpoint) == -1) {
reply_with_perror ("asprintf");
return -1;
}
r = system (cmd);
if (r == -1) {
reply_with_perror ("system");
free (cmd);
return -1;
}
if (!WIFEXITED (r) || WEXITSTATUS (r) != 0) {
reply_with_error ("%s: command failed", cmd);
free (cmd);
return -1;
}
free (cmd);
return 0;
}

View File

@@ -10345,6 +10345,21 @@ If the optional C<suffix> parameter is given, then the suffix
See also: C<guestfs_mkdtemp>." };
{ defaults with
name = "mklost_and_found";
style = RErr, [Pathname "mountpoint"], [];
proc_nr = Some 374;
tests = [
InitBasicFS, Always, TestRun (
[["rm_rf"; "/lost+found"];
["mklost_and_found"; "/"]])
];
shortdesc = "make lost+found directory on an ext2/3/4 filesystem";
longdesc = "\
Make the C<lost+found> directory, normally in the root directory
of an ext2/3/4 filesystem. C<mountpoint> is the directory under
which we try to create the C<lost+found> directory." };
]
(* Non-API meta-commands available only in guestfish.

View File

@@ -1 +1 @@
373
374