diff options
Diffstat (limited to '')
-rw-r--r-- | src/shared/udev-util.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c index 29484226c6..a5ed8e8f6b 100644 --- a/src/shared/udev-util.c +++ b/src/shared/udev-util.c @@ -42,3 +42,26 @@ int udev_parse_config(void) { return 0; } + +int udev_device_new_from_stat_rdev(struct udev *udev, const struct stat *st, struct udev_device **ret) { + struct udev_device *nd; + char type; + + assert(udev); + assert(st); + assert(ret); + + if (S_ISBLK(st->st_mode)) + type = 'b'; + else if (S_ISCHR(st->st_mode)) + type = 'c'; + else + return -ENOTTY; + + nd = udev_device_new_from_devnum(udev, type, st->st_rdev); + if (!nd) + return -errno; + + *ret = nd; + return 0; +} |