diff options
| author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2004-07-26 09:11:12 +0000 |
|---|---|---|
| committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2004-07-26 09:11:12 +0000 |
| commit | 9cdf461f9fa82384c18bc1e149fb70d4243995f4 (patch) | |
| tree | 46c3a59fa158ebbd7303454f2657c330abfc24fe /miscutils | |
| parent | 9d39a896a95f562a8229c88ed1fdeaa929a06010 (diff) | |
| download | busybox-w32-9cdf461f9fa82384c18bc1e149fb70d4243995f4.tar.gz busybox-w32-9cdf461f9fa82384c18bc1e149fb70d4243995f4.tar.bz2 busybox-w32-9cdf461f9fa82384c18bc1e149fb70d4243995f4.zip | |
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
git-svn-id: svn://busybox.net/trunk/busybox@9015 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/makedevs.c | 9 |
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 @@ | |||
| 13 | #include <fcntl.h> | 13 | #include <fcntl.h> |
| 14 | #include <unistd.h> | 14 | #include <unistd.h> |
| 15 | #include <sys/types.h> | 15 | #include <sys/types.h> |
| 16 | #include <sys/sysmacros.h> /* major() and minor() */ | ||
| 16 | #include "busybox.h" | 17 | #include "busybox.h" |
| 17 | 18 | ||
| 18 | int makedevs_main(int argc, char **argv) | 19 | int makedevs_main(int argc, char **argv) |
| 19 | { | 20 | { |
| 20 | mode_t mode; | 21 | mode_t mode; |
| 21 | char *basedev, *type, *nodname, buf[255]; | 22 | char *basedev, *type, *nodname, buf[255]; |
| 22 | int major, Sminor, S, E; | 23 | int Smajor, Sminor, S, E; |
| 23 | 24 | ||
| 24 | if (argc < 7 || *argv[1]=='-') | 25 | if (argc < 7 || *argv[1]=='-') |
| 25 | bb_show_usage(); | 26 | bb_show_usage(); |
| 26 | 27 | ||
| 27 | basedev = argv[1]; | 28 | basedev = argv[1]; |
| 28 | type = argv[2]; | 29 | type = argv[2]; |
| 29 | major = atoi(argv[3]) << 8; /* correcting param to mknod() */ | 30 | Smajor = major(atoi(argv[3])); |
| 30 | Sminor = atoi(argv[4]); | 31 | Sminor = minor(atoi(argv[4])); |
| 31 | S = atoi(argv[5]); | 32 | S = atoi(argv[5]); |
| 32 | E = atoi(argv[6]); | 33 | E = atoi(argv[6]); |
| 33 | nodname = argc == 8 ? basedev : buf; | 34 | nodname = argc == 8 ? basedev : buf; |
| @@ -57,7 +58,7 @@ int makedevs_main(int argc, char **argv) | |||
| 57 | 58 | ||
| 58 | /* if mode != S_IFCHR and != S_IFBLK third param in mknod() ignored */ | 59 | /* if mode != S_IFCHR and != S_IFBLK third param in mknod() ignored */ |
| 59 | 60 | ||
| 60 | if (mknod(nodname, mode, major | Sminor)) | 61 | if (mknod(nodname, mode, Smajor | Sminor)) |
| 61 | bb_error_msg("Failed to create: %s", nodname); | 62 | bb_error_msg("Failed to create: %s", nodname); |
| 62 | 63 | ||
| 63 | if (nodname == basedev) /* ex. /dev/hda - to /dev/hda1 ... */ | 64 | if (nodname == basedev) /* ex. /dev/hda - to /dev/hda1 ... */ |
