From f56bc8edd5f23c23298bf3f609a98dd6fec5d512 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 2 Nov 2012 09:32:52 +0000 Subject: [PATCH] New API: mklost_and_found --- TODO | 1 - daemon/ext2.c | 27 +++++++++++++++++++++++++++ generator/actions.ml | 15 +++++++++++++++ src/MAX_PROC_NR | 2 +- 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 63904774b..22869bf19 100644 --- a/TODO +++ b/TODO @@ -57,7 +57,6 @@ Ideas for extra commands e2image e2undo filefrag - mklost+found SELinux: chcat diff --git a/daemon/ext2.c b/daemon/ext2.c index 7fc1172d2..e4afced17 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -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; +} diff --git a/generator/actions.ml b/generator/actions.ml index 5d713478c..5c3de5242 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -10345,6 +10345,21 @@ If the optional C parameter is given, then the suffix See also: C." }; + { 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 directory, normally in the root directory +of an ext2/3/4 filesystem. C is the directory under +which we try to create the C directory." }; + ] (* Non-API meta-commands available only in guestfish. diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index a5c3fde3c..38a45c3e8 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -373 +374