X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fmknod.c;h=ee2d1ffa108add1f42b58df9535291fd5fbc6cc1;hp=6ff88efab1f2dd7fe8875a42ffec56113f28dd5b;hb=e44cf42f362d793c47d892a18a6853d88abd6ecb;hpb=edb9b3abc03c0a0f84b1cbd9cf5920e3c84e5c18 diff --git a/daemon/mknod.c b/daemon/mknod.c index 6ff88ef..ee2d1ff 100644 --- a/daemon/mknod.c +++ b/daemon/mknod.c @@ -26,9 +26,24 @@ #include #include -#include "../src/guestfs_protocol.h" +#include "guestfs_protocol.h" #include "daemon.h" #include "actions.h" +#include "optgroups.h" + +#ifdef HAVE_MKNOD +int +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) @@ -36,19 +51,23 @@ do_mknod (int mode, int devmajor, int devminor, const char *path) #ifdef HAVE_MKNOD int r; + 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 - reply_with_error ("%s is not available", __func__); - return -1; + NOT_AVAILABLE (-1); #endif }