aboutsummaryrefslogtreecommitdiff
path: root/miscutils/makedevs.c
diff options
context:
space:
mode:
authorGravatar Eric Andersen <andersen@codepoet.org>2004-07-26 09:11:12 +0000
committerGravatar Eric Andersen <andersen@codepoet.org>2004-07-26 09:11:12 +0000
commit4f807a84c5d936c931cd93c9e98d087305295a1c (patch)
tree46c3a59fa158ebbd7303454f2657c330abfc24fe /miscutils/makedevs.c
parent5dcf15e02de10e648ac8e8d86500678f2043d2e6 (diff)
downloadbusybox-4f807a84c5d936c931cd93c9e98d087305295a1c.tar.gz
busybox-4f807a84c5d936c931cd93c9e98d087305295a1c.tar.bz2
BusyBox has no business hard coding the number of major and minor bits for a
dev_t. This is especially important now that the user space concept of a dev_t and the kernel concept of a dev_t are divergant. The only bit of user space allowed to know the number of major and minor bits is include/sys/sysmacros.h (i.e. part of libc). When used with a current C library and a 2.6.x kernel, this fix should allow BusyBox to support wide device major/minor numbers. -Erik
Diffstat (limited to 'miscutils/makedevs.c')
-rw-r--r--miscutils/makedevs.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index 45498bb1d..e4233330a 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -13,21 +13,22 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
+#include <sys/sysmacros.h> /* major() and minor() */
#include "busybox.h"
int makedevs_main(int argc, char **argv)
{
mode_t mode;
char *basedev, *type, *nodname, buf[255];
- int major, Sminor, S, E;
+ int Smajor, Sminor, S, E;
if (argc < 7 || *argv[1]=='-')
bb_show_usage();
basedev = argv[1];
type = argv[2];
- major = atoi(argv[3]) << 8; /* correcting param to mknod() */
- Sminor = atoi(argv[4]);
+ Smajor = major(atoi(argv[3]));
+ Sminor = minor(atoi(argv[4]));
S = atoi(argv[5]);
E = atoi(argv[6]);
nodname = argc == 8 ? basedev : buf;
@@ -57,7 +58,7 @@ int makedevs_main(int argc, char **argv)
/* if mode != S_IFCHR and != S_IFBLK third param in mknod() ignored */
- if (mknod(nodname, mode, major | Sminor))
+ if (mknod(nodname, mode, Smajor | Sminor))
bb_error_msg("Failed to create: %s", nodname);
if (nodname == basedev) /* ex. /dev/hda - to /dev/hda1 ... */