X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fmknod.c;h=2458a8514f7c8b1188fa21a35f0b7f4f80b0486b;hp=5af791fc51b7134adaf3ce3f54282c89e5aa8ce9;hb=61ab83d19009a8006dd73ebe16d22494b78be4d1;hpb=f850e1f065fb04df7cc87a921ab3c658741cc393 diff --git a/daemon/mknod.c b/daemon/mknod.c index 5af791f..2458a85 100644 --- a/daemon/mknod.c +++ b/daemon/mknod.c @@ -1,5 +1,5 @@ /* libguestfs - the guestfsd daemon - * Copyright (C) 2009 Red Hat Inc. + * 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 @@ -29,41 +29,62 @@ #include "../src/guestfs_protocol.h" #include "daemon.h" #include "actions.h" +#include "optgroups.h" +#ifdef HAVE_MKNOD int -do_mknod (int mode, int devmajor, int devminor, char *path) +optgroup_mknod_available (void) { + return 1; +} +#else +int +optgroup_mknod_available (void) +{ + return 0; +} +#endif + +int +do_mknod (int mode, int devmajor, int devminor, const char *path) +{ +#ifdef HAVE_MKNOD int r; - NEED_ROOT (-1); - ABS_PATH (path, -1); + if (mode < 0) { + reply_with_error ("%s: mode is negative", path); + return -1; + } CHROOT_IN; r = mknod (path, mode, makedev (devmajor, devminor)); CHROOT_OUT; if (r == -1) { - reply_with_perror ("mknod: %s", path); + reply_with_perror ("%s", path); return -1; } return 0; +#else + NOT_AVAILABLE (-1); +#endif } int -do_mkfifo (int mode, char *path) +do_mkfifo (int mode, const char *path) { return do_mknod (mode | S_IFIFO, 0, 0, path); } int -do_mknod_b (int mode, int devmajor, int devminor, char *path) +do_mknod_b (int mode, int devmajor, int devminor, const char *path) { return do_mknod (mode | S_IFBLK, devmajor, devminor, path); } int -do_mknod_c (int mode, int devmajor, int devminor, char *path) +do_mknod_c (int mode, int devmajor, int devminor, const char *path) { return do_mknod (mode | S_IFCHR, devmajor, devminor, path); }