- char filename[255];
- DBusMessage* message;
- DBusMessageIter iter;
-
- if (sysbus_connection == NULL)
- return;
-
- strncpy(filename, udev_root, sizeof(filename));
- strncat(filename, dev->name, sizeof(filename));
-
- /* object, interface, member */
- message = dbus_message_new_signal("/org/kernel/udev/NodeMonitor",
- "org.kernel.udev.NodeMonitor",
- "NodeCreated");
-
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_append_string(&iter, filename);
- dbus_message_iter_append_string(&iter, path);
-
- if ( !dbus_connection_send(sysbus_connection, message, NULL) )
- dbg("error sending d-bus signal");
-
- dbus_message_unref(message);
-
- dbus_connection_flush(sysbus_connection);
+ 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;