#include "udev.h"
#include "udev_version.h"
+#include "namedev.h"
static char *get_action(void)
temp = getenv("DEVPATH");
if (temp == NULL)
return NULL;
- strcpy(device, SYSFS_ROOT);
+ strcpy(device, "");
+// strcpy(device, SYSFS_ROOT);
strcat(device, temp);
return device;
return unlink(filename);
}
-static int add_device(char *device, char type)
+static int add_device(char *device, char type, struct device_attr *attr)
{
char *name;
int major;
int minor;
int mode;
int retval = -EINVAL;
-
+#if 0
retval = get_major_minor(device, &major, &minor);
if (retval) {
dbg ("get_major_minor failed");
retval = -EINVAL;
goto exit;
}
-
- return create_node(name, type, major, minor, mode);
+#endif
+ return create_node(attr->name, type, attr->major, attr->minor, attr->mode);
exit:
return retval;
int main(int argc, char *argv[])
{
+ struct device_attr attr;
char *subsystem;
char *action;
char *device;
goto exit;
}
+ namedev_init();
+
+ /* sleep for a second or two to give the kernel a chance to
+ * create the dev file
+ */
+ sleep(2);
+
/* for now, the block layer is the only place where block devices are */
subsystem = argv[1];
if (strcmp(subsystem, "block") == 0)
}
dbg("looking at %s", device);
+ retval = namedev_name_device(device, &attr);
+ if (retval)
+ return retval;
+
if (strcmp(action, "add") == 0)
- return add_device(device, type);
+ return add_device(device, type, &attr);
if (strcmp(action, "remove") == 0)
return remove_device(device);