From 4f807a84c5d936c931cd93c9e98d087305295a1c Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Mon, 26 Jul 2004 09:11:12 +0000 Subject: 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 --- archival/tar.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'archival/tar.c') 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 @@ #include #include #include +#include /* major() and minor() */ #include "unarchive.h" #include "busybox.h" @@ -58,11 +59,6 @@ # define TAR_MAGIC "ustar" /* ustar and a null */ # define TAR_VERSION " " /* Be compatable with GNU tar format */ -# ifndef MAJOR -# define MAJOR(dev) (((dev)>>8)&0xff) -# define MINOR(dev) ((dev)&0xff) -# endif - static const int TAR_BLOCK_SIZE = 512; static const int TAR_MAGIC_LEN = 6; static const int TAR_VERSION_LEN = 2; @@ -262,15 +258,15 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo, } else if (S_ISCHR(statbuf->st_mode)) { header.typeflag = CHRTYPE; putOctal(header.devmajor, sizeof(header.devmajor), - MAJOR(statbuf->st_rdev)); + major(statbuf->st_rdev)); putOctal(header.devminor, sizeof(header.devminor), - MINOR(statbuf->st_rdev)); + minor(statbuf->st_rdev)); } else if (S_ISBLK(statbuf->st_mode)) { header.typeflag = BLKTYPE; putOctal(header.devmajor, sizeof(header.devmajor), - MAJOR(statbuf->st_rdev)); + major(statbuf->st_rdev)); putOctal(header.devminor, sizeof(header.devminor), - MINOR(statbuf->st_rdev)); + minor(statbuf->st_rdev)); } else if (S_ISFIFO(statbuf->st_mode)) { header.typeflag = FIFOTYPE; } else if (S_ISREG(statbuf->st_mode)) { -- cgit v1.2.3