From owner-freebsd-current Mon Mar 25 11:35:57 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id LAA28267 for current-outgoing; Mon, 25 Mar 1996 11:35:57 -0800 (PST) Received: from ki.net (root@ki.net [142.77.249.8]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id LAA28254 for ; Mon, 25 Mar 1996 11:35:50 -0800 (PST) Received: (from scrappy@localhost) by ki.net (8.7.4/8.7.4) id OAA11592; Mon, 25 Mar 1996 14:36:58 -0500 (EST) Date: Mon, 25 Mar 1996 14:36:56 -0500 (EST) From: "Marc G. Fournier" To: current@freebsd.org Subject: PATCH: /usr/src/sys/miscfs/devfs/devfs_tree.c Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Hi... Can someone commit the patch that follows? The patch fixes a problem with devfs_add_devswf() in which a device isn't being created properly if it involves a subdirectory. At the end of this email, is an example of what the current code does and what the patch produces. Thanks... *** /usr/src.orig/sys/miscfs/devfs/devfs_tree.c Sun Feb 18 04:43:44 1996 --- miscfs/devfs/devfs_tree.c Fri Mar 22 14:09:15 1996 *************** *** 910,916 **** ...) { va_list ap; ! char *p, *q, buf[256]; /* XXX */ int i; va_start(ap, fmt); --- 910,916 ---- ...) { va_list ap; ! char *p, buf[256]; /* XXX */ int i; va_start(ap, fmt); *************** *** 918,929 **** va_end(ap); buf[i] = '\0'; p = NULL; - for (q=buf; *q == '/'; q++) - continue; ! for (i=0; q[i]; i++) ! if (q[i] == '/') ! p = q; if (p) { *p++ = '\0'; --- 918,930 ---- va_end(ap); buf[i] = '\0'; p = NULL; ! for(i=strlen(buf); i>0; i--) ! if(buf[i] == '/') { ! p=&buf[i]; ! buf[i]=0; ! break; ! } if (p) { *p++ = '\0'; -----[ CUT HERE ]----- main1.c is a standalone program using the algorithm used in the original devfs_add_devswf(), while main.c is a standalone program using the modified devfs_add_devswf(). Both are trying to create a device of "/fd/0", as is used in /usr/src/sys/kern/kern_descrip.c. What should happen is a device named 0 should be created in /fd, but the current code tries to create a device named 'd/0' in / Script started on Mon Mar 25 14:33:36 1996 > cat main1.c #include main() { char buf[20], *p, *q; int i; strcpy(buf, "/fd/0"); printf("buf = %s\n\n", buf); p = NULL; for (q=buf; *q == '/'; q++) continue; for (i=0; q[i]; i++) if (q[i] == '/') p = q; if(p) { *p++ = '\0'; printf("buf = %s\np = %s\n\n", buf, p); } else printf("buf = %s\np is NULL\n\n", buf); } > ./main1 buf = /fd/0 buf = / p = d/0 > cat main.c #include main() { char buf[20], *p; int i; strcpy(buf, "/fd/0"); printf("buf = %s\n\n", buf); p = NULL; for(i = strlen(buf); i >= 0; i--) if(buf[i] == '/') { p = &buf[i]; buf[i] = 0; break; } if(p) { *p++ = '\0'; printf("buf = %s\np = %s\n\n", buf, p); } else printf("buf = %s\np is NULL\n\n", buf); } > ./main buf = /fd/0 buf = /fd p = 0 > exit exit Script done on Mon Mar 25 14:33:45 1996 Marc G. Fournier | POP Mail Telnet Acct DNS Hosting System | WWW Services Database Services | Knowledge, Administrator | | Information and scrappy@ki.net | WWW: http://www.ki.net | Communications, Inc