mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
sd-device: introduce device_has_db() helper function
This commit is contained in:
@@ -809,6 +809,19 @@ static int device_get_db_path(sd_device *device, char **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int device_has_db(sd_device *device) {
|
||||
_cleanup_free_ char *path = NULL;
|
||||
int r;
|
||||
|
||||
assert(device);
|
||||
|
||||
r = device_get_db_path(device, &path);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return access(path, F_OK) >= 0;
|
||||
}
|
||||
|
||||
int device_update_db(sd_device *device) {
|
||||
_cleanup_(unlink_and_freep) char *path = NULL, *path_tmp = NULL;
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
|
||||
@@ -59,6 +59,7 @@ int device_clone_with_db(sd_device *device, sd_device **ret);
|
||||
|
||||
int device_tag_index(sd_device *dev, sd_device *dev_old, bool add);
|
||||
bool device_should_have_db(sd_device *device);
|
||||
int device_has_db(sd_device *device);
|
||||
int device_update_db(sd_device *device);
|
||||
int device_delete_db(sd_device *device);
|
||||
int device_read_db_internal_filename(sd_device *device, const char *filename); /* For fuzzer */
|
||||
|
||||
Reference in New Issue
Block a user