[PATCH] eject -T support
Tito
farmatito at tiscali.it
Sat Oct 7 08:47:37 PDT 2006
On Saturday 7 October 2006 16:42, you wrote:
> > About this comment:
> > // FIXME: what if something is mounted OVER our cdrom?
> > // We will unmount something else??!
> > // What if cdrom is mounted many times?
> >
> > 1) something mounted OVER our cdrom:
> >
> > /dev/hdd on /media/cdrom1 type iso9660 (ro,noexec,nosuid,nodev)
> > /dev/hdb1 on /media/cdrom1 type reiserfs (rw)
> >
> > ./busybox eject
> > eject: /dev/cdrom: Input/output error
> >
> > /dev/hdd on /media/cdrom1 type iso9660 (ro,noexec,nosuid,nodev)
> >
> > the overmounted block device is unmounted and eject fails.
>
> This is grossly incorrect.
>
> > 2) cdrom is mounted many times:
> >
> > /dev/hdd on /media/cdrom1 type iso9660 (ro)
> > /dev/hdd on /media/cdrom0 type iso9660 (ro)
> >
> > root at localhost:/dev/pts/1:/root/Desktop/busybox# ./busybox eject
> > eject: /dev/cdrom: Input/output error
> >
> > cat /proc/mounts
> > /dev/hdd /media/cdrom1 iso9660 ro 0 0
> >
> > cat /etc/mtab
> >
> > /dev/hda1 on / type ext3 (rw,noatime,errors=remount-ro)
> > proc on /proc type proc (rw)
> > /sys on /sys type sysfs (rw)
> > varrun on /var/run type tmpfs (rw)
> > varlock on /var/lock type tmpfs (rw)
> > udev on /dev type tmpfs (rw)
> > devpts on /dev/pts type devpts (rw,gid=5,mode=620)
> > devshm on /dev/shm type tmpfs (rw)
> > /dev/hda2 on /boot type ext2 (rw)
> >
> > block device is unmounted one time, eject fails,
> > mtab is not updated correctly.
>
> Also very bad.
>
> > These corner cases seems to be fixed by this example code,
> > but it is rather bloated as it imports half of umount's code
> > and is not well tested.
> > If you want to take a look at it....maybe you can squeeze it
> > or you have some better idea.
>
> I have an idea: remove that code entirely, then:
>
> #!/bin/sh
> umount /dev/cdrom
> eject
>
> Would this work?
I don't think so. One test I did was to use
umount_main()
instead of the actual code but this gave me some errors on one
of the two cases depending if I fed the device or the mount dir
as args.
Also something as
system("umount bla")
could be an option, but we tried it at the very beginning
of the eject porting and dropped it for security reasons.
BTW: the original eject version 2.0.13 by Jeff Tranter (tranter at pobox.com)
handle this cases well also, i'm studying a strace maybe
i can get some better idea on how to do it.....
Another option would be to ignore this corner cases as until now
nobody complained and maybe they are unlikely to happen ;-P
Ciao,
Tito
More information about the busybox
mailing list