Bug 3404 - udev mount.sh writes to /tmp before it is symlinked to /var/tmp
Summary: udev mount.sh writes to /tmp before it is symlinked to /var/tmp
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 1.4
Hardware: x86 Multiple
: Medium normal
Target Milestone: 1.5 M1
Assignee: Chen Qi
QA Contact:
URL:
Whiteboard: Blocked, need some further discussion
Depends on:
Blocks:
 
Reported: 2012-11-09 22:36 UTC by Marc Ferland
Modified: 2013-05-03 03:29 UTC (History)
8 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Ferland 2012-11-09 22:36:43 UTC
The udev init script is currently run before the bootmisc one. This means that if an "ADD" event for a block device happens _before_ the bootmisc script has terminated the content of /tmp will get deleted (bootmisc removes /tmp completely before creating a symlink to /var/tmp).

This results in the /media/$name directory not being cleaned-up when the device is removed.

To reproduce:
- Start your device with a usb flash drive plugged in (on my system this usually yields to /media/sdb1 being created);
- Once the system has finished booting, unplug the flash drive;
- Look in /media, the sdb1 directory should still be there even if the drive was removed.

What about creating a ram drive very early on boot? Just before udev would be a nice place.
Comment 1 Chen Qi 2012-11-10 13:45:05 UTC
Symlink /tmp to /var/tmp should be done in populate_volatiles.sh. So I would suggest delete it from bootmisc.sh, add it to /etc/default/volatiles/<config>. Let populate_volatiles.sh handle the details. 
Something like: 
--- a/meta/recipes-core/initscripts/initscripts-1.0/volatiles
+++ b/meta/recipes-core/initscripts/initscripts-1.0/volatiles
@@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock
 l root root 0755 /var/log /var/volatile/log
 l root root 0755 /var/run /var/volatile/run
 l root root 1777 /var/tmp /var/volatile/tmp
+l root root 1777 /tmp /var/tmp
 d root root 0755 /var/lock/subsys none
 f root root 0664 /var/log/wtmp none
 f root root 0664 /var/run/utmp none

A related bug is Bug#3181.
Comment 2 Chen Qi 2012-11-12 02:48:48 UTC
One more problem: udev seems to have a high priority in initscripts that it does no deserve.
The udev script states clearly that it needs 'mountvirtfs'.
root@beagleboard:/etc/init.d# head udev 
#!/bin/sh

### BEGIN INIT INFO
# Provides:          udev
# Required-Start:    mountvirtfs
# Required-Stop:     
# Default-Start:     S
# Default-Stop:
# Short-Description: Start udevd, populate /dev and load drivers.
### END INIT INFO

On the other hand, we can see mountall.sh which provides 'mountvirtfs' has a lower priority then udev. This should be fixed.
root@beagleboard:/etc/rcS.d# ls -1
S00psplash.sh
S02banner.sh
S02sysfs.sh
S03udev
S04modutils.sh
S06alignment.sh
S07bootlogd
S10checkroot.sh
S35mountall.sh
S37populate-volatile.sh
S38devpts.sh
S39alsa-state
S39hostname.sh
S40networking
S43portmap
S45mountnfs.sh
S55bootmisc.sh

udev should have a lower priority than mountall.sh and populate_volatiles.sh.

Any suggestion would be welcome.
Comment 3 Chen Qi 2012-11-12 06:40:18 UTC
(In reply to comment #1)
> Symlink /tmp to /var/tmp should be done in populate_volatiles.sh. So I would
> suggest delete it from bootmisc.sh, add it to
> /etc/default/volatiles/<config>. Let populate_volatiles.sh handle the
> details. 
> Something like: 
> --- a/meta/recipes-core/initscripts/initscripts-1.0/volatiles
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/volatiles
> @@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock
>  l root root 0755 /var/log /var/volatile/log
>  l root root 0755 /var/run /var/volatile/run
>  l root root 1777 /var/tmp /var/volatile/tmp
> +l root root 1777 /tmp /var/tmp
>  d root root 0755 /var/lock/subsys none
>  f root root 0664 /var/log/wtmp none
>  f root root 0664 /var/run/utmp none
> 
> A related bug is Bug#3181.

After a second thought, I realize that updating populate_volatile.sh script described in Bug#3181, together with the changes described above would solve this problem.
Comment 4 Chen Qi 2012-11-19 02:13:29 UTC
Blocked due to read-only rootfs support.

(I'm somewhat confused about it, for the previous scripts don't support RO rootfs as well.)
Comment 5 Chen Qi 2013-03-08 02:32:00 UTC
merged into poky/master: 297906d39cfcaa56009214e8759b9853f82f02d7

http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=12c4acd7ac5a27cf3676065b60f1c8395c96854c
Comment 6 Chen Qi 2013-04-18 08:54:01 UTC
Reopen this bug.
Because if it's not first boot, /tmp has already been symlinked to /var/volatile/tmp which is not created when udev starts, resulting in touch /tmp/.automount-$name failed.

I'll send out a patch to fix this problem soon.

Mark the milestone to 1.5 since dylan has been released.
Comment 7 Chen Qi 2013-05-03 03:29:31 UTC
merged into poky/master: cab467dfd78e667775a3969350961358acf1daaf