#include "udev.h"
#include "udev_version.h"
#include "namedev.h"
+#include "udevdb.h"
#include "libsysfs/libsysfs.h"
/*
* 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;
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];
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);