From: "Guo, Min" <min.guo@intel.com>
To: linux-hotplug@vger.kernel.org
Subject: RE: [ANNOUNCE] udev 0.2 release
Date: Thu, 31 Jul 2003 07:47:58 +0000 [thread overview]
Message-ID: <marc-linux-hotplug-105964105031159@msgid-missing> (raw)
In-Reply-To: <marc-linux-hotplug-105917102320963@msgid-missing>
[-- Attachment #1: Type: text/plain, Size: 1782 bytes --]
Simple patch for udev mknod.
Thanks
Guo Min
The content of this email message solely contains my own personal views,
and not those of my employer.
-----------------------------------------------------------------------------------------------------------------
--- /root/udev-0.2/udev-add.c 2003-07-24 23:54:49.000000000 +0800
+++ udev/udev-add.c 2003-07-31 16:35:14.277998152 +0800
@@ -81,35 +81,26 @@
*/
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);
+ mknod(filename,mode,makedev(major,minor));
exit(0);
break;
case (-1):
[-- Attachment #2: udev-add.c.diff --]
[-- Type: application/octet-stream, Size: 1455 bytes --]
--- /root/udev-0.2/udev-add.c 2003-07-24 23:54:49.000000000 +0800
+++ udev/udev-add.c 2003-07-31 16:35:14.277998152 +0800
@@ -81,35 +81,26 @@
*/
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);
+ mknod(filename,mode,makedev(major,minor));
exit(0);
break;
case (-1):
next prev parent reply other threads:[~2003-07-31 7:47 UTC|newest]
Thread overview: 13+ 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 [this message]
2003-07-31 23:04 ` Greg KH
2003-08-01 0:48 ` Guo, Min
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
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-105964105031159@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).