Date: Mon, 25 Mar 1996 14:36:56 -0500 (EST) From: "Marc G. Fournier" <scrappy@ki.net> To: current@freebsd.org Subject: PATCH: /usr/src/sys/miscfs/devfs/devfs_tree.c Message-ID: <Pine.BSF.3.91.960325142921.10448G-100000@ki.net>
next in thread | raw e-mail | index | archive | help
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 <stdio.h>
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 <stdio.h>
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.960325142921.10448G-100000>
