Commit 917bb5a1 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] prepare for 32-bit dev_t: mknod()/ustat()

	Changed sys_mknod() prototype to have unsigned int passed to it
instead of current dev_t.  Added old_decode_dev() in sys_mknod() and
made sure that its callers are passing it old_encode_dev(<value>)
	Switched sys_ustat() and its variants from dev_t to unsigned (and
added old_decode_dev()).
	Took care of assignments to ROOT_DEV - again, old_decode_dev().
	Late-boot search in devfs (call sys_newstat() and compare with
st_rdev) also updated.
parent 3136f2b1
......@@ -498,7 +498,7 @@ static int __init parse_tag_core(const struct tag *tag)
if (tag->hdr.size > 2) {
if ((tag->u.core.flags & 1) == 0)
root_mountflags &= ~MS_RDONLY;
ROOT_DEV = tag->u.core.rootdev;
ROOT_DEV = old_decode_dev(tag->u.core.rootdev);
}
return 0;
}
......
......@@ -286,7 +286,7 @@ static int __init parse_tag_core(const struct tag *tag)
if (tag->hdr.size > 2) {
if ((tag->u.core.flags & 1) == 0)
root_mountflags &= ~MS_RDONLY;
ROOT_DEV = tag->u.core.rootdev;
ROOT_DEV = old_decode_dev(tag->u.core.rootdev);
}
return 0;
}
......
......@@ -957,7 +957,7 @@ void __init setup_arch(char **cmdline_p)
pre_setup_arch_hook();
early_cpu_init();
ROOT_DEV = ORIG_ROOT_DEV;
ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
drive_info = DRIVE_INFO;
screen_info = SCREEN_INFO;
edid_info = EDID_INFO;
......
......@@ -1188,7 +1188,7 @@ asmlinkage int irix_uname(struct iuname *buf)
#undef DEBUG_XSTAT
static inline u32
linux_to_irix_dev_t (dev_t t)
linux_to_irix_dev_t(dev_t t)
{
return MAJOR (t) << 18 | MINOR (t);
}
......@@ -1360,17 +1360,17 @@ asmlinkage int irix_fxstat(int version, int fd, struct stat *statbuf)
return error;
}
extern asmlinkage int sys_mknod(const char * filename, int mode, dev_t dev);
extern asmlinkage int sys_mknod(const char * filename, int mode, unsigned dev);
asmlinkage int irix_xmknod(int ver, char *filename, int mode, dev_t dev)
asmlinkage int irix_xmknod(int ver, char *filename, int mode, unsigned dev)
{
int retval;
printk("[%s:%d] Wheee.. irix_xmknod(%d,%s,%x,%x)\n",
current->comm, current->pid, ver, filename, mode, (int) dev);
current->comm, current->pid, ver, filename, mode, dev);
switch(ver) {
case 2:
/* shouldn't we convert here as well as on stat()? */
retval = sys_mknod(filename, mode, dev);
break;
......
......@@ -272,7 +272,7 @@ int hpux_utssys(char *ubuf, int n, int type)
break ;
case 2:
/* ustat(): */
return( hpux_ustat((dev_t)n, (struct hpux_ustat *)ubuf) );
return( hpux_ustat(old_decode_dev(n), (struct hpux_ustat *)ubuf) );
break ;
case 3:
/* setuname():
......
......@@ -107,7 +107,7 @@ extern char saved_command_line[];
extern int pmac_newworld;
#define DEFAULT_ROOT_DEVICE 0x0801 /* sda1 - slightly silly choice */
#define DEFAULT_ROOT_DEVICE Root_SDA1 /* sda1 - slightly silly choice */
extern void zs_kgdb_hook(int tty_num);
static void ohare_init(void);
......
......@@ -353,7 +353,7 @@ void __init setup_arch(char **cmdline_p)
sh_console_init();
#endif
ROOT_DEV = ORIG_ROOT_DEV;
ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
#ifdef CONFIG_BLK_DEV_RAM
rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
......
......@@ -321,7 +321,7 @@ void __init setup_arch(char **cmdline_p)
if (!root_flags)
root_mountflags &= ~MS_RDONLY;
ROOT_DEV = root_dev;
ROOT_DEV = old_decode_dev(root_dev);
#ifdef CONFIG_BLK_DEV_INITRD
rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
......
......@@ -517,7 +517,7 @@ void __init setup_arch(char **cmdline_p)
if (!root_flags)
root_mountflags &= ~MS_RDONLY;
ROOT_DEV = root_dev;
ROOT_DEV = old_decode_dev(root_dev);
#ifdef CONFIG_BLK_DEV_INITRD
rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
......
......@@ -257,13 +257,13 @@ asmlinkage int solaris_fstat64(unsigned int fd, u32 statbuf)
asmlinkage int solaris_mknod(u32 path, u32 mode, s32 dev)
{
int (*sys_mknod)(const char *,int,dev_t) =
(int (*)(const char *,int,dev_t))SYS(mknod);
int (*sys_mknod)(const char *,int,unsigned) =
(int (*)(const char *,int,unsigned))SYS(mknod);
int major, minor;
if ((major = R4_MAJOR(dev)) > 255 ||
(minor = R4_MINOR(dev)) > 255) return -EINVAL;
return sys_mknod((const char *)A(path), mode, MKDEV(major,minor));
return sys_mknod((const char *)A(path), mode, old_encode_dev(MKDEV(major,minor)));
}
asmlinkage int solaris_xmknod(int vers, u32 path, u32 mode, s32 dev)
......
......@@ -1476,7 +1476,7 @@ long sys32_uname(struct old_utsname * name)
extern int sys_ustat(dev_t, struct ustat *);
long sys32_ustat(dev_t dev, struct ustat32 *u32p)
long sys32_ustat(unsigned dev, struct ustat32 *u32p)
{
struct ustat u;
mm_segment_t seg;
......
......@@ -317,7 +317,7 @@ void __init setup_arch(char **cmdline_p)
{
unsigned long low_mem_size;
ROOT_DEV = ORIG_ROOT_DEV;
ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
drive_info = DRIVE_INFO;
screen_info = SCREEN_INFO;
edid_info = EDID_INFO;
......
......@@ -1445,7 +1445,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
return error;
}
asmlinkage long sys_mknod(const char __user * filename, int mode, dev_t dev)
asmlinkage long sys_mknod(const char __user * filename, int mode, unsigned dev)
{
int error = 0;
char * tmp;
......@@ -1471,8 +1471,12 @@ asmlinkage long sys_mknod(const char __user * filename, int mode, dev_t dev)
case 0: case S_IFREG:
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
break;
case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK:
error = vfs_mknod(nd.dentry->d_inode,dentry,mode,dev);
case S_IFCHR: case S_IFBLK:
error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
old_decode_dev(dev));
break;
case S_IFIFO: case S_IFSOCK:
error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
break;
case S_IFDIR:
error = -EPERM;
......
......@@ -405,14 +405,14 @@ struct super_block * user_get_super(dev_t dev)
return NULL;
}
asmlinkage long sys_ustat(dev_t dev, struct ustat __user * ubuf)
asmlinkage long sys_ustat(unsigned dev, struct ustat __user * ubuf)
{
struct super_block *s;
struct ustat tmp;
struct kstatfs sbuf;
int err = -EINVAL;
s = user_get_super(dev);
s = user_get_super(old_decode_dev(dev));
if (s == NULL)
goto out;
err = vfs_statfs(s, &sbuf);
......
......@@ -80,7 +80,7 @@ static dev_t __init try_name(char *name, int part)
/*
* Nope. Try old-style "0321"
*/
res = (dev_t)simple_strtoul(buf, &s, 16);
res = old_decode_dev(simple_strtoul(buf, &s, 16));
if (*s)
goto fail;
}
......@@ -107,7 +107,7 @@ static dev_t __init try_name(char *name, int part)
if (part < range)
return res + part;
fail:
return (dev_t) 0;
return 0;
}
/*
......@@ -146,7 +146,7 @@ dev_t name_to_dev_t(char *name)
if (sscanf(name, "%u:%u", &maj, &min) == 2) {
res = MKDEV(maj, min);
} else {
res = (dev_t)simple_strtoul(name, &p, 16);
res = old_decode_dev(simple_strtoul(name, &p, 16));
if (*p)
goto fail;
}
......@@ -187,7 +187,7 @@ dev_t name_to_dev_t(char *name)
sys_rmdir("/sys");
return res;
fail:
res = (dev_t) 0;
res = 0;
goto done;
}
......
......@@ -10,7 +10,7 @@
#include <linux/root_dev.h>
asmlinkage long sys_unlink(const char *name);
asmlinkage long sys_mknod(const char *name, int mode, dev_t dev);
asmlinkage long sys_mknod(const char *name, int mode, unsigned dev);
asmlinkage long sys_newstat(char * filename, struct stat * statbuf);
asmlinkage long sys_ioctl(int fd, int cmd, unsigned long arg);
asmlinkage long sys_mkdir(const char *name, int mode);
......@@ -43,7 +43,7 @@ static inline void umount_devfs(const char *path) {}
static inline int create_dev(char *name, dev_t dev, char *devfs_name)
{
sys_unlink(name);
return sys_mknod(name, S_IFBLK|0600, dev);
return sys_mknod(name, S_IFBLK|0600, old_encode_dev(dev));
}
#endif
......
......@@ -78,7 +78,7 @@ static void * __init read_dir(char *path, int *len)
/*
* recursively scan <path>, looking for a device node of type <dev>
*/
static int __init find_in_devfs(char *path, dev_t dev)
static int __init find_in_devfs(char *path, unsigned dev)
{
struct stat buf;
char *end = path + strlen(path);
......@@ -140,7 +140,7 @@ int __init create_dev(char *name, dev_t dev, char *devfs_name)
if (!dev)
return -1;
strcpy(path, "/dev");
if (find_in_devfs(path, dev) < 0)
if (find_in_devfs(path, old_encode_dev(dev)) < 0)
return -1;
return sys_symlink(path + 5, name);
}
......@@ -40,7 +40,7 @@ static void __init handle_initrd(void)
int error;
int i, pid;
real_root_dev = ROOT_DEV;
real_root_dev = old_encode_dev(ROOT_DEV);
create_dev("/dev/root.old", Root_RAM0, NULL);
/* mount initrd on rootfs' /root */
mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
......@@ -69,12 +69,12 @@ static void __init handle_initrd(void)
close(root_fd);
umount_devfs("/old/dev");
if (real_root_dev == Root_RAM0) {
if (old_decode_dev(real_root_dev) == Root_RAM0) {
sys_chdir("/old");
return;
}
ROOT_DEV = real_root_dev;
ROOT_DEV = old_decode_dev(real_root_dev);
mount_root();
printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
......
......@@ -136,7 +136,7 @@ static void __init md_setup_drive(void)
snprintf(comp_name, 63, "/dev/%s", devname);
if (sys_newstat(comp_name, &buf) == 0 &&
S_ISBLK(buf.st_mode))
dev = buf.st_rdev;
dev = old_decode_dev(buf.st_rdev);
if (!dev) {
printk(KERN_WARNING "md: Unknown device name: %s\n", devname);
break;
......
......@@ -24,7 +24,7 @@ static void __init free(void *where)
}
asmlinkage long sys_mkdir(char *name, int mode);
asmlinkage long sys_mknod(char *name, int mode, dev_t dev);
asmlinkage long sys_mknod(char *name, int mode, unsigned dev);
asmlinkage long sys_symlink(char *old, char *new);
asmlinkage long sys_link(char *old, char *new);
asmlinkage long sys_write(int fd, const char *buf, size_t size);
......@@ -92,7 +92,7 @@ static __initdata mode_t mode;
static __initdata unsigned long body_len, name_len;
static __initdata uid_t uid;
static __initdata gid_t gid;
static __initdata dev_t rdev;
static __initdata unsigned rdev;
static void __init parse_header(char *s)
{
......@@ -113,7 +113,7 @@ static void __init parse_header(char *s)
body_len = parsed[6];
major = parsed[7];
minor = parsed[8];
rdev = MKDEV(parsed[9], parsed[10]);
rdev = old_encode_dev(MKDEV(parsed[9], parsed[10]));
name_len = parsed[11];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment