[BusyBox] 1.00-pre1 problem: can't umount oldroot after pivot_root&chroot
Yang Xiaopeng
yxp at hanwang.com.cn
Tue Jul 29 02:26:34 UTC 2003
Yang Xiaopeng wrote:
> Old /proc is unmounted when init restart, before executing my scripts,
> all user processes are also killed in that step. When my scripts run,
> proc filesystem is remounted to /tmp/proc before pivot_root&chroot to
> /tmp.
> after chroot, its real mount point should be /proc in the new root.
>
> Here is the output of `mount` just after pivot_root&chroot to /tmp:
>
> /dev/root on /old_root type cramfs (rw)
> none on / type tmpfs (rw)
> none on /proc type proc (rw)
>
> and the `ps` output:
>
> PID Uid VmSize Stat Command
> 1 root 616 S /bin/sh sbin/flash.sh
> 2 root SW [keventd]
> 3 root SWN [ksoftirqd_CPU0]
> 4 root SW [kswapd]
> 5 root SW [bdflush]
> 6 root SW [kupdated]
> 7 root SW [keyd]
> 8 root RW [ledtimed]
> 9 root SW [mtdblockd]
> 10 root Z [khubd]
> 181 root 676 R ps
>
> I'm sure that no user process use old root now, but when run "umount
> /old_root", it says:
> umount: /old_root: Device or resource busy
>
> I have tried to remount /proc within the new root *after* chroot, but
> get the same result.
>
>
I found the problem, I said that no user process use old root when run
my scripts, but
I'm wrong, actually there is a '3' fd open the file
"/old_root/dev/console". By adding
debug message in init/init.c, I found the problem: when init restart(in
exec_signal()),
before open the new terminal device, there is still a file opened(I
don't know which file it is), so the
terminal device(stdin) get fd '1', and the first dup(0)(stdout) return
'2', the second(stderr) return '3'.
I attach a simple patch to solve this problem.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: busybox-1.00-pre1-init.patch
Url: http://lists.busybox.net/pipermail/busybox/attachments/20030729/d0c571fc/attachment.diff
More information about the busybox
mailing list