diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-07-26 09:11:12 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-07-26 09:11:12 +0000 |
commit | 4f807a84c5d936c931cd93c9e98d087305295a1c (patch) | |
tree | 46c3a59fa158ebbd7303454f2657c330abfc24fe /archival/tar.c | |
parent | 5dcf15e02de10e648ac8e8d86500678f2043d2e6 (diff) | |
download | busybox-w32-4f807a84c5d936c931cd93c9e98d087305295a1c.tar.gz busybox-w32-4f807a84c5d936c931cd93c9e98d087305295a1c.tar.bz2 busybox-w32-4f807a84c5d936c931cd93c9e98d087305295a1c.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
Diffstat (limited to 'archival/tar.c')
-rw-r--r-- | archival/tar.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/archival/tar.c b/archival/tar.c index 2de6454e7..689dd1424 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <signal.h> | 49 | #include <signal.h> |
50 | #include <sys/wait.h> | 50 | #include <sys/wait.h> |
51 | #include <sys/socket.h> | 51 | #include <sys/socket.h> |
52 | #include <sys/sysmacros.h> /* major() and minor() */ | ||
52 | #include "unarchive.h" | 53 | #include "unarchive.h" |
53 | #include "busybox.h" | 54 | #include "busybox.h" |
54 | 55 | ||
@@ -58,11 +59,6 @@ | |||
58 | # define TAR_MAGIC "ustar" /* ustar and a null */ | 59 | # define TAR_MAGIC "ustar" /* ustar and a null */ |
59 | # define TAR_VERSION " " /* Be compatable with GNU tar format */ | 60 | # define TAR_VERSION " " /* Be compatable with GNU tar format */ |
60 | 61 | ||
61 | # ifndef MAJOR | ||
62 | # define MAJOR(dev) (((dev)>>8)&0xff) | ||
63 | # define MINOR(dev) ((dev)&0xff) | ||
64 | # endif | ||
65 | |||
66 | static const int TAR_BLOCK_SIZE = 512; | 62 | static const int TAR_BLOCK_SIZE = 512; |
67 | static const int TAR_MAGIC_LEN = 6; | 63 | static const int TAR_MAGIC_LEN = 6; |
68 | static const int TAR_VERSION_LEN = 2; | 64 | static const int TAR_VERSION_LEN = 2; |
@@ -262,15 +258,15 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo, | |||
262 | } else if (S_ISCHR(statbuf->st_mode)) { | 258 | } else if (S_ISCHR(statbuf->st_mode)) { |
263 | header.typeflag = CHRTYPE; | 259 | header.typeflag = CHRTYPE; |
264 | putOctal(header.devmajor, sizeof(header.devmajor), | 260 | putOctal(header.devmajor, sizeof(header.devmajor), |
265 | MAJOR(statbuf->st_rdev)); | 261 | major(statbuf->st_rdev)); |
266 | putOctal(header.devminor, sizeof(header.devminor), | 262 | putOctal(header.devminor, sizeof(header.devminor), |
267 | MINOR(statbuf->st_rdev)); | 263 | minor(statbuf->st_rdev)); |
268 | } else if (S_ISBLK(statbuf->st_mode)) { | 264 | } else if (S_ISBLK(statbuf->st_mode)) { |
269 | header.typeflag = BLKTYPE; | 265 | header.typeflag = BLKTYPE; |
270 | putOctal(header.devmajor, sizeof(header.devmajor), | 266 | putOctal(header.devmajor, sizeof(header.devmajor), |
271 | MAJOR(statbuf->st_rdev)); | 267 | major(statbuf->st_rdev)); |
272 | putOctal(header.devminor, sizeof(header.devminor), | 268 | putOctal(header.devminor, sizeof(header.devminor), |
273 | MINOR(statbuf->st_rdev)); | 269 | minor(statbuf->st_rdev)); |
274 | } else if (S_ISFIFO(statbuf->st_mode)) { | 270 | } else if (S_ISFIFO(statbuf->st_mode)) { |
275 | header.typeflag = FIFOTYPE; | 271 | header.typeflag = FIFOTYPE; |
276 | } else if (S_ISREG(statbuf->st_mode)) { | 272 | } else if (S_ISREG(statbuf->st_mode)) { |