+static int make_node(char *filename, int major, int minor, unsigned int mode, uid_t uid, gid_t gid)
+{
+ int retval;
+
+ retval = mknod(filename, mode, makedev(major, minor));
+ if (retval != 0) {
+ dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
+ filename, mode, major, minor, strerror(errno));
+ return retval;
+ }
+
+ dbg("chmod(%s, %#o)", filename, mode);
+ retval = chmod(filename, mode);
+ if (retval != 0) {
+ dbg("chmod(%s, %#o) failed with error '%s'",
+ filename, mode, strerror(errno));
+ return retval;
+ }
+
+ if (uid != 0 || gid != 0) {
+ dbg("chown(%s, %u, %u)", filename, uid, gid);
+ retval = chown(filename, uid, gid);
+ if (retval != 0) {
+ dbg("chown(%s, %u, %u) failed with error '%s'",
+ filename, uid, gid, strerror(errno));
+ return retval;
+ }
+ }
+
+ return 0;
+}
+
+/* get the local logged in user */
+static void set_to_local_user(char *user)
+{
+ struct utmp *u;
+ time_t recent = 0;
+
+ strnfieldcpy(user, default_owner_str, OWNER_SIZE);
+ setutent();
+ while (1) {
+ u = getutent();
+ if (u == NULL)
+ break;
+
+ /* is this a user login ? */
+ if (u->ut_type != USER_PROCESS)
+ continue;
+
+ /* is this a local login ? */
+ if (strcmp(u->ut_host, ""))
+ continue;
+
+ if (u->ut_time > recent) {
+ recent = u->ut_time;
+ strnfieldcpy(user, u->ut_user, OWNER_SIZE);
+ dbg("local user is '%s'", user);
+ break;
+ }
+ }
+ endutent();
+}
+
+/* Used to unlink existing files to ensure that our new file/symlink is created */
+static int unlink_entry(char *filename)
+{
+ struct stat stats;
+ int retval = 0;
+
+ if (lstat(filename, &stats) == 0) {
+ if ((stats.st_mode & S_IFMT) != S_IFDIR) {
+ retval = unlink(filename);
+ if (retval) {
+ dbg("unlink(%s) failed with error '%s'",
+ filename, strerror(errno));
+ }
+ }
+ }
+ return retval;
+}
+
+static int create_node(struct udevice *dev, int fake)