along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdbool.h>
#include <unistd.h>
#include <fcntl.h>
-#include <string.h>
#include <sys/stat.h>
#include "libudev.h"
int udev_device_update_db(struct udev_device *udev_device)
{
- struct udev *udev = udev_device_get_udev(udev_device);
bool has_info;
const char *id;
char filename[UTIL_PATH_SIZE];
strscpyl(filename_tmp, sizeof(filename_tmp), filename, ".tmp", NULL);
mkdir_parents(filename_tmp, 0755);
f = fopen(filename_tmp, "we");
- if (f == NULL) {
- udev_err(udev, "unable to create temporary db file '%s': %m\n", filename_tmp);
- return -1;
- }
+ if (f == NULL)
+ return log_debug_errno(errno, "unable to create temporary db file '%s': %m", filename_tmp);
/*
* set 'sticky' bit to indicate that we should not clean the
}
if (udev_device_get_usec_initialized(udev_device) > 0)
- fprintf(f, "I:%llu\n", (unsigned long long)udev_device_get_usec_initialized(udev_device));
+ fprintf(f, "I:"USEC_FMT"\n", udev_device_get_usec_initialized(udev_device));
udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device)) {
if (!udev_list_entry_get_num(list_entry))
r = rename(filename_tmp, filename);
if (r < 0)
return -1;
- udev_dbg(udev, "created %s file '%s' for '%s'\n", has_info ? "db" : "empty",
+ log_debug("created %s file '%s' for '%s'", has_info ? "db" : "empty",
filename, udev_device_get_devpath(udev_device));
return 0;
}
if (id == NULL)
return -1;
strscpyl(filename, sizeof(filename), "/run/udev/data/", id, NULL);
+
unlink(filename);
return 0;
}