X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fmknod.c;h=d5b8467218b030316453dd1867d191409f096a32;hp=a6e6eca66f058e421ee66b1203d7e713cf0f0dd1;hb=9ba779ea367b2ea7077da7bdd75e813cd06c7eea;hpb=6bda071b5cd8393b37653687027c4ae6c6cf3804 diff --git a/daemon/mknod.c b/daemon/mknod.c index a6e6eca..d5b8467 100644 --- a/daemon/mknod.c +++ b/daemon/mknod.c @@ -13,7 +13,7 @@ * * 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. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include @@ -26,44 +26,65 @@ #include #include -#include "../src/guestfs_protocol.h" +#include "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 (return -1); - ABS_PATH (path, return -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); }