From owner-freebsd-hackers Sat Jan 13 1:57:30 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from smtp7.xs4all.nl (smtp7.xs4all.nl [194.109.127.133]) by hub.freebsd.org (Postfix) with ESMTP id D807037B401 for ; Sat, 13 Jan 2001 01:57:07 -0800 (PST) Received: from localhost (s340-modem1351.dial.xs4all.nl [194.109.165.71]) by smtp7.xs4all.nl (8.9.3/8.9.3) with SMTP id KAA29891; Sat, 13 Jan 2001 10:57:03 +0100 (CET) Message-ID: <3A6025F1.794BDF32@xs4all.nl> Date: Sat, 13 Jan 2001 09:54:57 +0000 From: "W.H.Scholten" Organization: . X-Mailer: Mozilla 3.04 (X11; I; FreeBSD 4.1-RELEASE i386) MIME-Version: 1.0 To: Alfred Perlstein Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: pppd & mkdir diff References: <3A5C843C.794BDF32@xs4all.nl> <20010111132509.J7240@fw.wintelcom.net> <3A5EE6B1.41C67EA6@xs4all.nl> <20010112081422.U7240@fw.wintelcom.net> Content-Type: multipart/mixed; boundary="------------1CFBAE3959E2B60015FB7483" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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