Commit Graph

58 Commits

Author SHA1 Message Date
Yu Watanabe 9a56b87717 udev: move util_path_encode() and rename it to escape_path() 2020-12-16 02:14:47 +09:00
Yu Watanabe 5953d8b910 udev: move util_replace_whitespace() to udev-util.c 2020-12-16 02:14:47 +09:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Lennart Poettering 6b000af4f2 tree-wide: avoid some loaded terms
https://tools.ietf.org/html/draft-knodel-terminology-02
https://lwn.net/Articles/823224/

This gets rid of most but not occasions of these loaded terms:

1. scsi_id and friends are something that is supposed to be removed from
   our tree (see #7594)

2. The test suite defines an API used by the ubuntu CI. We can remove
   this too later, but this needs to be done in sync with the ubuntu CI.

3. In some cases the terms are part of APIs we call or where we expose
   concepts the kernel names the way it names them. (In particular all
   remaining uses of the word "slave" in our codebase are like this,
   it's used by the POSIX PTY layer, by the network subsystem, the mount
   API and the block device subsystem). Getting rid of the term in these
   contexts would mean doing some major fixes of the kernel ABI first.

Regarding the replacements: when whitelist/blacklist is used as noun we
replace with with allow list/deny list, and when used as verb with
allow-list/deny-list.
2020-06-25 09:00:19 +02:00
Zbigniew Jędrzejewski-Szmek 92e068b465 basic/utf8: do not read past end of string when looking for a multi-byte character
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9341.
2019-02-26 12:37:40 +01:00
Yu Watanabe 577ab71c58 libudev-util: make util_replace_whitespace() read only len characters
This effectively reverts df8ba4fa0e.

Fixes #11264.
2019-01-03 15:10:57 +01:00
Yu Watanabe 3839535a53 libudev: make util_resolve_subsys_kernel() return negative errno
This also replaces udev_device by sd_device in the function.
2018-11-21 17:31:16 +09:00
Yu Watanabe df8ba4fa0e libudev-util: make util_replace_whitespace() not count leading white spaces 2018-11-21 17:30:45 +09:00
Yu Watanabe 646acebd58 libudev-util: make util_replace_*() return size_t 2018-11-21 16:35:20 +09:00
Yu Watanabe 805a7097ee libudev-util: add assertions 2018-11-21 16:32:54 +09:00
Yu Watanabe f921b457a7 libudev: coding style fixes 2018-11-20 14:38:35 +09:00
Yu Watanabe 5ea78a39e5 libudev-list: move libudev-list related definitions to libudev-list-internal.h
This also rename libudev-private.h to libudev-util.h, and cleanups
several unnecessary headers from udev.h and libudev-util.h
2018-11-20 14:38:35 +09:00
Yu Watanabe 46f0fbd8fd udev: drop util_log_priority() and use log_level_from_string()
The function util_log_priority() is almost same as
log_level_from_string(). The difference between them is only that
util_log_priority() accepts such that '3 hogehoge'.
2018-11-12 23:25:40 +09:00
Yu Watanabe e39b4d254d libudev: re-implement udev-monitor by sd_device_monitor 2018-10-17 03:31:20 +09:00
Yu Watanabe 1544d17f73 libudev-util: adjust type of returned value by util_string_hash32() 2018-09-10 18:27:36 +09:00
Yu Watanabe 755c3fe9a7 libudev-util: drop unnecessary argument 'struct udev *udev' from util_resolve_subsys_kernel() 2018-09-10 18:27:36 +09:00
Zbigniew Jędrzejewski-Szmek d9b02e1697 tree-wide: drop copyright headers from frequent contributors
Fixes #9320.

for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do
  git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms'
done
2018-06-20 11:58:53 +02:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
Let's unify an beautify our remaining copyright statements, with a
unicode ©. This means our copyright statements are now always formatted
the same way. Yay.
2018-06-14 10:20:21 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Lennart Poettering 7546145e26 string-util: add delete_trailing_chars() and skip_leading_chars() helpers
And let's port over a couple of users to the new APIs.
2017-11-13 10:47:15 +01:00
Dan Streetman be45268352 udev-event: use in-place whitespace replacement
Instead of using a temp buffer to replace whitespace in variable
substitutions, just allow util_replace_whitespace to replace in-place.
Add a comment to util_replace_whitespace indicating it is used to replace
in-place, to prevent accidental future breakage.
2017-01-27 07:58:00 -05:00
Dan Streetman a9d99b32a3 libudev-util: change util_replace_whitespace to return number of chars in dest
Instead of returning 0, which is unhelpful, return the number of chars
copied into the dest string.  This allows callers that care about that
to easily use it, instead of having to calculate the strlen.

No current users of the function check the return value, so this does not
break any existing code; it is used in the following patch.
2017-01-03 17:09:46 -05:00
Thomas Hindoe Paaboel Andersen b4bbcaa9c4 tree-wide: group include of libudev.h with sd-* 2015-11-17 07:06:08 +01:00
Thomas Hindoe Paaboel Andersen cf0fbc49e6 tree-wide: sort includes
Sort the includes accoding to the new coding style.
2015-11-16 22:09:36 +01:00
Lennart Poettering 7ccbd1ae84 util-lib: split out syslog-related calls into syslog-util.[ch] 2015-10-27 13:25:57 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.

This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.

Also touches a few unrelated include files.
2015-10-24 23:05:02 +02:00
Thomas Hindoe Paaboel Andersen b250ea2fd6 tree-wide: remove unused functions 2015-10-19 21:46:01 +02:00
Thomas Hindoe Paaboel Andersen 4835f5639a libudev-util: check length before accesing the array 2015-04-05 08:46:01 +02:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
This patch removes includes that are not used. The removals were found with
include-what-you-use which checks if any of the symbols from a header is
in use.
2015-02-23 23:53:42 +01:00
Michal Schmidt ff49bc3212 treewide: drop unnecessary trailing \n in log_*() calls 2014-11-28 14:26:31 +01:00
Kay Sievers 25e773eeb4 udev: switch to systemd logging functions 2014-11-13 13:12:57 +01:00
Zbigniew Jędrzejewski-Szmek ee7122c0ec libudev: do not accept invalid log levels
Invalid log levels lead to a assert failure later on.

https://bugs.freedesktop.org/show_bug.cgi?id=85657
2014-11-01 14:39:47 -04:00
Tom Gundersen ba7408a6e9 udev: util - use log_level_from_string() 2014-09-16 12:12:56 +02:00
Tom Gundersen 37d522746b libudev: util - drop util_delete_path()
Use rmdir_parents() from src/shared instead.
2014-09-16 12:12:56 +02:00
Tom Gundersen 23bf8dd7d5 libudev: drop util_lookup_{user,group}
Use shared versions instead. Difference is with overwriting of repeated user/group
name, and lack of logging.
2014-09-16 12:12:56 +02:00
Tom Gundersen 9d19a679f2 udev - drop print_kmsg
The only remaining user was 'starting version XXX', which is now logged using log_info().
2014-09-09 22:48:57 +02:00
Tom Gundersen ac9c87dbc4 Revert "libudev: use get_*_creds from shared rather than util_lookup_*"
This reverts commit a56ba6158b.

The commit was pushed in error.
2014-08-01 22:33:20 +02:00
Tom Gundersen a56ba6158b libudev: use get_*_creds from shared rather than util_lookup_* 2014-08-01 16:34:50 +02:00
Lennart Poettering 955d98c9c1 everywhere: make use of new0() and macro() macros, and stop using perror() 2014-02-13 14:45:51 +01:00
Kay Sievers 57d0e6b273 libudev: ship the original MurmurHash2.[ch] file 2013-12-23 02:55:06 +01:00
Dave Reisner 8f6ce71fe7 device-nodes: move device node specific code to own file
In the process, rename udev_encode_string which is poorly named for what
it does. It deals specifically with encoding names that udev creates and
has its own rules: utf8 is valid but some ascii is not (e.g. path
separators), and everything else is simply escaped. Rename it to
encode_devnode_name.
2013-09-19 11:50:34 -04:00
Dave Reisner 02a36bc9a1 move utf8 functions from libudev-private.h to utf8.h
There's now some more obvious overlap amongst the two utf8 validation
functions, but no more than there already was previously.

This also adds some menial tests for anyone who wants to do more
merging of these two in the future.
2013-09-17 16:31:32 -04:00
Zbigniew Jędrzejewski-Szmek 4dd1de72e8 Remove some dead code
Based on coverity report.
2013-03-31 14:28:36 -04:00
Jan Engelhardt acd42fae59 libudev: avoid potential misaligned accesses
clang reports:
  src/libudev/libudev-util.c:665:35: warning: cast from
  "const unsigned char *" to "unsigned int *" increases required alignment
  from 1 to 4 [-Wcast-align]
2013-03-20 16:18:04 +01:00
Thomas Hindoe Paaboel Andersen 090be86534 use streq instead of strcmp 2013-02-13 18:14:20 +01:00
Kay Sievers d5a89d7dc1 udev: move string copy functions to shared/ 2013-01-09 19:06:46 +01:00
Kay Sievers 1328f66ad1 udev: net_id - append "dev_id" value if needed 2013-01-04 19:08:08 +01:00
Kay Sievers 88a6477ef3 libudev: update copyright headers 2012-11-12 17:50:33 +01:00