git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Version 1.10.10.
[libguestfs.git]
/
daemon
/
mknod.c
diff --git
a/daemon/mknod.c
b/daemon/mknod.c
index
a6e6eca
..
ee2d1ff
100644
(file)
--- a/
daemon/mknod.c
+++ b/
daemon/mknod.c
@@
-26,44
+26,65
@@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include "
../src/
guestfs_protocol.h"
+#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
#include "daemon.h"
#include "actions.h"
+#include "optgroups.h"
+#ifdef HAVE_MKNOD
int
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;
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) {
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;
return -1;
}
return 0;
+#else
+ NOT_AVAILABLE (-1);
+#endif
}
int
}
int
-do_mkfifo (int mode, char *path)
+do_mkfifo (int mode, c
onst c
har *path)
{
return do_mknod (mode | S_IFIFO, 0, 0, path);
}
int
{
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, c
onst c
har *path)
{
return do_mknod (mode | S_IFBLK, devmajor, devminor, path);
}
int
{
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, c
onst c
har *path)
{
return do_mknod (mode | S_IFCHR, devmajor, devminor, path);
}
{
return do_mknod (mode | S_IFCHR, devmajor, devminor, path);
}