- strncpy(filename, UDEV_ROOT, sizeof(filename));
- strncat(filename, name, sizeof(filename));
- if (type == 'b') {
- mode |= S_IFBLK;
- } else if ((type == 'c') || (type == 'u')){
- mode |= S_IFCHR;
- } else if ( type == 'p') {
- mode |= S_IFIFO;
- } else {
- dbg("unknown node type %c\n", type);
- return -1;
- }
-
- retval = mknod(filename,mode,makedev(major,minor));
+
+ strncpy(filename, udev_root, sizeof(filename));
+ strncat(filename, dev->name, sizeof(filename));
+
+ switch (dev->type) {
+ case 'b':
+ dev->mode |= S_IFBLK;
+ break;
+ case 'c':
+ case 'u':
+ dev->mode |= S_IFCHR;
+ break;
+ case 'p':
+ dev->mode |= S_IFIFO;
+ break;
+ default:
+ dbg("unknown node type %c\n", dev->type);
+ return -EINVAL;
+ }
+
+ dbg("mknod(%s, %#o, %u, %u)", filename, dev->mode, dev->major, dev->minor);
+ retval = mknod(filename, dev->mode, makedev(dev->major, dev->minor));
+ if (retval)
+ dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
+ filename, dev->mode, dev->major, dev->minor, strerror(errno));
+
+ // FIXME set the ownership of the node