diff --git a/TODO b/TODO index bc0094609..72e8cd4c2 100644 --- a/TODO +++ b/TODO @@ -121,10 +121,8 @@ Extra commands / functionality: grep (do it locally using pipe?) dd (?) ln / ln -s - mknod readlink utime / utimes / futimes / futimens / l.. - mkfifo more mk*temp calls readdir / readdir-and-stat some sort of alloc/fallocate/posix_fallocate call to create empty space diff --git a/daemon/Makefile.am b/daemon/Makefile.am index d69f8999a..8884c6b25 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -46,6 +46,7 @@ guestfsd_SOURCES = \ initrd.c \ ls.c \ lvm.c \ + mknod.c \ mount.c \ ntfs.c \ pingdaemon.c \ @@ -59,6 +60,7 @@ guestfsd_SOURCES = \ swap.c \ sync.c \ tar.c \ + umask.c \ upload.c \ wc.c \ zero.c \ diff --git a/daemon/mknod.c b/daemon/mknod.c new file mode 100644 index 000000000..5af791fc5 --- /dev/null +++ b/daemon/mknod.c @@ -0,0 +1,69 @@ +/* libguestfs - the guestfsd daemon + * Copyright (C) 2009 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "../src/guestfs_protocol.h" +#include "daemon.h" +#include "actions.h" + +int +do_mknod (int mode, int devmajor, int devminor, char *path) +{ + int r; + + NEED_ROOT (-1); + ABS_PATH (path, -1); + + CHROOT_IN; + r = mknod (path, mode, makedev (devmajor, devminor)); + CHROOT_OUT; + + if (r == -1) { + reply_with_perror ("mknod: %s", path); + return -1; + } + + return 0; +} + +int +do_mkfifo (int mode, char *path) +{ + return do_mknod (mode | S_IFIFO, 0, 0, path); +} + +int +do_mknod_b (int mode, int devmajor, int devminor, char *path) +{ + return do_mknod (mode | S_IFBLK, devmajor, devminor, path); +} + +int +do_mknod_c (int mode, int devmajor, int devminor, char *path) +{ + return do_mknod (mode | S_IFCHR, devmajor, devminor, path); +} diff --git a/daemon/umask.c b/daemon/umask.c new file mode 100644 index 000000000..ad8573d78 --- /dev/null +++ b/daemon/umask.c @@ -0,0 +1,46 @@ +/* libguestfs - the guestfsd daemon + * Copyright (C) 2009 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "../src/guestfs_protocol.h" +#include "daemon.h" +#include "actions.h" + +int +do_umask (int mask) +{ + int r; + + r = umask (mask); + + if (r == -1) { + reply_with_perror ("umask"); + return -1; + } + + return r; +} diff --git a/src/generator.ml b/src/generator.ml index 1a844ee50..960973da0 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -2676,6 +2676,76 @@ Create a swap partition on C with label C