From: Lionel Sambuc Date: Wed, 12 Dec 2012 13:30:19 +0000 (+0100) Subject: Cleaning usage of MAJOR/MINOR X-Git-Tag: v3.2.1~112 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/mdoc.3.txt?a=commitdiff_plain;h=22e69f558ea13c71bdf7e5bf4be1125595d27d1c;p=minix.git Cleaning usage of MAJOR/MINOR Change-Id: I4d7718c51967930375a5f0657b61f869745cf644 --- diff --git a/commands/autopart/autopart.c b/commands/autopart/autopart.c index e07022c51..c6fd7112c 100644 --- a/commands/autopart/autopart.c +++ b/commands/autopart/autopart.c @@ -229,13 +229,6 @@ void *alloc(size_t n) return m; } -#ifndef makedev /* Missing in sys/types.h */ -#define minor(dev) (((dev) >> MINOR) & BYTE) -#define major(dev) (((dev) >> MAJOR) & BYTE) -#define makedev(major, minor) \ - ((dev_t) (((major) << MAJOR) | ((minor) << MINOR))) -#endif - typedef enum parttype { DUNNO, SUBPART, PRIMARY, FLOPPY } parttype_t; typedef struct device { diff --git a/commands/fsck.mfs/fsck.c b/commands/fsck.mfs/fsck.c index 63513eb25..8b1abd099 100644 --- a/commands/fsck.mfs/fsck.c +++ b/commands/fsck.mfs/fsck.c @@ -958,8 +958,7 @@ void list(ino_t ino, d_inode *ip) switch (ip->i_mode & I_TYPE) { case I_CHAR_SPECIAL: case I_BLOCK_SPECIAL: - printf(" %2x,%2x ", (dev_t) ip->i_zone[0] >> MAJOR & 0xFF, - (dev_t) ip->i_zone[0] >> MINOR & 0xFF); + printf(" %2x,%2x ", major(ip->i_zone[0]), minor(ip->i_zone[0])); break; default: printf("%7ld ", ip->i_size); } diff --git a/commands/part/part.c b/commands/part/part.c index 18b3ee53a..eba6496db 100644 --- a/commands/part/part.c +++ b/commands/part/part.c @@ -200,13 +200,6 @@ void *alloc(size_t n) return m; } -#ifndef makedev /* Missing in sys/types.h */ -#define minor(dev) (((dev) >> MINOR) & BYTE) -#define major(dev) (((dev) >> MAJOR) & BYTE) -#define makedev(major, minor) \ - ((dev_t) (((major) << MAJOR) | ((minor) << MINOR))) -#endif - typedef enum parttype { DUNNO, SUBPART, PRIMARY, FLOPPY } parttype_t; typedef struct device { diff --git a/commands/partition/partition.c b/commands/partition/partition.c index be790d5b1..5b3a7b2fc 100644 --- a/commands/partition/partition.c +++ b/commands/partition/partition.c @@ -36,13 +36,6 @@ void fatal(const char *label) exit(1); } -#ifndef makedev -#define minor(dev) (((dev) >> MINOR) & BYTE) -#define major(dev) (((dev) >> MAJOR) & BYTE) -#define makedev(major, minor) \ - ((dev_t) (((major) << MAJOR) | ((minor) << MINOR))) -#endif - int aflag; /* Add a new partition to the current table. */ int mflag; /* Minix rules, no need for alignment. */ int rflag; /* Report current partitions. */ diff --git a/commands/repartition/repartition.c b/commands/repartition/repartition.c index b3966d5ad..ba929f281 100644 --- a/commands/repartition/repartition.c +++ b/commands/repartition/repartition.c @@ -44,13 +44,6 @@ void fatal(const char *label) exit(1); } -#ifndef makedev -#define minor(dev) (((dev) >> MINOR) & BYTE) -#define major(dev) (((dev) >> MAJOR) & BYTE) -#define makedev(major, minor) \ - ((dev_t) (((major) << MAJOR) | ((minor) << MINOR))) -#endif - #define MINOR_d0p0s0 128 void partsort(struct part_entry *pe) diff --git a/commands/service/service.c b/commands/service/service.c index 3f8cadf67..65fe1998f 100644 --- a/commands/service/service.c +++ b/commands/service/service.c @@ -307,7 +307,7 @@ static int parse_arguments(int argc, char **argv, u32_t *rss_flags) print_usage(argv[ARG_NAME], "major already set"); exit(EINVAL); } - req_major = (stat_buf.st_rdev >> MAJOR) & BYTE; + req_major = major(stat_buf.st_rdev); if(req_dev_style == STYLE_NDEV) { req_dev_style = STYLE_DEV; } diff --git a/servers/mfs/inode.c b/servers/mfs/inode.c index 1ad314c6c..e04b118c4 100644 --- a/servers/mfs/inode.c +++ b/servers/mfs/inode.c @@ -275,8 +275,8 @@ struct inode *alloc_inode(dev_t dev, mode_t bits) b = alloc_bit(sp, IMAP, sp->s_isearch); if (b == NO_BIT) { err_code = ENOSPC; - major = (int) (sp->s_dev >> MAJOR) & BYTE; - minor = (int) (sp->s_dev >> MINOR) & BYTE; + major = major(sp->s_dev); + minor = minor(sp->s_dev); printf("Out of i-nodes on device %d/%d\n", major, minor); return(NULL); } diff --git a/sys/sys/types.h b/sys/sys/types.h index d7c8ffb86..74abeecc7 100644 --- a/sys/sys/types.h +++ b/sys/sys/types.h @@ -133,7 +133,6 @@ typedef uint32_t bitchunk_t; /* collection of bits in a bitmap */ */ typedef unsigned long Ino_t; - #endif /* __minix */ #include @@ -301,13 +300,13 @@ typedef int32_t __devmajor_t, __devminor_t; #define devmajor_t __devmajor_t #define devminor_t __devminor_t #define NODEVMAJOR (-1) -/* Major, minor numbers, dev_t's. */ -#define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */ -#define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */ -#define minor(dev) ((devminor_t)(((dev) >> MINOR) & 0xff)) -#define major(dev) ((devmajor_t)(((dev) >> MAJOR) & 0xff)) -#define makedev(major, minor) \ - ((dev_t) (((major) << MAJOR) | ((minor) << MINOR))) +/* LSC Our major / minor numbering scheme is not the exactly the same, to be updated? */ +#define major(x) ((devmajor_t)(((uint32_t)(x) & 0x0000ff00) >> 8)) +#define minor(x) ((devminor_t)( \ + (((uint32_t)(x) & 0x000000ff) >> 0))) +#define makedev(x,y) ((dev_t)((((x) << 8) & 0x0000ff00) | \ + \ + (((y) << 0) & 0x000000ff))) #endif #ifdef _BSD_CLOCK_T_