Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Jan 2001 19:14:32 -0800
From:      Alfred Perlstein <bright@wintelcom.net>
To:        "W.H.Scholten" <whs@xs4all.nl>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: pppd & mkdir diff
Message-ID:  <20010113191432.G7240@fw.wintelcom.net>
In-Reply-To: <3A6025F1.794BDF32@xs4all.nl>; from whs@xs4all.nl on Sat, Jan 13, 2001 at 09:54:57AM %2B0000
References:  <3A5C843C.794BDF32@xs4all.nl> <20010111132509.J7240@fw.wintelcom.net> <3A5EE6B1.41C67EA6@xs4all.nl> <20010112081422.U7240@fw.wintelcom.net> <3A6025F1.794BDF32@xs4all.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
* W.H.Scholten <whs@xs4all.nl> [010113 01:57] wrote:
> 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).

Actually, there already exists a function called dirname in libc, dirname(3).

Here's what I'm going to commit:


Index: mkdir.c
===================================================================
RCS file: /home/ncvs/src/bin/mkdir/mkdir.c,v
retrieving revision 1.19
diff -u -u -r1.19 mkdir.c
--- mkdir.c	1999/09/04 03:19:38	1.19
+++ mkdir.c	2001/01/14 03:14:51
@@ -50,6 +50,7 @@
 
 #include <err.h>
 #include <errno.h>
+#include <libgen.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -108,7 +109,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);




Does this look ok to you?

-Alfred


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?20010113191432.G7240>