Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 453656 - =sys-fs/udev-init-scripts-9999 does not create the /run/udev/rules.d directory before using it
Summary: =sys-fs/udev-init-scripts-9999 does not create the /run/udev/rules.d director...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: udev maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-23 11:35 UTC by Pim Vullers
Modified: 2013-01-27 19:13 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch for udev-init-scripts (udev-init-scripts-21-create_run_udev_rules_d.patch,563 bytes, patch)
2013-01-25 04:04 UTC, Samuli Suominen (RETIRED)
Details | Diff
Create /run/udev/rules.d when required (foo.patch,570 bytes, patch)
2013-01-25 15:21 UTC, Samuli Suominen (RETIRED)
Details | Diff
0001-Fix-population-of-run-udev-rules.d-for-newnet.patch (0001-Fix-population-of-run-udev-rules.d-for-newnet.patch,1.36 KB, patch)
2013-01-25 15:39 UTC, Mike Gilbert
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pim Vullers 2013-01-23 11:35:42 UTC
I've got a tmpfs mounted at /run and use networking using the network init script. This causes the udev initscript to write some lines to /run/udev/rules.d/90-network.rules as shown below. However, this directory does not exist, which causes the lines not to be written and a number of error messages (file does not exist) on boot.

I solved this by adding a mkdir command as shown below.

disable_oldnet_hotplug()
{
        if is_service_enabled network; then
                # disable network hotplugging
                local f="/run/udev/rules.d/90-network.rules"
                mkdir -p `dirname "${f}"`
                echo "# This file disables network hotplug events calling" >> "${f}"
                echo "# old-style openrc net scripts" >> "${f}"
                echo "# as we use /etc/init.d/network to set up our network" >> "${f}"
        fi
}
Comment 1 Ulenrich 2013-01-23 12:14:58 UTC
Confirming:
Using sys-apps/systemd-197-r1
there is no directory /run/udev/rules.d
but 

/run/udev$ ls -ll
total 4
srw-------  1 root root     0 23. Jan 11:17 control
drwxr-xr-x  2 root root 16120 23. Jan 11:17 data
drwxr-xr-x 83 root root  1660 23. Jan 11:17 links
-rw-r--r--  1 root root     8 23. Jan 11:17 queue.bin
drwxr-xr-x  6 root root   120 23. Jan 11:17 tags
drwxr-xr-x  2 root root   280 23. Jan 11:17 watch
Comment 2 Mike Gilbert gentoo-dev 2013-01-24 16:10:32 UTC
This seems like a udev-init-scripts problem, not an openrc problem.
Comment 3 William Hubbs gentoo-dev 2013-01-24 16:46:30 UTC
(In reply to comment #2)
> This seems like a udev-init-scripts problem, not an openrc problem.

No, it isn't a udev-init-scripts problem. udev-init-scripts has no idea about the /run/udev directory or its contents.

Also, see comment #1. If we do create it in udev-init-scripts this will not fix the issue for systemd users, so maybe udev itself should create this.

It may be a udev problem thinking about it though (see comment #2 for why since systemd doesn't use udev-init-scripts).
Comment 4 Mike Gilbert gentoo-dev 2013-01-24 16:58:16 UTC
(In reply to comment #3)

My thought was that any program writing files to /run/udev/rules.d should mkdir -p /run/udev/rules.d first. That ensures there are no race conditions on start up.
Comment 5 William Hubbs gentoo-dev 2013-01-24 17:04:18 UTC
(In reply to comment #4)
> (In reply to comment #3)
> 
> My thought was that any program writing files to /run/udev/rules.d should
> mkdir -p /run/udev/rules.d first. That ensures there are no race conditions
> on start up.

That could be done, but it wouldn't be a udev-init-scripts issue, because udev-init-scripts doesn't create /run/udev.

We already have two things that would have to be fixed; systemd and openrc.

But, I would rather talk to upstream (I'm not sure I'll be able to today) about getting udev to create /run/udev/rules.d when it creates /run/udev.
Comment 6 Mike Gilbert gentoo-dev 2013-01-24 17:07:51 UTC
(In reply to comment #5)

systemd does not write any rules in /run/udev/rules.d, so that is a non-issue.

/etc/init.d/udev (part of udev-init-scripts) does write rules in /run/udev/rules.d. Therefore, using my strategy, udev-init-scripts would require a fix.
Comment 7 Mike Gilbert gentoo-dev 2013-01-24 17:27:07 UTC
Here's a little feedback from #systemd:

<floppym> kay: How would you reccomend creating /run/udev/rules.d? Should that be handled by the udev startup script/process, or by whatever program is writing rules there?
<kay> floppym: i have never used it, and i wouldn't :)
<floppym> Heh.
<kay> floppym: you need to tell udev to reload, it will not find out that there are new rules
<kay> floppym: i guess the one that drops the file there, and does the reload can do the mkdir too
<floppym> Ah. I was under the impression there was some kind of inotify thing happening or something.
<floppym> Good to know it isn't that simle.
<kay> old udevs did inotify, but it's gone in the systemd code
Comment 8 Samuli Suominen (RETIRED) gentoo-dev 2013-01-25 04:04:18 UTC
Created attachment 336802 [details, diff]
Patch for udev-init-scripts

Should be created where used I guess

psst...
And how is that tmpfiles.d support currently? 
We could just make one of the tmpfile to create the dir for us once it's implemented if it already isn't
Comment 9 Alexander Tsoy 2013-01-25 05:21:38 UTC
JFYI

1. dracut always create this dir. It seems it never use it itself.

UDEVVERSION=$(udevadm --version)
if [ $UDEVVERSION -gt 166 ]; then
    # newer versions of udev use /run/udev/rules.d
    export UDEVRULESD=/run/udev/rules.d
    [ -d /run/udev ] || mkdir -p -m 0755 /run/udev
    [ -d $UDEVRULESD ] || mkdir -p -m 0755 $UDEVRULESD
else
    mkdir -m 0755 /dev/.udev /dev/.udev/rules.d
    export UDEVRULESD=/dev/.udev/rules.d
fi

2. "udevadm control --reload" can be used to reload rules.
Comment 10 Samuli Suominen (RETIRED) gentoo-dev 2013-01-25 15:21:49 UTC
Created attachment 336842 [details, diff]
Create /run/udev/rules.d when required

got last attachment reversed, this one is the real one
Comment 11 Mike Gilbert gentoo-dev 2013-01-25 15:39:40 UTC
Created attachment 336844 [details, diff]
0001-Fix-population-of-run-udev-rules.d-for-newnet.patch

I think we also need to move disable_oldnet_hotplug
Comment 12 Samuli Suominen (RETIRED) gentoo-dev 2013-01-25 20:08:43 UTC
applied as 21-r1 to tree, WilliamH gets to close this bug after committing to git and releasing new udev-init-scripts -- adjusting $summary accordingly
Comment 13 Samuli Suominen (RETIRED) gentoo-dev 2013-01-27 19:13:25 UTC
This is now committed to the git repository for 9999 -> Closing. Thanks everyone.