+ char filename[NAME_SIZE];
+ char linkname[NAME_SIZE];
+ char linktarget[NAME_SIZE];
+ char partitionname[NAME_SIZE];
+ uid_t uid = 0;
+ gid_t gid = 0;
+ int i;
+ int tail;
+ char *pos;
+ int len;
+
+ strfieldcpy(filename, udev_root);
+ strfieldcat(filename, dev->name);
+
+ 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;
+ }
+
+ /* create parent directories if needed */
+ if (strrchr(dev->name, '/'))
+ create_path(filename);
+
+ if (dev->owner[0] != '\0') {
+ char *endptr;
+ unsigned long id = strtoul(dev->owner, &endptr, 10);
+ if (endptr[0] == '\0')
+ uid = (uid_t) id;
+ else {
+ struct passwd *pw;
+ if (strncmp(dev->owner, LOCAL_USER, sizeof(LOCAL_USER)) == 0)
+ set_to_local_user(dev->owner);
+
+ pw = getpwnam(dev->owner);
+ if (pw == NULL)
+ dbg("specified user unknown '%s'", dev->owner);
+ else
+ uid = pw->pw_uid;
+ }
+ }
+
+ if (dev->group[0] != '\0') {
+ char *endptr;
+ unsigned long id = strtoul(dev->group, &endptr, 10);
+ if (endptr[0] == '\0')
+ gid = (gid_t) id;
+ else {
+ struct group *gr = getgrnam(dev->group);
+ if (gr == NULL)
+ dbg("specified group unknown '%s'", dev->group);
+ else
+ gid = gr->gr_gid;
+ }
+ }
+
+ if (!fake) {
+ info("creating device node '%s'", filename);
+ if (make_node(filename, dev->major, dev->minor, dev->mode, uid, gid) != 0)
+ goto error;
+ } else {
+ info("creating device node '%s', major = '%d', minor = '%d', "
+ "mode = '%#o', uid = '%d', gid = '%d'", filename,
+ dev->major, dev->minor, (mode_t)dev->mode, uid, gid);
+ }
+
+ /* create all_partitions if requested */
+ if (dev->partitions > 0) {
+ info("creating device partition nodes '%s[1-%i]'", filename, dev->partitions);
+ if (!fake) {
+ for (i = 1; i <= dev->partitions; i++) {
+ strfieldcpy(partitionname, filename);
+ strintcat(partitionname, i);
+ make_node(partitionname, dev->major,
+ dev->minor + i, dev->mode, uid, gid);
+ }
+ }
+ }
+
+ /* create symlink(s) if requested */
+ foreach_strpart(dev->symlink, " ", pos, len) {
+ strfieldcpymax(linkname, pos, len+1);
+ strfieldcpy(filename, udev_root);
+ strfieldcat(filename, linkname);
+ dbg("symlink '%s' to node '%s' requested", filename, dev->name);
+ if (!fake)
+ if (strrchr(linkname, '/'))
+ create_path(filename);