#include "udev.h"
#include "smack-util.h"
-static int node_symlink(struct udev_device *dev, const char *node, const char *slink)
-{
+static int node_symlink(struct udev_device *dev, const char *node, const char *slink) {
struct stat stats;
char target[UTIL_PATH_SIZE];
char *s;
}
/* find device node of device with highest priority */
-static const char *link_find_prioritized(struct udev_device *dev, bool add, const char *stackdir, char *buf, size_t bufsize)
-{
+static const char *link_find_prioritized(struct udev_device *dev, bool add, const char *stackdir, char *buf, size_t bufsize) {
struct udev *udev = udev_device_get_udev(dev);
DIR *dir;
int priority = 0;
}
/* manage "stack of names" with possibly specified device priorities */
-static void link_update(struct udev_device *dev, const char *slink, bool add)
-{
- struct udev *udev = udev_device_get_udev(dev);
+static void link_update(struct udev_device *dev, const char *slink, bool add) {
char name_enc[UTIL_PATH_SIZE];
char filename[UTIL_PATH_SIZE * 2];
char dirname[UTIL_PATH_SIZE];
if (target == NULL) {
log_debug("no reference left, remove '%s'", slink);
if (unlink(slink) == 0)
- util_delete_path(udev, slink);
+ rmdir_parents(slink, "/");
} else {
log_debug("creating link '%s' to '%s'", slink, target);
node_symlink(dev, target, slink);
}
}
-void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev_old)
-{
+void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev_old) {
struct udev_list_entry *list_entry;
/* update possible left-over symlinks */
if ((stats.st_mode & 0777) != (mode & 0777) || stats.st_uid != uid || stats.st_gid != gid) {
log_debug("set permissions %s, %#o, uid=%u, gid=%u", devnode, mode, uid, gid);
- chmod(devnode, mode);
- chown(devnode, uid, gid);
+ err = chmod(devnode, mode);
+ if (err < 0)
+ log_warning("setting mode of %s to %#o failed: %m", devnode, mode);
+ err = chown(devnode, uid, gid);
+ if (err < 0)
+ log_warning("setting owner of %s to uid=%u, gid=%u failed: %m", devnode, uid, gid);
} else {
log_debug("preserve permissions %s, %#o, uid=%u, gid=%u", devnode, mode, uid, gid);
}
link_update(dev, udev_list_entry_get_name(list_entry), true);
}
-void udev_node_remove(struct udev_device *dev)
-{
+void udev_node_remove(struct udev_device *dev) {
struct udev_list_entry *list_entry;
char filename[UTIL_PATH_SIZE];