Date: Sat, 13 Jan 2001 09:54:57 +0000 From: "W.H.Scholten" <whs@xs4all.nl> To: Alfred Perlstein <bright@wintelcom.net> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: pppd & mkdir diff Message-ID: <3A6025F1.794BDF32@xs4all.nl> References: <3A5C843C.794BDF32@xs4all.nl> <20010111132509.J7240@fw.wintelcom.net> <3A5EE6B1.41C67EA6@xs4all.nl> <20010112081422.U7240@fw.wintelcom.net>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------1CFBAE3959E2B60015FB7483 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Alfred Perlstein wrote: [ mkdir ] > I'll commit the patch shortly. Here's a better patch, it checks for multiple slashes, so mkdir /tmp/aa///bb//// will give: mkdir: /tmp/aa: No such file or directory Also, renamed the function to dirname as it does the same as dirname(1). Regards, Wouter --------------1CFBAE3959E2B60015FB7483 Content-Type: text/plain; charset=us-ascii; name="mkdir.diff3" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mkdir.diff3" diff -ruN /usr/src/bin/mkdir.orig/mkdir.c /usr/src/bin/mkdir/mkdir.c --- /usr/src/bin/mkdir.orig/mkdir.c Sat Sep 4 05:19:38 1999 +++ /usr/src/bin/mkdir/mkdir.c Sat Jan 13 10:45:07 2001 @@ -58,6 +58,8 @@ int build __P((char *, mode_t)); void usage __P((void)); +char *dirname __P((char *)); + int vflag; @@ -108,7 +110,10 @@ if (build(*argv, omode)) success = 0; } else if (mkdir(*argv, omode) < 0) { - warn("%s", *argv); + if (errno == ENOTDIR || errno == ENOENT) + warn("%s", dirname(*argv)); + else + warn("%s", *argv); success = 0; } else if (vflag) (void)printf("%s\n", *argv); @@ -129,6 +134,22 @@ } exit(exitval); } + + +char *dirname(char *path) { + char *slash; + + while (path[ strlen(path)-1 ] == '/') path[ strlen(path)-1 ] = 0; + + slash = strrchr(path, '/'); + if (slash) { + *slash = 0; + while (path[ strlen(path)-1 ] == '/') path[ strlen(path)-1 ] = 0; + } + + return path; +} + int build(path, omode) --------------1CFBAE3959E2B60015FB7483-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A6025F1.794BDF32>