diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-10 12:52:49 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-10 12:55:04 +0100 |
commit | 44da812b424f5e10e268d47149d012d49edf858b (patch) | |
tree | 14e5e11712c46bcd57d5cb1130be507d96ab11c6 /daemon/file.c | |
parent | dd0432e2efc2e22ddbc9fb0a2746ee1c6a9c582f (diff) | |
download | libguestfs-44da812b424f5e10e268d47149d012d49edf858b.tar.gz libguestfs-44da812b424f5e10e268d47149d012d49edf858b.tar.xz libguestfs-44da812b424f5e10e268d47149d012d49edf858b.zip |
New commands: rm rmdir rm-rf mkdir mkdir-p chmod chown
Diffstat (limited to 'daemon/file.c')
-rw-r--r-- | daemon/file.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/daemon/file.c b/daemon/file.c index ce449672..43c875cc 100644 --- a/daemon/file.c +++ b/daemon/file.c @@ -180,3 +180,63 @@ do_read_lines (const char *path) return r; } + +int +do_rm (const char *path) +{ + int r; + + NEED_ROOT (-1); + ABS_PATH (path, -1); + + CHROOT_IN; + r = unlink (path); + CHROOT_OUT; + + if (r == -1) { + reply_with_perror ("unlink: %s", path); + return -1; + } + + return 0; +} + +int +do_chmod (int mode, const char *path) +{ + int r; + + NEED_ROOT (-1); + ABS_PATH (path, -1); + + CHROOT_IN; + r = chmod (path, mode); + CHROOT_OUT; + + if (r == -1) { + reply_with_perror ("chmod: %s: 0%o", path, mode); + return -1; + } + + return 0; +} + +int +do_chown (int owner, int group, const char *path) +{ + int r; + + NEED_ROOT (-1); + ABS_PATH (path, -1); + + CHROOT_IN; + r = chown (path, owner, group); + CHROOT_OUT; + + if (r == -1) { + reply_with_perror ("chown: %s: %d.%d", path, owner, group); + return -1; + } + + return 0; +} |