chiark / gitweb /
[PATCH] udev: mode should be mode_t
[elogind.git] / udev-add.c
index 586815e2c794386b0c720528f3d94b6a92b775b6..d158c41b1d54adbc138a28d9ea098f1e855c9a95 100644 (file)
@@ -31,6 +31,7 @@
 #include "udev.h"
 #include "udev_version.h"
 #include "namedev.h"
+#include "udevdb.h"
 #include "libsysfs/libsysfs.h"
 
 
@@ -70,7 +71,7 @@ exit:
 /*
  * We also want to add some permissions here, and possibly some symlinks
  */
-static int create_node(char *name, char type, int major, int minor, int mode)
+static int create_node(char *name, char type, int major, int minor, mode_t mode)
 {
        char filename[255];
        int retval = 0;
@@ -92,14 +93,15 @@ static int create_node(char *name, char type, int major, int minor, int mode)
                return -EINVAL;
        }
 
-       retval = mknod(filename,mode,makedev(major,minor));
+       dbg("mknod(%s, %#o, %u, %u)", filename, mode, major, minor);
+       retval = mknod(filename, mode, makedev(major, minor));
        if (retval)
                dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
                    filename, mode, major, minor, strerror(errno));
        return retval;
 }
 
-struct sysfs_class_device *get_class_dev(char *device_name)
+static struct sysfs_class_device *get_class_dev(char *device_name)
 {
        char sysfs_path[SYSFS_PATH_MAX];
        char dev_path[SYSFS_PATH_MAX];
@@ -161,10 +163,16 @@ int udev_add_device(char *device, char *subsystem)
 
        retval = get_major_minor(class_dev, &major, &minor);
        if (retval) {
-               dbg ("get_major_minor failed");
+               dbg("get_major_minor failed");
                goto exit;
        }
 
+       retval = udevdb_add_device(device, class_dev, attr.name, type, major, minor, attr.mode);
+
+       if (retval != 0)
+               dbg("udevdb_add_device failed, but we are going to try to create the node anyway. "
+                   "But remove might not work properly for this device.");
+
        sysfs_close_class_device(class_dev);
 
        return create_node(attr.name, type, major, minor, attr.mode);