1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-10 01:17:44 +03:00

sd-device: introduce device_new_from_stat_rdev()

This commit is contained in:
Yu Watanabe 2018-08-22 14:00:53 +09:00
parent 3c1f2cee0a
commit ad5944d71c
2 changed files with 18 additions and 0 deletions

View File

@ -843,6 +843,22 @@ int device_new_from_synthetic_event(sd_device **new_device, const char *syspath,
return 0;
}
int device_new_from_stat_rdev(sd_device **ret, const struct stat *st) {
char type;
assert(ret);
assert(st);
if (S_ISBLK(st->st_mode))
type = 'b';
else if (S_ISCHR(st->st_mode))
type = 'c';
else
return -ENOTTY;
return sd_device_new_from_devnum(ret, type, st->st_rdev);
}
int device_copy_properties(sd_device *device_dst, sd_device *device_src) {
const char *property, *value;
int r;

View File

@ -3,12 +3,14 @@
#include <inttypes.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "sd-device.h"
int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len);
int device_new_from_strv(sd_device **ret, char **strv);
int device_new_from_stat_rdev(sd_device **ret, const struct stat *st);
int device_get_id_filename(sd_device *device, const char **ret);