]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/udev/udevadm-util.c
1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright © 2008-2009 Kay Sievers <kay@vrfy.org>
8 #include "string-util.h"
9 #include "udevadm-util.h"
11 struct udev_device
*find_device(struct udev
*udev
,
18 if (prefix
&& !startswith(id
, prefix
))
19 id
= strjoina(prefix
, id
);
21 if (path_startswith(id
, "/dev/")) {
25 if (stat(id
, &statbuf
) < 0)
28 if (S_ISBLK(statbuf
.st_mode
))
30 else if (S_ISCHR(statbuf
.st_mode
))
35 return udev_device_new_from_devnum(udev
, type
, statbuf
.st_rdev
);
36 } else if (path_startswith(id
, "/sys/"))
37 return udev_device_new_from_syspath(udev
, id
);