summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--daemon/file.c18
-rw-r--r--generator/actions.ml27
-rw-r--r--src/MAX_PROC_NR2
3 files changed, 46 insertions, 1 deletions
diff --git a/daemon/file.c b/daemon/file.c
index a5b3e854..5ca9ccfa 100644
--- a/daemon/file.c
+++ b/daemon/file.c
@@ -107,6 +107,24 @@ do_rm (const char *path)
}
int
+do_rm_f (const char *path)
+{
+ int r;
+
+ CHROOT_IN;
+ r = unlink (path);
+ CHROOT_OUT;
+
+ /* Ignore ENOENT. */
+ if (r == -1 && errno != ENOENT) {
+ reply_with_perror ("%s", path);
+ return -1;
+ }
+
+ return 0;
+}
+
+int
do_chmod (int mode, const char *path)
{
int r;
diff --git a/generator/actions.ml b/generator/actions.ml
index 16b1518c..a17fed0d 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -9802,6 +9802,33 @@ the resulting filesystem may be inconsistent or corrupt.
The returned status indicates whether filesystem corruption was
detected (returns C<1>) or was not detected (returns C<0>)." };
+ { defaults with
+ name = "rm_f";
+ style = RErr, [Pathname "path"], [];
+ proc_nr = Some 367;
+ tests = [
+ InitScratchFS, Always, TestOutputFalse
+ [["mkdir"; "/rm_f"];
+ ["touch"; "/rm_f/foo"];
+ ["rm_f"; "/rm_f/foo"];
+ ["rm_f"; "/rm_f/not_exists"];
+ ["exists"; "/rm_f/foo"]];
+ InitScratchFS, Always, TestLastFail
+ [["mkdir"; "/rm_f2"];
+ ["mkdir"; "/rm_f2/foo"];
+ ["rm_f"; "/rm_f2/foo"]]
+ ];
+ shortdesc = "remove a file ignoring errors";
+ longdesc = "\
+Remove the file C<path>.
+
+If the file doesn't exist, that error is ignored. (Other errors,
+eg. I/O errors or bad paths, are not ignored)
+
+This call cannot remove directories.
+Use C<guestfs_rmdir> to remove an empty directory,
+or C<guestfs_rm_rf> to remove directories recursively." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 4203007d..526204c8 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-366
+367