From owner-cvs-bin Tue Apr 1 15:46:25 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id PAA14305 for cvs-bin-outgoing; Tue, 1 Apr 1997 15:46:25 -0800 (PST) Received: (from mpp@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id PAA14298; Tue, 1 Apr 1997 15:46:23 -0800 (PST) Date: Tue, 1 Apr 1997 15:46:23 -0800 (PST) From: Mike Pritchard Message-Id: <199704012346.PAA14298@freefall.freebsd.org> To: CVS-committers, cvs-all, cvs-bin Subject: cvs commit: src/bin/mkdir mkdir.c Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk mpp 97/04/01 15:46:23 Modified: bin/mkdir mkdir.c Log: Fix several problems with mkdir: 1) Fix mkdir -p to exit with the proper exit status and issue an error message if it was unable to create all of the specified directories and they did not previously exist. POSIX says: The mkdir utility shall exit with one of the following values: 0 All the specified directories were created successfully or the -p option was specified and all the specified directories now exist. E.g. % mkdir -p /var/mkdir mkdir: /var/mkdir: Permission denied % touch /tmp/file % mkdir -p /tmp/file/dir mkdir: /tmp/file: Not a directory Previously the above examples would exit with a zero exit status and no error message. Something like the following run as a normal user will still not produce an error: % id uid=629(mpp) gid=629(mpp).... % mkdir -p /usr/local/etc % ls -ld /usr/local/etc drwxr-xr-x 4 bin bin 512 Dec 26 14:55 /usr/local/etc/ 2) Cleaned up the mode handling to be more efficient when multiple directories are being created. 3) Fixed a problem where directories could be created with the wrong mode if the the -p option was specified and the build() routine returned and error. It would leave the umask set incorrectly at this point. 4) Removed an unused variable. Closes PR# 2304. Revision Changes Path 1.10 +38 -29 src/bin/mkdir/mkdir.c