Re: pre-patch2.1.45-3 lookin' good

NIIBE Yutaka (gniibe@mri.co.jp)
Mon, 14 Jul 1997 19:52:27 +0900


Hello Linus,

Linus Torvalds writes:
> Currently not working:
[...]
> - rd_root initial ramdisk loading. The file pointer initializations are
> more complex, and I can't stomach it right now - again I don't actually
> use this feature.

INITRD, that's I want. Since I really want to run the latest kernel
today, I tried to make another patch against pre-patch-2.1.45-4.

Here are patches to allow INITRD to compile (against pre-patch-2.1.45-4).
It compiles and works for me.

(1) Fix missing closing paren in arch/i386/kernel/process.c
(2) Fix for loop Driver (not tested).
(3) Fix for Ramdisk Driver (tested).
(4) Fix for SCSI General Driver (not tested).
(5) Fix for Sound Driver (not tested).
(6) Fix for duplicate dput in fs/super.c (tested).
This caused OOPS when killing AMD.
(7) Fix for do_change_root() in fs/super.c (tested).

Thanks,

-- 
NIIBE Yutaka

==================== $ TZ=UTC diff -ru linux linux.new diff -ru linux/arch/i386/kernel/process.c linux.new/arch/i386/kernel/process.c --- linux/arch/i386/kernel/process.c Mon Jul 14 10:35:32 1997 +++ linux.new/arch/i386/kernel/process.c Mon Jul 14 08:10:27 1997 @@ -625,7 +625,7 @@ lock_kernel(); filename = getname((char *) regs.ebx); error = PTR_ERR(filename); - if (IS_ERR(filename) + if (IS_ERR(filename)) goto out; error = do_execve(filename, (char **) regs.ecx, (char **) regs.edx, &regs); putname(filename); diff -ru linux/drivers/block/loop.c linux.new/drivers/block/loop.c --- linux/drivers/block/loop.c Mon Jun 16 23:35:54 1997 +++ linux.new/drivers/block/loop.c Mon Jul 14 08:16:16 1997 @@ -292,7 +292,7 @@ return -EBADF; if (lo->lo_inode) return -EBUSY; - inode = file->f_inode; + inode = file->f_dentry->d_inode; if (!inode) { printk("loop_set_fd: NULL inode?!?\n"); return -EINVAL; diff -ru linux/drivers/block/rd.c linux.new/drivers/block/rd.c --- linux/drivers/block/rd.c Mon Jul 14 10:35:32 1997 +++ linux.new/drivers/block/rd.c Mon Jul 14 10:25:51 1997 @@ -444,8 +444,9 @@ */ __initfunc(static void rd_load_image(kdev_t device,int offset)) { - struct inode inode, out_inode; + struct inode inode, out_inode; struct file infile, outfile; + struct dentry in_dentry, out_dentry; unsigned short fs; kdev_t ram_device; int nblocks, i; @@ -457,15 +458,19 @@ memset(&infile, 0, sizeof(infile)); memset(&inode, 0, sizeof(inode)); + memset(&in_dentry, 0, sizeof(in_dentry)); inode.i_rdev = device; infile.f_mode = 1; /* read only */ - infile.f_inode = &inode; + infile.f_dentry = &in_dentry; + in_dentry.d_inode = &inode; memset(&outfile, 0, sizeof(outfile)); memset(&out_inode, 0, sizeof(out_inode)); + memset(&out_dentry, 0, sizeof(out_dentry)); out_inode.i_rdev = ram_device; outfile.f_mode = 3; /* read/write */ - outfile.f_inode = &out_inode; + outfile.f_dentry = &out_dentry; + out_dentry.d_inode = &out_inode; if (blkdev_open(&inode, &infile) != 0) return; if (blkdev_open(&out_inode, &outfile) != 0) return; @@ -506,9 +511,9 @@ printk(KERN_NOTICE "RAMDISK: Loading %d blocks into ram disk... ", nblocks); for (i=0; i < nblocks; i++) { - infile.f_op->read(infile.f_inode, &infile, buf, + infile.f_op->read(infile.f_dentry->d_inode, &infile, buf, BLOCK_SIZE); - outfile.f_op->write(outfile.f_inode, &outfile, buf, + outfile.f_op->write(outfile.f_dentry->d_inode, &outfile, buf, BLOCK_SIZE); if (!(i % 16)) { printk("%c\b", rotator[rotate & 0x3]); @@ -637,7 +642,7 @@ { if (exit_code) return -1; - insize = crd_infp->f_op->read(crd_infp->f_inode, crd_infp, + insize = crd_infp->f_op->read(crd_infp->f_dentry->d_inode, crd_infp, inbuf, INBUFSIZ); if (insize == 0) return -1; @@ -656,7 +661,7 @@ unsigned n; uch *in, ch; - crd_outfp->f_op->write(crd_outfp->f_inode, crd_outfp, window, + crd_outfp->f_op->write(crd_outfp->f_dentry->d_inode, crd_outfp, window, outcnt); in = window; for (n = 0; n < outcnt; n++) { diff -ru linux/drivers/scsi/sg.c linux.new/drivers/scsi/sg.c --- linux/drivers/scsi/sg.c Fri Apr 4 16:52:23 1997 +++ linux.new/drivers/scsi/sg.c Mon Jul 14 08:19:24 1997 @@ -488,7 +488,7 @@ static unsigned int sg_poll(struct file *file, poll_table * wait) { - int dev = MINOR(file->f_inode->i_rdev); + int dev = MINOR(file->f_dentry->d_inode->i_rdev); struct scsi_generic *device = &scsi_generics[dev]; unsigned int mask = 0; diff -ru linux/drivers/sound/soundcard.c linux.new/drivers/sound/soundcard.c --- linux/drivers/sound/soundcard.c Mon Jun 16 23:35:56 1997 +++ linux.new/drivers/sound/soundcard.c Mon Jul 14 08:23:08 1997 @@ -246,7 +246,7 @@ struct inode *inode; int ret = 0; - inode = file->f_inode; + inode = file->f_dentry->d_inode; if (sound_select (inode, file, SEL_IN, wait)) ret |= POLLIN; @@ -326,7 +326,7 @@ vma->vm_page_prot)) return -EAGAIN; - vma->vm_inode = inode; + vma->vm_dentry->d_inode = inode; atomic_inc(&inode->i_count); dmap->mapping_flags |= DMA_MAP_MAPPED; diff -ru linux/fs/super.c linux.new/fs/super.c --- linux/fs/super.c Mon Jul 14 10:35:34 1997 +++ linux.new/fs/super.c Mon Jul 14 10:02:40 1997 @@ -691,7 +691,6 @@ goto out; } dev = inode->i_sb->s_dev; - dput(dentry); inode = dummy_inode = get_empty_inode(); inode->i_rdev = dev; } @@ -1101,8 +1100,7 @@ { kdev_t old_root_dev; struct vfsmount *vfsmnt; - struct inode *old_root,*old_pwd,*inode; - unsigned long old_fs; + struct dentry *old_root,*old_pwd,*dir_d = NULL; int error; old_root = current->fs->root; @@ -1114,24 +1112,29 @@ } ROOT_DEV = new_root_dev; do_mount_root(); - old_fs = get_fs(); - set_fs(get_ds()); - error = namei(put_old, &inode); - if (error) inode = NULL; - set_fs(old_fs); - if (!error && (atomic_read(&inode->i_count) != 1 || inode->i_mount)) + dir_d = lookup_dentry(put_old, NULL, 1); + if (IS_ERR(dir_d)) { + error = PTR_ERR(dir_d); + } else if (!dir_d->d_inode) { + dput(dir_d); + error = -ENOENT; + } else { + error = 0; + } + if (!error && dir_d->d_covers != dir_d) { + dput(dir_d); error = -EBUSY; - if (!error && !S_ISDIR(inode->i_mode)) + } + if (!error && !S_ISDIR(dir_d->d_inode->i_mode)) { + dput(dir_d); error = -ENOTDIR; - iput(old_root); /* current->fs->root */ - iput(old_pwd); /* current->fs->pwd */ + } + dput(old_root); + dput(old_pwd); if (error) { int umount_error; - if (inode) iput(inode); printk(KERN_NOTICE "Trying to unmount old root ... "); - old_root->i_mount = old_root; - /* does this belong into do_mount_root ? */ umount_error = do_umount(old_root_dev,1); if (umount_error) printk(KERN_ERR "error %d\n",umount_error); else { @@ -1140,16 +1143,16 @@ } return umount_error ? error : 0; } - iput(old_root); /* sb->s_covered */ remove_vfsmnt(old_root_dev); vfsmnt = add_vfsmnt(old_root_dev,"/dev/root.old",put_old); if (!vfsmnt) printk(KERN_CRIT "Trouble: add_vfsmnt failed\n"); else { - vfsmnt->mnt_sb = old_root->i_sb; - vfsmnt->mnt_sb->s_covered = inode; + vfsmnt->mnt_sb = old_root->d_inode->i_sb; + d_mount(dir_d,vfsmnt->mnt_sb->s_root); vfsmnt->mnt_flags = vfsmnt->mnt_sb->s_flags; } - inode->i_mount = old_root; + d_umount(old_root); + d_mount(dir_d,old_root); return 0; }

====================