Commit Graph

10980 Commits

Author SHA1 Message Date
Boian Bonev
5f98fb38c1
Merge branch 'master' into hwdb-bin-file-environment 2023-10-01 00:04:32 +03:00
Vivien Kraus
c7da117e5c Let libudev find hwdb.bin under UDEV_HWDB_BIN
* src/libudev/libudev-hwdb.c (get_hwdb_bin_paths): New function,
replacing hwdb_bin_paths.
(struct udev_hwdb): New bin_paths field.
(udev_hwdb_new): Initialize it with get_hwdb_bin_paths.
(udev_hwdb_validate): Use the bin_paths field to find hwdb.bin.
(udev_hwdb_unref): Free the bin_paths field.
* src/libudev/libudev.h: Warn about UDEV_HWDB_BIN.
* man/udev.xml: Mention run-time UDEV_HWDB_BIN.
* man/udev.7: Re-generate.
2023-09-30 19:36:55 +02:00
Boian Bonev
19aa81d9bf
Regenerate according to 0cf14fb and e5e4013 2023-09-30 16:55:44 +00:00
Boian Bonev
e5e4013cb7
Move the changes from udev.7 to udev.xml
Commit 0cf14fb changed only the generated udev.7 without touching the
source file udev.xml
2023-09-30 16:52:12 +00:00
Boian Bonev
072d94137f
Merge pull request #257 from bbonev/issue256
Fix := not preventing further assignments to RUN
2023-09-30 19:18:50 +03:00
Boian Bonev
0d86dd9a2a
Merge pull request #260 from bbonev/usrlocal
Add /usr/local/lib/udev/rules.d
2023-09-12 00:10:06 +02:00
Boian Bonev
298ef249e3
Add /usr/local/lib/udev/rules.d
Closes #259
2023-09-11 19:15:17 +03:00
Boian Bonev
f49af0b03b
Fix := not preventing further assignments to RUN
Closes #256

Suggested by: Aksel Lunde Aase
2023-08-31 23:46:56 +00:00
NaofumiHonda
b9cc389aab
Clear sysattr cache if a null pointer is passed (#255)
* Clear sysattr cache if a null pointer is passed

* remove tabs
2023-08-21 18:17:45 +03:00
Boian Bonev
ffc1b77871
Update as per IRC discussion 2023-05-30 16:16:33 +00:00
Boian Bonev
2703baf556
Include unaligned.h in dist 2023-05-16 15:08:56 +00:00
Boian Bonev
490b90da5a
Merge branch 'master' of github.com:eudev-project/eudev 2023-05-16 14:18:09 +00:00
Boian Bonev
ee12a0afd7
Prepare a release of 3.2.12 2023-05-16 14:17:36 +00:00
Boian Bonev
39979ddf46
Merge pull request #247 from cockroach/master
Fix compile-time issue on very old kernels
2023-04-06 21:40:29 +03:00
Stefan Ott
09b536e0b9 Fix compile-time issue on very old kernels
Kernel versions prior to 3.4 did not have V4L2_CAP_DEVICE_CAPS and
compiling against such a kernel will fail.

This patch introduces a version check and makes eudev fall back to
v2cap.capabilities on these kernels.
2023-04-05 18:20:37 +02:00
Boian Bonev
9bcbc131a6
Merge pull request #240 from bbonev/missing-tools
Missing tools
2023-02-18 02:29:39 +02:00
Boian Bonev
8bc3169766
Merge pull request #246 from omnivagant/udev-7-mention-split-usr
man: udev.7, mention /usr/lib with split-usr
2023-02-18 02:28:48 +02:00
omni
0cf14fbdce man: udev.7, mention /usr/lib with split-usr 2023-02-04 13:39:20 +00:00
Boian Bonev
c2a042eb1d
Allocate udev struct 2022-11-13 03:59:04 +02:00
Ralph Ronnquist
0d94554d9e Rewrite using current API 2022-11-13 03:42:29 +02:00
Boian Bonev
b359e32d07
WIP not compilable fido_id 2022-10-04 17:39:05 +03:00
Boian Bonev
6836c0e9a2
Rework dmi_memory_id from systemd 2022-10-04 17:38:38 +03:00
Boian Bonev
99b0381c85
Merge pull request #238 from bbonev/fix-free-nonheap-object
Do not free a static string
2022-10-03 14:36:17 +03:00
Boian Bonev
bebf651fbf
Merge pull request #239 from bbonev/sd-pr-24353
Systemd PR 24353
2022-09-22 21:48:14 +03:00
Boian Bonev
1c10b23250
Do not initialize dynamic string with static value
- the value is unused anyways
- thanks to Arsen for spotting this

In file included from udevadm-hwdb.c:26:
In function ‘freep’,
    inlined from ‘adm_hwdb’ at udevadm-hwdb.c:624:38:
../../src/shared/util.h:289:9: warning: ‘free’ called on a pointer to an unallocated object ‘"/usr/etc/udev/hwdb.bin"’ [-Wfree-nonheap-object]
  289 |         free(*(void**) p);
      |         ^~~~~~~~~~~~~~~~~
../../src/shared/util.h:289:9: warning: ‘free’ called on a pointer to an unallocated object ‘"/usr/etc/udev/hwdb.bin"’ [-Wfree-nonheap-object]
2022-09-22 01:45:31 +03:00
Boian Bonev
189f05e874
Revert "Do not free a static string"
This reverts commit e4bbbc8e36.
2022-09-22 01:43:19 +03:00
Boian Bonev
152456e741
udev: hwdb: Add rules to match cros-ec-accel by 'location' sysfs file
The cros-ec-accel devices report their mounting location by the 'label'
sysfs file only since Linux v6.0. With earlier kernels, a nonstandard
'location' file reports this, but slightly differently (lid instead of
display) [1].

Add udev rules to import the correct hwdb entries based on this
'location' file for cros-ec-accel devices, so that the base-mounted
accel matrix has the correct value for older kernels as well.

[1] https://kernel.org/doc/Documentation/ABI/testing/sysfs-bus-iio-cros-ec

systemd-commit ac3c031e3862e3d74e64b108e0bafcaefa71c792
Author: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Date:   Thu Aug 18 19:56:13 2022 +0300
2022-09-22 01:29:51 +03:00
Boian Bonev
9f366b943d
hwdb: Add Chromebook accel orientation quirks based on sysfs label
The base-mounted accelerometer on Chromebooks return values same as the
display when the lid angle is 180 degrees, instead of when the lid is
closed. To match userspace expectations we must further rotate the
existing accelerometer mounting matrix by 180 degrees around the X axis:

    [[-1,  0,  0],    [[ 1,  0,  0],    [[-1,  0,  0],
     [ 0, -1,  0],  X  [ 0, -1,  0],  =  [ 0,  1,  0],
     [ 0,  0, -1]]     [ 0,  0, -1]]     [ 0,  0,  1]]

A previous commit lets us distinguish between the two cros-ec-accel
devices on these boards by their 'label' sysfs file. Add hwdb entries
that make base-mounted accelerometers use this correct matrix, and
display-mounted ones use the existing one.

Note that the cros-ec-accel drivers use 'label' only since Linux v6.0.
The old match strings are not removed to support older kernels, even
though they are only correct for the display-mounted sensor.

systemd-commit fea267f8c71d0edffee5ccbb806755fb626c5e29
Author: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Date:   Thu Aug 18 18:24:05 2022 +0300
2022-09-22 01:28:34 +03:00
Boian Bonev
fa741e87a8
udev: hwdb: Match iio sensors based on their label
The IIO subsystem exposes a 'label' sysfs file to help userspace better
identify its devices [1]. Standardized labels include the sensor type
along with its location, including 'accel-base' and 'accel-display'.

Most Chrome OS boards have two accelerometers that are indistinguishable
except for this label (or a 'location' sysfs file before Linux v6.0),
and need different mounting matrix corrections based on their location.

Add a udev rule that matches hwdb entries using this label, so we can
correct both accelerometers on these devices with hwdb entries. The
existing rules and hwdb entries are not modified to keep potential
out-of-tree entries working, but new entries in this form will override
existing ones. Also add currently standardized labels to parse-hwdb.py.

[1] https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-iio

systemd-commit e2f25ae64889ea7fe8a7556ee5fba91bc2a0eab8
Author: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Date:   Thu Aug 18 17:27:22 2022 +0300
2022-09-22 01:17:17 +03:00
Boian Bonev
e4bbbc8e36
Do not free a static string
In file included from udevadm-hwdb.c:26:
In function ‘freep’,
    inlined from ‘adm_hwdb’ at udevadm-hwdb.c:624:38:
../../src/shared/util.h:289:9: warning: ‘free’ called on a pointer to an unallocated object ‘"/usr/etc/udev/hwdb.bin"’ [-Wfree-nonheap-object]
  289 |         free(*(void**) p);
      |         ^~~~~~~~~~~~~~~~~
../../src/shared/util.h:289:9: warning: ‘free’ called on a pointer to an unallocated object ‘"/usr/etc/udev/hwdb.bin"’ [-Wfree-nonheap-object]
2022-09-22 00:51:17 +03:00
Boian Bonev
ba2cff9c54
Prepare a pre-release of 3.2.12-pre3 2022-06-14 02:44:42 +03:00
Boian Bonev
91066e4a66
Merge pull request #233 from bbonev/time32warn
Avoid warning on 32bit
2022-06-12 12:26:25 +03:00
Boian Bonev
da0ca7eb21
Avoid warning on 32bit
On 32bit arches where time_t is defined as long int and where
sizeof(long)==sizeof(int), PRI_TIME is PRIu32 which is "u" and gcc warns about
ignoring the long part of the integer type. There is no problem besides the
warning.

Upcast time_t to 64bit and get rid of PRI_TIME and configure checks

udevadm-monitor.c: In function ‘print_device’:
udevadm-monitor.c:49:16: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘__time_t’ {aka ‘long int’} [-Wformat=]
   49 |         printf("%-6s[%"PRI_TIME".%06ld] %-8s %s (%s)\n",
      |                ^~~~~~~~
   50 |                source,
   51 |                ts.tv_sec, ts.tv_nsec/1000,
      |                ~~~~~~~~~
      |                  |
      |                  __time_t {aka long int}
In file included from ../../src/shared/macro.h:26,
                 from udev.h:26,
                 from udevadm-monitor.c:35:
/usr/include/inttypes.h:104:19: note: format string is defined here
  104 | # define PRIu32  "u"
2022-06-11 17:43:28 +03:00
Boian Bonev
2c969a36db
Revert "Avoid warning on 32bit"
This reverts commit b1de2b70bc.
2022-06-11 17:42:31 +03:00
Boian Bonev
b1de2b70bc
Avoid warning on 32bit
On 32bit arches where time_t is defined as long int and where
sizeof(long)==sizeof(int), PRI_TIME is PRIu32 which is "u" and gcc warns about
ignoring the long part of the integer type. There is no problem besides the
warning.

Use "lu" in the above conditions and PRIu32 in all other 32bit time_t cases.

udevadm-monitor.c: In function ‘print_device’:
udevadm-monitor.c:49:16: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘__time_t’ {aka ‘long int’} [-Wformat=]
   49 |         printf("%-6s[%"PRI_TIME".%06ld] %-8s %s (%s)\n",
      |                ^~~~~~~~
   50 |                source,
   51 |                ts.tv_sec, ts.tv_nsec/1000,
      |                ~~~~~~~~~
      |                  |
      |                  __time_t {aka long int}
In file included from ../../src/shared/macro.h:26,
                 from udev.h:26,
                 from udevadm-monitor.c:35:
/usr/include/inttypes.h:104:19: note: format string is defined here
  104 | # define PRIu32  "u"
2022-06-10 04:03:00 +03:00
Boian Bonev
dd6b068a56
Prepare a pre-release of 3.2.12-pre2 2022-06-10 02:09:47 +03:00
Boian Bonev
3211655fd8
Merge pull request #232 from bbonev/buffers
Fix problems detected by fortified builds
2022-06-09 20:55:13 +03:00
Boian Bonev
54d0df107e
Use snprintf (for posterity)
Also fix code style of sizeof()

Suggested-by: Arsen Arsenović <arsen@aarsen.me>
2022-06-09 20:08:33 +03:00
Boian Bonev
20f79fab0f
Add error checking
lseek and ftruncate may fail; do not continue the processing if that happens

Suggested-by: Arsen Arsenović <arsen@aarsen.me>
2022-06-09 20:01:17 +03:00
Boian Bonev
fe9bac1092
Change prepare to never return an unlocked fd
- fix coding style while at it
- add checks and fail in case lockf failed

Suggested-by: Arsen Arsenović <arsen@aarsen.me>
2022-06-09 19:50:12 +03:00
Boian Bonev
9bffb8a8cc
Do not try to lock a negative fd 2022-06-09 19:24:05 +03:00
Boian Bonev
07afd28617
Mark as safe to ignore
Suggested-by: Arsen Arsenović <arsen@aarsen.me>
2022-06-09 19:16:07 +03:00
Boian Bonev
74b5af522e
Fix code style
Suggested-by: Arsen Arsenović <arsen@aarsen.me>
2022-06-09 19:03:34 +03:00
Boian Bonev
1833f76239
Increase the path buffer and fail on truncation
Add a check to avoid creating files with path that may be truncated
2022-06-08 08:28:31 +03:00
Boian Bonev
aaa76e5173
Kill warnings for unused result
ftruncate and lockf are declared with attribute ‘warn_unused_result’.
Kill the warning and add a TODO comment.
2022-06-08 08:24:40 +03:00
Boian Bonev
ed95424f74
Refuse to generate truncated USB modalias
In case of invalid input the resulting modalias would exceed the buffer and be
truncated. Add checks to avoid generating truncated modalias.
2022-06-08 08:20:08 +03:00
Boian Bonev
9f99dba5a0
Avoid buffer overrun with long version strings
This condition may happen with version as 3.2.12-pre1 which would generate
udev-3.2.12-pre1 with length of 17 including the terminating 0, while
struct udev_ctrl.version is only 16 bytes
2022-06-08 08:13:23 +03:00
Boian Bonev
49222bcc9c
Build and install hwdb.7 man page 2022-06-08 02:41:44 +03:00
Boian Bonev
f566c4ae32
Merge the generated man page 2022-06-06 16:30:50 +03:00
Boian Bonev
8bf47b7dfb
Prepare a pre-release of 3.2.12-pre1 2022-06-06 16:14:03 +03:00