All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Guo, Min" <min.guo@intel.com>
To: linux-hotplug@vger.kernel.org
Subject: RE: [ANNOUNCE] udev 0.2 release
Date: Fri, 01 Aug 2003 00:48:27 +0000	[thread overview]
Message-ID: <marc-linux-hotplug-105969925201478@msgid-missing> (raw)
In-Reply-To: <marc-linux-hotplug-105917102320963@msgid-missing>

[-- Attachment #1: Type: text/plain, Size: 1770 bytes --]

Thanks,the revised patch.
---------------------------------------------
--- /root/udev-0.2/udev-add.c	2003-07-24 23:54:49.000000000 +0800
+++ /udev/udev-add.c	2003-08-01 09:45:24.651393112 +0800
@@ -81,45 +81,24 @@
  */
 static int create_node(char *name, char type, int major, int minor, int mode)
 {
-	char *argv[7];
-	char mode_string[100];
-	char type_string[3];
-	char major_string[20];
-	char minor_string[20];
 	char filename[255];
 	int retval = 0;
-
 	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;
+ 	}
 
-	snprintf(mode_string, sizeof(mode_string), "--mode=%#o", mode);
-	snprintf(type_string, sizeof(type_string), "%c", type);
-	snprintf(major_string, sizeof(major_string), "%d", major);
-	snprintf(minor_string, sizeof(minor_string), "%d", minor);
-	
-	argv[0] = MKNOD;
-	argv[1] = mode_string;
-	argv[2] = filename;
-	argv[3] = type_string;
-	argv[4] = major_string;
-	argv[5] = minor_string;
-	argv[6] = NULL;
-	dbg ("executing %s %s %s %s %s %s",
-		argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
-	switch (fork()) {
-		case 0:
-			/* we are the child, so lets run the program */
-			execv (MKNOD, argv);
-			exit(0);
-			break;
-		case (-1):
-			dbg ("fork failed.");
-			retval = -EFAULT;
-			break;
-		default:
-			break;
-	}
+	retval = mknod(filename,mode,makedev(major,minor));
 	return retval;
+		
 }
 
 struct sysfs_class_device *get_class_dev(char *device_name)

[-- Attachment #2: udev-add.c.diff --]
[-- Type: application/octet-stream, Size: 1636 bytes --]

--- /root/udev-0.2/udev-add.c	2003-07-24 23:54:49.000000000 +0800
+++ /udev/udev-add.c	2003-08-01 09:45:24.651393112 +0800
@@ -81,45 +81,24 @@
  */
 static int create_node(char *name, char type, int major, int minor, int mode)
 {
-	char *argv[7];
-	char mode_string[100];
-	char type_string[3];
-	char major_string[20];
-	char minor_string[20];
 	char filename[255];
 	int retval = 0;
-
 	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;
+ 	}
 
-	snprintf(mode_string, sizeof(mode_string), "--mode=%#o", mode);
-	snprintf(type_string, sizeof(type_string), "%c", type);
-	snprintf(major_string, sizeof(major_string), "%d", major);
-	snprintf(minor_string, sizeof(minor_string), "%d", minor);
-	
-	argv[0] = MKNOD;
-	argv[1] = mode_string;
-	argv[2] = filename;
-	argv[3] = type_string;
-	argv[4] = major_string;
-	argv[5] = minor_string;
-	argv[6] = NULL;
-	dbg ("executing %s %s %s %s %s %s",
-		argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
-	switch (fork()) {
-		case 0:
-			/* we are the child, so lets run the program */
-			execv (MKNOD, argv);
-			exit(0);
-			break;
-		case (-1):
-			dbg ("fork failed.");
-			retval = -EFAULT;
-			break;
-		default:
-			break;
-	}
+	retval = mknod(filename,mode,makedev(major,minor));
 	return retval;
+		
 }
 
 struct sysfs_class_device *get_class_dev(char *device_name)

  parent reply	other threads:[~2003-08-01  0:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-25 21:47 [ANNOUNCE] udev 0.2 release Greg KH
2003-07-26  0:18 ` Joshua Schmidlkofer
2003-07-26 15:57 ` Greg KH
2003-07-31  7:46 ` Guo, Min
2003-07-31  7:47 ` Guo, Min
2003-07-31 23:04 ` Greg KH
2003-08-01  0:48 ` Guo, Min [this message]
2003-08-05  0:19 ` Greg KH
2003-08-05  2:22 ` Guo, Min
2003-08-05 10:08 ` Daniel Stekloff
2003-08-12  7:17 ` Guo, Min
2003-08-12  7:24 ` Guo, Min
2003-08-13  9:35 ` Daniel Stekloff
  -- strict thread matches above, loose matches on Subject: below --
2003-07-25 21:47 Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-hotplug-105969925201478@msgid-missing \
    --to=min.guo@intel.com \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.