]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/udev/udevadm-util.c
1 /* SPDX-License-Identifier: GPL-2.0+ */
5 #include "alloc-util.h"
6 #include "device-private.h"
8 #include "udevadm-util.h"
10 int find_device(const char *id
, const char *prefix
, sd_device
**ret
) {
11 _cleanup_free_
char *buf
= NULL
;
16 if (prefix
&& !path_startswith(id
, prefix
)) {
17 buf
= path_join(NULL
, prefix
, id
);
23 if (path_startswith(id
, "/sys/"))
24 return sd_device_new_from_syspath(ret
, id
);
26 if (path_startswith(id
, "/dev/")) {
29 if (stat(id
, &st
) < 0)
32 return device_new_from_stat_rdev(ret
, &st
);