summaryrefslogtreecommitdiff
path: root/src/udev/cdrom_id
Commit message (Collapse)AuthorAgeFilesLines
* udev: implement --version in all builtinsZbigniew Jędrzejewski-Szmek2023-03-161-7/+11
| | | | | | | | | | | | | | | | Those are separate binaries, and occasionally people will get a misplaced binary that doesn't match the rest of the installed system and be confused, so it good to be able to check the version. It is also nice to have the same interface in all binaries. Note that we usually use a separate 'enum ARG_VERSION = 0x100' for an option without a short name. We can use a less verbose approach of simply taking any unused letter, which works just as well and even the compiler would warn us if we tried to use the letter in another place. This way we avoid a few lines of boilerplate. The help texts are adjusted to have an empty line between the synopsis and option list, and no empty lines after the option list.
* udev/cdrom_id: do not abort on unknown optionsZbigniew Jędrzejewski-Szmek2023-03-161-0/+2
| | | | Copy-pasta is good, but you have to pick a reliable source.
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* udev: always open with O_NOCTTYYu Watanabe2022-09-101-1/+1
| | | | | All files or device nodes opened here should not be console tty. Let's open it the flags for safety.
* tree-wide: Fix format specifier warnings for %xJan Janssen2022-08-301-4/+4
| | | | | | Unfortunately, hex output can only be produced with unsigned types. Some cases can be fixed by producing the correct type, but a few simply have to be cast. At least casting makes it explicit.
* udev/cdrom_id: check last track infoYu Watanabe2022-08-151-1/+1
| | | | | | Fixes off-by-one issue. Fixes #24306.
* tree-wide: add a space after if, switch, for, and whileYu Watanabe2022-04-011-1/+1
|
* udev/cdrom_id: use a macro to initialize contextZbigniew Jędrzejewski-Szmek2021-11-231-13/+7
| | | | | | c was initialized unconditionally, but one has to look at the function body to understand this. Let's make the whole thing shorter and more direct.
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-1/+1
| | | | | | | | | | | | | | | | | 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/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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/cdrom_id: add forgotten return and fix typoZbigniew Jędrzejewski-Szmek2021-04-191-8/+8
| | | | Fixup for 092c05717c.
* udev/cdrom_id: use random_u64_range() and tweak log messagesZbigniew Jędrzejewski-Szmek2021-04-191-24/+23
| | | | https://github.com/systemd/systemd/pull/19317#pullrequestreview-637765222
* udev/cdrom_id: drop unnecessary cleanup and simplify loopZbigniew Jędrzejewski-Szmek2021-04-151-11/+9
|
* udev/cdrom_id: do not pass ioctl return value to log_debug_errno()Zbigniew Jędrzejewski-Szmek2021-04-151-2/+15
| | | | While at it, let's print the tray status in human readable form.
* tree-wide: use -EINVAL for enum invalid valuesZbigniew Jędrzejewski-Szmek2021-02-101-2/+2
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617. This does not touch anything exposed in src/systemd. Changing the defines there would be a compatibility break. Note that tests are broken after this commit. They will be fixed in the next one.
* udev/cdrom_id: re-enable logging related functionsYu Watanabe2021-01-201-0/+5
| | | | | | The logging related functions are mistakenly located in main() by a084b3878955bc1b93adcaa7a41acb83b18eff9b, and dropped by 23afa884d4f3bcd97160a893816f9ba170f62ad4.
* udev: use DEFINE_MAIN_FUNCTION in cdrom_idDan Streetman2021-01-201-14/+2
| | | | | | | | This was failing s390x ubuntu ci due to an old version of binutils; the binutils package in use for ubuntu ci tests has been updated and the build no longer fails, so this can use the macro again. Fixes: #18165
* udev/cdrom: split main() into main() and run()Yu Watanabe2021-01-081-23/+26
| | | | | However, we do not use DEFINE_MAIN_FUNCTION() here, as ubuntu s390x CI does not like it...
* udev/cdrom: drop unnecessary headersYu Watanabe2021-01-081-12/+0
|
* udev/cdrom: drop never hit conditionYu Watanabe2021-01-081-2/+0
|
* udev/cdrom: void()ify several function callsYu Watanabe2021-01-081-7/+7
|
* udev/cdrom: tighten variable scope used in loopYu Watanabe2021-01-081-27/+27
|
* udev/cdrom: use unaligned_read_be32() or friendsYu Watanabe2021-01-081-10/+11
|
* udev/cdrom: split cd_media_info() into small piecesYu Watanabe2021-01-081-95/+113
|
* udev/cdrom: introduce enum for media stateYu Watanabe2021-01-081-18/+40
|
* udev/cdrom: move media status to ContextYu Watanabe2021-01-081-34/+35
|
* udev/cdrom: introduce enum for media and drive featureYu Watanabe2021-01-081-636/+279
|
* udev/cdrom: introduce ContextYu Watanabe2021-01-081-49/+94
|
* udev/cdrom: make cd_profiles() return positive value if drive has mediaYu Watanabe2021-01-081-15/+14
|
* udev/cdrom: make media_lock() return negative errnoYu Watanabe2021-01-081-9/+5
|
* udev/cdrom: introduce scsi_cmd_run_and_log()Yu Watanabe2021-01-081-99/+99
|
* udev/cdrom: use random_u64() and usleep()Yu Watanabe2021-01-081-7/+3
|
* udev/cdrom: split out parse_argv() and help()Yu Watanabe2021-01-081-49/+58
|
* udev: Updates for cdrom_id helperpali2020-12-221-28/+312
| | | | | | | | cdrom_id udev helper does not parse all MMC profiles. Following change fixes this issue and parse all 34 profiles from all MMC standard versions. Also it replaces magic constants by macros provided by linux/cdrom.h and fixes cd_profiles_old_mmc() to issue READ_DISC_INFO command in two steps, like it is doing kernel and also mkudffs.
* license: GPL-2.0+ -> GPL-2.0-or-laterYu Watanabe2020-11-091-1/+1
|
* udev/cdrom_id: Do not open CD-rom in exclusive mode.Michal Suchanek2019-10-241-23/+1
| | | | | | | | | | | | | | When you have a CD automunt solution that talks directly to the kernel independently of udev it races with cdrom_id for exclusive access to the device failing unpredictably. The whole is_mounted function in cdrom_id is broken: there is no saying what happens between calling is_mounted and opening the device. Hence assume that the device can be mounted asynchronously at any time, do not use exclusive access, and do away with is_mouted. Signed-off-by: Michal Suchanek <msuchanek@suse.de>
* udev: do not hardcode program nameDavid Tardon2019-10-111-2/+3
|
* udev/cdrom_id: drop unneeded parenthesesZbigniew Jędrzejewski-Szmek2019-05-011-20/+18
|
* udev: drop unnecessary bracketsYu Watanabe2019-04-301-10/+6
| | | | Follow-up for ed0cb346821972ec2c505ee11ed3d383aba6256e.
* Merge pull request #12420 from mrc0mmand/coccinelle-tweaksLennart Poettering2019-04-301-14/+11
|\ | | | | Coccinelle improvements
| * tree-wide: code improvements suggested by CoccinelleFrantisek Sumsal2019-04-301-12/+9
| |
| * tree-wide: replace explicit NULL checks with their shorter variantsFrantisek Sumsal2019-04-281-2/+2
| | | | | | | | Done by coccinelle/equals-null.cocci
* | codespell: fix spelling errorsBen Boeckel2019-04-291-1/+1
|/
* tree-wide: constify a few static string tablesLennart Poettering2019-03-251-1/+1
|
* util: split out memcmp()/memset() related calls into memory-util.[ch]Lennart Poettering2019-03-131-1/+1
| | | | Just some source rearranging.
* tree-wide: replace 'unsigned int' with 'unsigned'Yu Watanabe2018-10-191-56/+56
|
* udev/cdrom_id: drop duplicated logsYu Watanabe2018-09-101-2/+0
|
* udev/cdrom_id: drop unused udev structYu Watanabe2018-09-101-133/+110
|
* tree-wide: drop empty lines in commentsYu Watanabe2018-07-231-2/+0
|
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-1/+0
| | | | | | | | 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