Commit Graph

10668 Commits

Author SHA1 Message Date
Daniel Drake
cdbef8fd5a udevd: fix synchronization with settle when handling inotify events
udev uses inotify to implement a scheme where when the user closes
a writable device node, a change uevent is forcefully generated.
In the case of block devices, it actually requests a partition rescan.

This currently can't be synchronized with "udevadm settle", i.e. this
is not reliable in a script:

 sfdisk --change-id /dev/sda 1 81
 udevadm settle
 mount /dev/sda1 /foo

The settle call doesn't synchronize there, so at the same time we try
to mount the device, udevd is busy removing the partition device nodes and
readding them again. The mount call often happens in that moment where the
partition node has been removed but not readded yet.

This exact issue was fixed long ago:
http://git.kernel.org/cgit/linux/hotplug/udev.git/commit/?id=bb38678e3ccc02bcd970ccde3d8166a40edf92d3

but that fix is no longer valid now that sequence numbers are no longer
used.

Fix this by forcing another mainloop iteration after handling inotify events
before unblocking settle. If the inotify event caused us to generate a
"change" event, we'll pick that up in the following loop iteration, before
we reach the end of the loop where we respond to settle's control message,
unblocking it.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 13:18:48 -04:00
Nir Soffer
1cd8de00b5 udev: restore udevadm settle timeout
Commit 9ea28c55a2 (udev: remove seqnum API and all assumptions about
seqnums) introduced a regresion, ignoring the timeout option when
waiting until the event queue is empty.

Previously, if the udev event queue was not empty when the timeout was
expired, udevadm settle was returning with exit code 1.  To check if the
queue is empty, you could invoke udevadm settle with timeout=0. This
patch restores the previous behavior.

(David: fixed timeout==0 handling and dropped redundant assignment)

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 13:18:06 -04:00
Gavin Li
24f869b793 hwdb: add Samsung ATIV Book 6 / 8
This adds support for the keyboard illumination keys and fixes
Fn+F1.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 13:16:36 -04:00
Peter Hutterer
8282539ff1 hwdb: set the resolution for a couple of bcm5974 touchpads
Verified for the 5,1 Macbook, the others are guesses based on the list of
supported devices of the moshi trackpad protector.
http://www.moshi.com/trackpad-protector-trackguard-macbook-pro#silver

Resolution calculated based on the min/max settings set in the kernel driver,
divided by the physical size. This is probably slightly off, but still better
than no resolution at all.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 13:15:52 -04:00
Zbigniew Jędrzejewski-Szmek
37668c896a rules: finish incomplete rename
Fixup for 51c0c2869845a058268d54c3111d55d0dd485704.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 13:14:46 -04:00
Matthew Garrett
32610f8a5f rules: fix tests for removable state
We only care about whether our direct parent is removable, not whether any
further points up the tree are - the kernel will take care of policy for
those itself. This enables autosuspend on devices where the root hub reports
that its removable state is unknown.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 13:13:28 -04:00
Anthony G. Basile
c5bf58cafc udev: builtin-keyboard: add support for EVDEV_ABS_*
Parse properties in the form
EVDEV_ABS_00="<min>:<max>:<res>:<fuzz>:<flat>"

and apply them to the kernel device. Future processes that open that device
will see the updated EV_ABS range.

This is particularly useful for touchpads that don't provide a resolution in
the kernel driver but can be fixed up through hwdb entries (e.g. bcm5974).

All values in the property are optional, e.g. a string of "::45" is valid to
set the resolution to 45.

The order intentionally orders resolution before fuzz and flat despite it
being the last element in the absinfo struct. The use-case for setting
fuzz/flat is almost non-existent, resolution is probably the most common case
we'll need.

To avoid multiple hwdb invocations for the same device, replace the
hwdb "keyboard:" prefix with "evdev:" and drop the separate 60-keyboard.rules
file. The new 60-evdev.rules is called for all event nodes
anyway, we don't need a separate rules file and second callout to the hwdb
builtin.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 13:09:45 -04:00
Peter Hutterer
e2e8747652 udev: builtin-keyboard: invert a condition
No functional changes, just to make the next patch easier to review

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 12:27:47 -04:00
Peter Hutterer
ca9aee0fac udev: builtin-keyboard: move actual key mapping to a helper function
No changes in the mapping, but previously we opened the device only on
successful parsing. Now we open the mapping as soon as we have a value that
looks interesting. Since errors are supposed to be the exception, not the
rule, this is probably fine.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 12:26:55 -04:00
Peter Hutterer
13d57d7917 udev: builtin-keyboard: immediately EVIOCSKEYCODE when we have a pair
Rather than building a map and looping through the map, immediately call the
ioctl when we have a successfully parsed property.

This has a side-effect: before the maximum number of ioctls was limited to the
size of the map (1024), now it is unlimited.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 12:26:13 -04:00
Peter Hutterer
accc92a8ad udev: builtin-keyboard: move fetching the device node up
No point parsing the properties if we can't get the devnode to apply them
later. Plus, this makes future additions easier to slot in.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 12:25:16 -04:00
Anthony G. Basile
206d05759f test-libudev.c: remove deprecated functions. 2015-04-12 12:21:07 -04:00
Hans de Goede
ce18923774 udev: input_id: tag accelerometers as ID_INPUT_ACCELEROMETER
input_id already (tries to) tag accelerometers as such, but this only works
for absolute accelerometers. Recent kernels mark accelerometers through an
input prop. Trust that prop and always tag devices with it with
ID_INPUT_ACCELEROMETER.

Note that detection by the prop bit works the same as the existing detection
and will ensure that no other tags get set on the device.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:48:23 -04:00
Anthony G. Basile
5ee5fee016 udev: input_id: tag pointing sticks as ID_INPUT_POINTINGSTICK
Also referred to as trackpoint, trackstick. These are marked by recent kernels
through an input prop. Forward that prop as udev property so userspace can
easily determine whether there is a pointing stick present.

These devices were previously marked as ID_INPUT_MOUSE, for backwards
compatibility we keep that in place, the new property is an addition.y

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:47:01 -04:00
Tom Gundersen
ae871637ad sd-device,udevd: fix spelling /ammend/amend/
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:45:15 -04:00
Tom Gundersen
5902f9fc08 udev: net_id - improve comments
The dev_port concept is a bit confusing, expand on the comment a bit.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:43:42 -04:00
Tom Gundersen
2b14e318ed udev: net_id - support multi-port enpo* device names
I'd argue that having firmware labels for such devices makes
no sense, but they exist, so make sure we handle them as best
as we can.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:42:56 -04:00
Tom Gundersen
9315261b19 udev: net_id - fix copy-paste error
In case pci_slot overflows we were truncating pci_path instead.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:41:21 -04:00
Harald Hoyer
59e0bf6c1f cdrom_id: unroll and simplify data check loop
also removes this warning:

src/udev/cdrom_id/cdrom_id.c: In function ‘cd_media_info.isra.13’:
src/udev/cdrom_id/cdrom_id.c:612:12: warning: assuming signed overflow
does not occur when assuming that (X + c) >= X is always true
[-Wstrict-overflow]
 static int cd_media_info(struct udev *udev, int fd)
            ^

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:40:28 -04:00
Thomas Hindoe Paaboel Andersen
39de7639b4 libudev-util: check length before accesing the array
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:35:50 -04:00
Anthony G. Basile
9dfdc62113 skip libudev: device - replace by a thin wrapper around sd-device
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:34:56 -04:00
Tom Gundersen
c48e712fee libudev: monitor - improve logging
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:29:00 -04:00
Anthony G. Basile
b97ee4d944 Merge branch 'master' of github.com:gentoo/eudev 2015-04-12 11:22:31 -04:00
Harald Hoyer
288fc0a1fb 50-udev-default.rules: don't run anything but REMOVE_CMD on remove
we don't want to run usb_id and input_id on ACTION=="remove"

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:22:21 -04:00
Mantas Mikulėnas
8f2f61f0a3 rules: storage - support MemoryStick (non-Pro) cards
These are handled by a different driver than MemoryStick Pro.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:21:14 -04:00
Kay Sievers
c0823e9525 rules: storage - whitelist partitioned MS & MMC devices
On Mon, Mar 23, 2015 at 8:55 AM, Mantas Mikulėnas <grawity@gmail.com> wrote:
> On Tue, Mar 17, 2015 at 11:50 PM, Kay Sievers <kay@vrfy.org> wrote:
>> On Tue, Mar 17, 2015 at 5:00 PM, Mantas Mikulėnas <grawity@gmail.com>
>> wrote:
>> > Accidentally dropped in 1aff20687f4868575.
>> > ---
>> >  rules/60-persistent-storage.rules | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> > +KERNEL!="loop*|mmcblk[0-9]*|mspblk[0-9]*|nvme*|sd*|sr*|vd*",
>> > GOTO="persistent_storage_end"
>>
>> We can't do that, we need to ignore the mmc*rpmb devices:
>>
>> http://cgit.freedesktop.org/systemd/systemd/commit/?id=b87b01cf83947f467f3c46d9831cd67955fc46b9
>>
>> Maybe "mmcblk*[0-9]" will work?
>
> Yeah, that would probably work (the names are like mmcblk0p1 etc.)

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:20:15 -04:00
Tom Gundersen
bf6e9fab7b rules: storage - don't apply rules to remove events
This line was accidentally lost in 52346b5f5424.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:19:21 -04:00
David Herrmann
7457718859 rules: avoid 'device/' accesses
We should never access parents, as the sysfs hierarchy is in no way
stable. Use KERNELS== etc. to match on a parent, then access it via
$attr{} (which accesses the matching device, not the current device).

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:18:38 -04:00
David Herrmann
d8e2e4c3a4 rules: fix input-name for keyboard rules
We match on the evdev node, but only the parent has a "name" attribute.
Use $attr{device/name} to access it.

This is borked since 2013, I wonder how that ever worked? Maybe this will
suddenly fix all the DMI-based key detections.

Thanks to Peter Hutterer for catching this!

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:18:11 -04:00
Blaž Tomažič
cb26a75abd hwdb: mouse DPI data, Roccat Lua (ROC-11-310)
https://bugs.freedesktop.org/show_bug.cgi?id=89743

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:18:11 -04:00
Marcel Holtmann
c810c02115 hwdb: Update database of Bluetooth company identifiers
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:18:04 -04:00
Zbigniew Jędrzejewski-Szmek
db9611f269 hwdb: add HP ProBook 450G0
https://bugs.freedesktop.org/show_bug.cgi?id=89684

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12 11:17:59 -04:00
blueness
20ec2e9549 Merge pull request #113 from yann-morin-1998/yem/legacy-gcc
Revert "udev: rules - modernise add_rule a bit"
2015-04-09 06:54:09 -04:00
Yann E. MORIN
d2aeb8b63d Revert "udev: rules - modernise add_rule a bit"
Initialisers for anonymous unions are unknown to gcc-4.5, which is still
quite widely used.

See the following build failure, reported by the Buildroot autobuilders:
    http://autobuild.buildroot.org/results/11e/11ebb926b891862e270b9cb39fd2ed4344b736a8/build-end.log

This reverts commit 5cb9807847.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Tom Gundersen <teg@jklm.no>
2015-04-04 14:02:20 +02:00
David Cortarello
6a398265f3 Remove hardcoded path /run and configure using --with-rootrundir=
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-27 11:34:13 -04:00
Anthony G. Basile
3cda11ed7c configure.ac: update udev version to 219. 2015-03-19 19:34:33 -04:00
Anthony G. Basile
ed4a3602ea src/libudev/Makefile.am: bump libudev revision to 2
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-19 17:58:41 -04:00
Michal Schmidt
252b174d23 shared: add path_compare(), an ordering path comparison
... and make path_equal() a simple wrapper around it.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-19 16:54:15 -04:00
Kay Sievers
c42184ebda sysctl: move property handling to shared/
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-19 16:40:25 -04:00
Tom Gundersen
0199ac5afb libudev: private - introduce udev_device_new_from_synthetic_event()
This allows set_action(), read_uevent_file() and read_db() to be made internal to libudev.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18 21:34:18 -04:00
Zbigniew Jędrzejewski-Szmek
9b2f02162b libudev-monitor: use initialization
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18 21:31:26 -04:00
Will Woods
59b6fb3b75 selinux: fix SEGV during switch-root if SELinux policy loaded
If you've got SELinux policy loaded, label_hnd is your labeling handle.
When systemd is shutting down, we free that handle via mac_selinux_finish().

But: switch_root() calls mkdir_p_label(), which tries to look up a label
using that freed handle, and so we get a bunch of garbage and eventually
SEGV in libselinux.

(This doesn't happen in the switch-root from initramfs to real root because
there's no SELinux policy loaded in initramfs, so label_hnd is NULL and we
never attempt any lookups.)

So: make sure that mac_selinux_finish() actually sets label_hnd to NULL, so
nobody tries to use it after it becomes invalid.

https://bugzilla.redhat.com/show_bug.cgi?id=1185604

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18 21:15:17 -04:00
Zbigniew Jędrzejewski-Szmek
c45230b3b0 Check that EWOULDBLOCK is the same as EAGAIN
It certainly is everywhere on Linux, but as a courtesy
to people doing some strange cross-compilation, check
that the assumption holds.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18 21:13:53 -04:00
Anthony G. Basile
f5625ab8c6 Replace ENOTSUP with EOPNOTSUPP
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18 21:09:57 -04:00
Shawn Landden
3a864f5e04 udev-ctrl: fix strict aliasing issues
it is ironic that
"The only purpose of this structure is to cast the structure pointer
passed in addr in order to avoid compiler warnings.  See EXAMPLE below."
from bind(2)

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18 21:01:30 -04:00
Zbigniew Jędrzejewski-Szmek
8c6168fcba udev: downgrade "has devpath" and "filled with db file" messages
Udev debug messages have to be significantly overhauled... For now
just downgrade those two. They are responsible for approximately 25%
of debug output during boot and are rather useless.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18 21:00:19 -04:00
Zbigniew Jędrzejewski-Szmek
96010518c6 udev: properly calculate size of remaining data
The data comes from the kernel, so chances of it being
garbled are low, but for correctness' sake, add the check.

CID #996458.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18 20:58:30 -04:00
Tom Gundersen
89fe48ab02 udev: make set_usec_initialized() internal to libudev
Instead introduce ensure_usec_initialized(), which copies the timestamp if possible otherwise
sets it to now(CLOCK_MONOTONIC).

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18 20:55:21 -04:00
Harald Hoyer
35ef251e16 path-util: fix path_is_mount_point() for symlinks
path_is_mount_point() compares the mount_id of a directory and the
mount_id of the parent directory. When following symlinks, the function
to get the parent directory does not take the symlink into account.

/bin -> /usr/bin with /usr being a mountpoint:
mount_id of /bin with AT_SYMLINK_FOLLOW != mount_id of /

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18 20:51:19 -04:00
Tom Gundersen
16ded21814 udevd: improve handling of failed worker
The information in the db is stale, so it does not make sense to
expose it any longer. Also, don't drop the kernel event, but simply
pass it on to userspace without ammending it.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18 20:43:21 -04:00