diff options
| author | Alexander Viro <viro@www.linux.org.uk> | 2003-09-22 22:52:17 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.osdl.org> | 2003-09-22 22:52:17 -0700 |
| commit | 40d2adc65cc233bbbd5437efe1df224b04a5ebf1 (patch) | |
| tree | 88f5df8a1b2c13aedcddf5f09fd391e4f52015d9 /include | |
| parent | 18d0c6d3ba8df654d99677ab070037d6c0d9c055 (diff) | |
[PATCH] 32-bit dev_t: internal use
Starting the conversion:
* internal dev_t made 32bit.
* new helpers - new_encode_dev(), new_decode_dev(), huge_encode_dev(),
huge_decode_dev(), new_valid_dev(). They do encoding/decoding of 32bit and
64bit values; for now huge_... are aliases for new_... and new_valid_dev()
is always true. We do 12:20 for 32bit; representation is compatible with
16bit one - we have major in bits 19--8 and minor in 31--20,7--0. That's
what the userland sees; internally we have (major << 20)|minor, of course.
* MKDEV(), MAJOR() and MINOR() updated.
* several places used to handle Missed'em'V dev_t (14:18 split)
manually; that stuff had been taken into common helpers.
Now we can start replacing old_... with new_... and huge_..., depending
on the width available. MKDEV() callers should (for now) make sure that major
and minor are within 12:20. That's what the next chunk will do.
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/fs.h | 3 | ||||
| -rw-r--r-- | include/linux/kdev_t.h | 74 | ||||
| -rw-r--r-- | include/linux/raid/md_k.h | 6 | ||||
| -rw-r--r-- | include/linux/types.h | 2 |
4 files changed, 74 insertions, 11 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 20a7b18b0841..b3a714c094d2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1392,9 +1392,6 @@ struct tree_descr { char *name; struct file_operations *ops; int mode; }; extern int simple_fill_super(struct super_block *, int, struct tree_descr *); extern int simple_pin_fs(char *name, struct vfsmount **mount, int *count); extern void simple_release_fs(struct vfsmount **mount, int *count); -extern int old_valid_dev(dev_t); -extern u16 old_encode_dev(dev_t); -extern dev_t old_decode_dev(u16); extern int inode_change_ok(struct inode *, struct iattr *); extern int inode_setattr(struct inode *, struct iattr *); diff --git a/include/linux/kdev_t.h b/include/linux/kdev_t.h index f60508da024d..bceea527dd37 100644 --- a/include/linux/kdev_t.h +++ b/include/linux/kdev_t.h @@ -1,8 +1,7 @@ #ifndef _LINUX_KDEV_T_H #define _LINUX_KDEV_T_H #ifdef __KERNEL__ -/* These are for user-level "dev_t" */ -#define MINORBITS 8 +#define MINORBITS 20 #define MINORMASK ((1U << MINORBITS) - 1) #define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS)) @@ -18,6 +17,77 @@ buffer; \ }) +/* acceptable for old filesystems */ +static inline int old_valid_dev(dev_t dev) +{ + return MAJOR(dev) < 256 && MINOR(dev) < 256; +} + +static inline u16 old_encode_dev(dev_t dev) +{ + return (MAJOR(dev) << 8) | MINOR(dev); +} + +static inline dev_t old_decode_dev(u16 val) +{ + return MKDEV((val >> 8) & 255, val & 255); +} + +static inline int new_valid_dev(dev_t dev) +{ + return 1; +} + +static inline u32 new_encode_dev(dev_t dev) +{ + unsigned major = MAJOR(dev); + unsigned minor = MINOR(dev); + return (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12); +} + +static inline dev_t new_decode_dev(u32 dev) +{ + unsigned major = (dev & 0xfff00) >> 8; + unsigned minor = (dev & 0xff) | ((dev >> 12) & 0xfff00); + return MKDEV(major, minor); +} + +static inline int huge_valid_dev(dev_t dev) +{ + return 1; +} + +static inline u64 huge_encode_dev(dev_t dev) +{ + return new_encode_dev(dev); +} + +static inline dev_t huge_decode_dev(u64 dev) +{ + return new_decode_dev(dev); +} + +static inline int sysv_valid_dev(dev_t dev) +{ + return MAJOR(dev) < (1<<14) && MINOR(dev) < (1<<18); +} + +static inline u32 sysv_encode_dev(dev_t dev) +{ + return MINOR(dev) | (MAJOR(dev) << 18); +} + +static inline unsigned sysv_major(u32 dev) +{ + return (dev >> 18) & 0x3fff; +} + +static inline unsigned sysv_minor(u32 dev) +{ + return dev & 0x3ffff; +} + + #else /* __KERNEL__ */ /* diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h index 70c5d117da8d..c9466321a2b2 100644 --- a/include/linux/raid/md_k.h +++ b/include/linux/raid/md_k.h @@ -64,11 +64,7 @@ static inline int level_to_pers (int level) typedef struct mddev_s mddev_t; typedef struct mdk_rdev_s mdk_rdev_t; -#if (MINORBITS != 8) -#error MD does not handle bigger kdev yet -#endif - -#define MAX_MD_DEVS (1<<MINORBITS) /* Max number of md dev */ +#define MAX_MD_DEVS 256 /* Max number of md dev */ /* * options passed in raidrun: diff --git a/include/linux/types.h b/include/linux/types.h index e3a3d8b1b6bb..3b407b06b48f 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -17,7 +17,7 @@ #ifndef __KERNEL_STRICT_NAMES -typedef __u16 __kernel_dev_t; +typedef __u32 __kernel_dev_t; typedef __kernel_fd_set fd_set; typedef __kernel_dev_t dev_t; |
