summaryrefslogtreecommitdiffstats
path: root/src/udev/udevadm-info.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* extract-word: modernize extract_many_wordsMike Yuan2024-03-031-1/+1
|
* udev: fix typo for persistent flagjanana2023-10-271-1/+1
| | | The 'parsistent' adjective is misspelt.
* udev: Enable filtering the output of udevadm info --export-dbDaan De Meyer2023-10-161-30/+206
| | | | | | | | | | Let's support the same filtering options that we also support in udevadm trigger in udevadm info to filter the devices produced by --export-db. One difference is that all properties specified by --propery-match= have to be satisfied in udevadm info unlike udevadm trigger where just one of them has to be satisfied.
* Add --json switch to udevadm infoDaan De Meyer2023-10-161-4/+78
| | | | | This allows getting the udevadm info --export-db and query "all" output as JSON.
* device-util: Declare iterator variables inlineDaan De Meyer2023-07-121-11/+10
|
* udev-util: make device_wait_for_initialization() take relative timeoutYu Watanabe2022-08-311-1/+1
| | | | Also make the timer event source floating.
* udevadm info: use pager for all output typesZbigniew Jędrzejewski-Szmek2022-06-221-1/+4
| | | | | Before we used the pager for --tree, but not e.g. for --export-db. I don't see any particular reason to limit this.
* udevadm info: implement --no-pagerZbigniew Jędrzejewski-Szmek2022-06-221-2/+9
|
* udevadm: info: also show parent devices by --treeYu Watanabe2022-04-171-0/+7
|
* udevadm: use xopendirat() where appropriateLennart Poettering2022-04-131-8/+13
| | | | | | | | | | | And while we are at it, let's use more appropriate open flags. O_NONBLOCk is pointless in combination with O_NOFOLLOW. O_NOFOLLOW makes a ton of sense otoh, since the inode is supposed to be a dir, we just checked. THe other flags are implied by xopendirat()
* udevadm: add new --tree mode to "udevadm info"Lennart Poettering2022-04-131-21/+194
| | | | sysfs is a tree, hence let's a mode that allows showing it as such.
* udevadm: if invalid devices are specified on "info" verb, continueLennart Poettering2022-04-041-6/+13
| | | | | | If multiple devices are specified on "udevadm info", then show data about them all even if one is missing. Return first encountered error though.
* udevadm: add a dash of color to "udevadm info"Lennart Poettering2022-04-041-14/+27
| | | | | | Let's make it easier to discern the "header" of device records from the "body", i.e. non-property data from property data, by using some conservative coloring.
* udevadm: show more fields of sd_device objects in "udevadm info"Lennart Poettering2022-04-041-9/+43
| | | | | | Let's make things easier to debug, and show a more comprehensive set of fields, extending on the existing output syntax that starts with one marker character followed by a colon and a space.
* tree-wide: add a space after if, switch, for, and whileYu Watanabe2022-04-011-1/+1
|
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-1/+0
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* udevadm: don't claim a sysattr was write only just because we get EPERM on readLennart Poettering2022-02-021-2/+3
| | | | | | | | it might be totally inaccessible, hence weaken our language a bit and just say "not readable", thus making not claim whether it is writable or not. Follow-up for 3a90bef55a5a71a03629a762470b0f9014cd8453
* udevadm: add more assertionsYu Watanabe2022-01-211-5/+18
|
* udevadm: simplify the code of removing udev state filesYu Watanabe2022-01-211-20/+10
|
* udevadm: split assertionsYu Watanabe2022-01-211-3/+4
| | | | Then we can easily find which pointer is NULL.
* udevadm: do not remove watch directoryYu Watanabe2022-01-211-4/+3
| | | | See the comment in the code.
* udevadm: cleanup-db: don't delete information for kept db entriesMartin Wilck2022-01-211-3/+59
| | | | | | | | | | | | | | | | devices with the db_persist property won't be deleted during database cleanup. This applies to dm and md devices in particular. For such devices, we should also keep the files under /run/udev/links, /run/udev/tags, and /run/udev/watch, to make sure that after restart, udevd has the same information about the devices as it did before the cleanup. If we don't do this, a lower-priority device that is discovered in the coldplug phase may take over symlinks from a device that persisted. Not removing the watches also enables udevd to resume watching a device after restart. Signed-off-by: Martin Wilck <mwilck@suse.com>
* udevadm: cleanup_dir: use dot_or_dot_dot()Martin Wilck2022-01-211-2/+4
| | | | | which is safer than just checking dent[0]. Also, fix two style issues.
* Merge pull request #21786 from keszybz/dirent-workYu Watanabe2021-12-161-2/+0
|\ | | | | Make FOREACH_DIRENT and FOREACH_DIRENT_ALL declare the iterator variables
| * tree-wide: make FOREACH_DIRENT_ALL define the iterator variableZbigniew Jędrzejewski-Szmek2021-12-151-2/+0
| | | | | | | | | | | | | | | | | | The variable is not useful outside of the loop (it'll always be null after the loop is finished), so we can declare it inline in the loop. This saves one variable declaration and reduces the chances that somebody tries to use the variable outside of the loop. For consistency, 'de' is used everywhere for the var name.
* | udevadm: also show write-only attributesYu Watanabe2021-12-141-10/+15
|/
* udev: teach udevadm --property=NAME and --value optionsFrantisek Sumsal2021-09-291-14/+55
| | | | | which allows limiting the properties listed by the `--query=property` option (and optionally listing only the respective values).
* udev: sort the options alphabeticallyFrantisek Sumsal2021-09-291-7/+7
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-3/+3
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | We recently started making more use of malloc_usable_size() and rely on it (see the string_erase() story). Given that we don't really support sytems where malloc_usable_size() cannot be trusted beyond statistics anyway, let's go fully in and rework GREEDY_REALLOC() on top of it: instead of passing around and maintaining the currenly allocated size everywhere, let's just derive it automatically from malloc_usable_size(). I am mostly after this for the simplicity this brings. It also brings minor efficiency improvements I guess, but things become so much nicer to look at if we can avoid these allocation size variables everywhere. Note that the malloc_usable_size() man page says relying on it wasn't "good programming practice", but I think it does this for reasons that don't apply here: the greedy realloc logic specifically doesn't rely on the returned extra size, beyond the fact that it is equal or larger than what was requested. (This commit was supposed to be a quick patch btw, but apparently we use the greedy realloc stuff quite a bit across the codebase, so this ends up touching *a*lot* of code.)
* udev: delete useless codesgaoyi2021-04-141-2/+0
| | | | It seems no one will touch queue.bin
* tree-wide: Drop custom formatting for print() help messagesDaan De Meyer2021-01-311-2/+2
| | | | | | | | | | | | I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by https://github.com/systemd/systemd/pull/18355#discussion_r567241580
* license: GPL-2.0+ -> GPL-2.0-or-laterYu Watanabe2020-11-091-1/+1
|
* udev-util: use absolute rather than relative timeout when waiting for devicesLennart Poettering2020-10-221-1/+5
| | | | This makes it easier to accurately wait for a overall deadline.
* udev: fix codesonar warningsAmitanand.Chikorde2020-07-301-1/+1
| | | | | | | | | | | | Fixed below systemd codesonar warning. isprint() is invoked here with an argument of signed type char, but only has defined behavior for int arguments that are either representable as unsigned char or equal to the value of macro EOF(-1). As per codesonar report, in a number of libc implementations, isprint() function implemented using lookup tables (arrays): passing in a negative value can result in a read underrun.
* udevadm: use STR_IN_SET(), add commentZbigniew Jędrzejewski-Szmek2020-07-161-11/+9
|
* udevadm: sort entries in `udevadm info -a` by attribute nameYu Watanabe2020-07-031-25/+52
|
* udevadm: show more error message during exporting databaseYu Watanabe2020-02-271-4/+4
| | | | Closes #14959.
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-031-1/+0
|
* udevadm: ensure 'udevadm info -w' show updated resultYu Watanabe2019-07-111-1/+6
| | | | This seems not necessary, but just for safety.
* udevadm: add --wait-for-initialization option to "udevadm info"Yu Watanabe2019-06-031-13/+32
|
* udevadm: drop unused optionYu Watanabe2019-04-041-1/+1
|
* udev: use string_table_lookup() where we canLennart Poettering2019-03-221-6/+3
|
* udevadm info: "-a" should enumerate sysfs attributes, not envs (#11642)Mantas Mikulėnas2019-02-051-1/+4
| | | This fixes a bug introduced by 13aca847695f49afeb93367ecdad76035fa6c139.
* udevadm info: make --export-prefix imply --exportYu Watanabe2019-01-221-0/+1
| | | | Setting --export without --export-prefix is meaningless.
* udevadm: use SYNTHETIC_ERRNO() macroYu Watanabe2019-01-121-4/+2
|
* Delete duplicate linesTopi Miettinen2019-01-121-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Found by inspecting results of running this small program: int main(int argc, const char **argv) { for (int i = 1; i < argc; i++) { FILE *f; char line[1024], prev[1024], *r; int lineno; prev[0] = '\0'; lineno = 1; f = fopen(argv[i], "r"); if (!f) exit(1); do { r = fgets(line, sizeof(line), f); if (!r) break; if (strcmp(line, prev) == 0) printf("%s:%d: error: dup %s", argv[i], lineno, line); lineno++; strcpy(prev, line); } while (!feof(f)); fclose(f); } }
* udevadm: allow multiple arguments to "info"Zbigniew Jędrzejewski-Szmek2018-12-111-39/+44
| | | | | This matches udevadm trigger, which allows multiple arguments since 80877656a55.
* udevadm: allow a .device unit to be specified for query and triggerZbigniew Jędrzejewski-Szmek2018-12-111-1/+1
| | | | | | | | | This is convenient when working with device units in systemd. Instead of converting the systemd unit name to a path to feed to udevadm, udevadm info|trigger can be called directly on the unit name. The man page is reworked a bit to describe the modern syntax with positional arguments first. It's just simpler to use than the positional options.
* udevadm: use path_startswith and shorten code a bitZbigniew Jędrzejewski-Szmek2018-12-111-21/+19
|