1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-14 05:57:40 +03:00

udevadm: use path friendly functions

This commit is contained in:
Yu Watanabe 2018-10-22 13:46:35 +09:00
parent 269c3b67c6
commit b753e14ac8

View File

@ -2,17 +2,23 @@
#include <errno.h>
#include "alloc-util.h"
#include "device-private.h"
#include "path-util.h"
#include "string-util.h"
#include "udevadm-util.h"
int find_device(const char *id, const char *prefix, sd_device **ret) {
_cleanup_free_ char *buf = NULL;
assert(id);
assert(ret);
if (prefix && !startswith(id, prefix))
id = strjoina(prefix, id);
if (prefix && !path_startswith(id, prefix)) {
buf = path_join(NULL, prefix, id);
if (!buf)
return -ENOMEM;
id = buf;
}
if (path_startswith(id, "/sys/"))
return sd_device_new_from_syspath(ret, id);