]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/udev/udevadm-util.c
1 /* SPDX-License-Identifier: GPL-2.0+ */
4 #include "string-util.h"
5 #include "udevadm-util.h"
7 struct udev_device
*find_device(struct udev
*udev
,
13 if (prefix
&& !startswith(id
, prefix
))
14 id
= strjoina(prefix
, id
);
16 if (path_startswith(id
, "/dev/")) {
20 if (stat(id
, &statbuf
) < 0)
23 if (S_ISBLK(statbuf
.st_mode
))
25 else if (S_ISCHR(statbuf
.st_mode
))
30 return udev_device_new_from_devnum(udev
, type
, statbuf
.st_rdev
);
31 } else if (path_startswith(id
, "/sys/"))
32 return udev_device_new_from_syspath(udev
, id
);