Commit Graph

59 Commits

Author SHA1 Message Date
Yu Watanabe 530a715ea9 udev/cdrom: introduce enum for media state 2021-01-08 14:08:38 +00:00
Yu Watanabe 97b2248475 udev/cdrom: move media status to Context 2021-01-08 14:08:38 +00:00
Yu Watanabe 38f3e20883 udev/cdrom: introduce enum for media and drive feature 2021-01-08 14:08:38 +00:00
Yu Watanabe e5aac5cdf1 udev/cdrom: introduce Context 2021-01-08 14:08:38 +00:00
Yu Watanabe 0f0b079135 udev/cdrom: make cd_profiles() return positive value if drive has media 2021-01-08 14:08:38 +00:00
Yu Watanabe 138dd9545a udev/cdrom: make media_lock() return negative errno 2021-01-08 14:08:38 +00:00
Yu Watanabe 4fe9ab406e udev/cdrom: introduce scsi_cmd_run_and_log() 2021-01-08 14:08:38 +00:00
Yu Watanabe 511ff06e99 udev/cdrom: use random_u64() and usleep() 2021-01-08 14:08:38 +00:00
Yu Watanabe 56c1a2977b udev/cdrom: split out parse_argv() and help() 2021-01-08 14:08:38 +00:00
pali 5fc3b26125 udev: Updates for cdrom_id helper
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.
2020-12-22 15:21:29 +09:00
Yu Watanabe f13467ec23 license: GPL-2.0+ -> GPL-2.0-or-later 2020-11-09 13:25:50 +09:00
Michal Suchanek 14cd12b3d5 udev/cdrom_id: Do not open CD-rom in exclusive mode.
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>
2019-10-24 00:09:18 +02:00
David Tardon 9e385314b0 udev: do not hardcode program name 2019-10-11 14:45:02 +02:00
Zbigniew Jędrzejewski-Szmek 64538af89b udev/cdrom_id: drop unneeded parentheses 2019-05-01 11:46:42 +02:00
Yu Watanabe 8b803ad634 udev: drop unnecessary brackets
Follow-up for ed0cb34682.
2019-04-30 19:10:35 +02:00
Lennart Poettering 0892f3f999
Merge pull request #12420 from mrc0mmand/coccinelle-tweaks
Coccinelle improvements
2019-04-30 11:37:19 +02:00
Frantisek Sumsal ed0cb34682 tree-wide: code improvements suggested by Coccinelle 2019-04-30 09:39:07 +02:00
Ben Boeckel 5238e95759 codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
Frantisek Sumsal 4e361acc06 tree-wide: replace explicit NULL checks with their shorter variants
Done by coccinelle/equals-null.cocci
2019-04-28 14:28:49 +02:00
Lennart Poettering b82f71c7ff tree-wide: constify a few static string tables 2019-03-25 14:04:34 +01:00
Lennart Poettering 0a9707187b util: split out memcmp()/memset() related calls into memory-util.[ch]
Just some source rearranging.
2019-03-13 12:16:43 +01:00
Yu Watanabe 14cb109d45 tree-wide: replace 'unsigned int' with 'unsigned' 2018-10-19 22:19:12 +02:00
Yu Watanabe f1ff9e8dd9 udev/cdrom_id: drop duplicated logs 2018-09-10 18:27:36 +09:00
Yu Watanabe 20a744b795 udev/cdrom_id: drop unused udev struct 2018-09-10 18:27:36 +09:00
Yu Watanabe f330408d62 tree-wide: drop empty lines in comments 2018-07-23 08:44:24 +02: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
Zbigniew Jędrzejewski-Szmek 50d1760d26 Drop more license boilerplate
$ git grep -e 'This program is free software' -l |grep -v LICENSE | \
  xargs perl -i -0pe 's/ \* This program.*?for more details.\s*\*\n( \* You should have.*licenses.>.\n)?//gms'

For some reason they were missed previously. All those files seem to
have proper SDPX tags.
2018-06-14 13:05:41 +02:00
Lennart Poettering 810adae9e9 tree-wide: use proper unicode © instead of (C) where we can
Let's use a proper unicode copyright symbol where we can, it's prettier.

This important patch is very important.
2018-06-14 10:20:20 +02:00
Zbigniew Jędrzejewski-Szmek 87ac8d998f tree-wide: use "cannot" instead of "can not"
This is the usual spelling, and a bit shorter.
2018-02-08 10:34:52 +01:00
Zbigniew Jędrzejewski-Szmek e7145211c7 Add SPDX license identifiers to source files under the GPL 2017-11-19 19:08:15 +01:00
Yu Watanabe 4c70109600 tree-wide: use IN_SET macro (#6977) 2017-10-04 16:01:32 +02:00
Zbigniew Jędrzejewski-Szmek b237a168df Rip out setting of the log level from udev_new and put it in a new function
This function is internal to systemd code, so external users of libudev
will not see those log messages. I think this is better. If we want to
allow that, the function could be put in libudev and exported.

v2: check that the string is more than one char before stripping quotes
2017-05-07 22:49:12 -04: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 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
Lennart Poettering 57255510c9 tree-wide: replace while(1) by for(;;) everywhere
Another Coccinelle script.
2015-09-09 14:59:53 +02:00
Lennart Poettering 1f6b411372 tree-wide: update empty-if coccinelle script to cover empty-while and more
Let's also clean up single-line while and for blocks.
2015-09-09 14:59:51 +02:00
Thomas Hindoe Paaboel Andersen 756775814c tree-wide: do not return error codes as bool 2015-08-06 00:49:45 +02:00
Ronny Chevalier 3df3e884ae shared: add random-util.[ch] 2015-04-11 00:11:13 +02:00
Harald Hoyer cb80d06c74 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)
            ^
2015-03-27 14:57:38 +01:00
Robert Milasan 257e968d8c udev: improve help/usage for some more programs 2015-01-01 14:38:21 -05:00
Thomas Hindoe Paaboel Andersen c4ef05484d use correct format types 2014-12-11 21:47:06 +01:00
Kay Sievers 25e773eeb4 udev: switch to systemd logging functions 2014-11-13 13:12:57 +01:00
Lennart Poettering ef309a681f util: unify how we see srand() 2014-10-30 15:35:37 +01:00
Zbigniew Jędrzejewski-Szmek 3fcd09602c cdrom_id: do not attempt to read past end of buffer
CID #1238437
2014-10-27 22:30:43 -04:00
Lennart Poettering 5168f84a29 udev: never bypass our own logging framework and call vsyslog() directly from udev tools 2014-08-11 20:13:38 +02:00
Lukas Nykryn a14f149760 cdrom_id: use the old MMC fallback
https://bugzilla.redhat.com/show_bug.cgi?id=1038015
The problem seems to be that the your virtual DVD is emulating a really
old DVD device, and doing it kind of strangely.

> dracut:# /lib/udev/cdrom_id --debug /dev/sr0
> probing: '/dev/sr0'
> INQUIRY: [IMM     ][Virtual CD/DVD   ][0316]
> GET CONFIGURATION failed with SK=5h/ASC=24h/ACQ=00h

So your virtual drive rejects the GET CONFIGURATION command as illegal.

Other pre-MMC2 drives that don't accept this command usually return the
error
SK=5h,ASC=20h (invalid/unsupported command code), in which case cdrom_id
tries an older method, and then ID_CDROM_MEDIA_TRACK_COUNT_DATA gets set
and all the /dev/disk/by-label (etc) links get set up.

The virtual drive returns the error SK=5h,ASC=24h (invalid field in
Command Descriptor Block), which cdrom_id doesn't handle, so it gives up
and the links never get made.

The ideal solution would be to make the IMM to emulate a device that's
less than 15 years old, but I'm not going to hold my breath waiting for
that.

So probably cdrom_id should also use the old MMC fallback when the error
is SK=5h,ASC=24h, and then all of this would work as expected.

Suggested-by:Luca Miccini <lmiccini@redhat.com>
2014-02-27 11:12:04 +01:00
Lennart Poettering c8a202b7d4 everywhere: always use O_CLOEXEC where it makes sense 2014-02-13 14:59:56 +01:00
Greg KH 29804cc1e0 use memzero(foo, length); for all memset(foo, 0, length); calls
In trying to track down a stupid linker bug, I noticed a bunch of
memset() calls that should be using memzero() to make it more "obvious"
that the options are correct (i.e. 0 is not the length, but the data to
set).  So fix up all current calls to memset(foo, 0, length) to
memzero(foo, length).
2014-01-31 11:55:01 +01:00
Lennart Poettering 9f6445e34a log: log_error() and friends add a newline after each line anyway, so avoid including it in the log strings 2013-12-24 16:39:37 +01:00