History log of /freebsd-11-stable/bin/mkdir/mkdir.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 331722 29-Mar-2018 eadler

Revert r330897:

This was intended to be a non-functional change. It wasn't. The commit
message was thus wrong. In addition it broke arm, and merged crypto
related code.

Revert with prejudice.

This revert skips files touched in r316370 since that commit was since
MFCed. This revert also skips files that require $FreeBSD$ property
changes.

Thank you to those who helped me get out of this mess including but not
limited to gonzo, kevans, rgrimes.

Requested by: gjb (re)


# 330897 14-Mar-2018 eadler

Partial merge of the SPDX changes

These changes are incomplete but are making it difficult
to determine what other changes can/should be merged.

No objections from: pfg


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 249996 27-Apr-2013 eadler

Add missing static qualifiers

Reviewed by: ed, jilles
MFC After: 3 days


# 226961 31-Oct-2011 ed

Put some static keywords in the source code.

For these simple utilities, it doesn't harm to make all global variables
static. In fact, this allows the compiler to perform better forms of
optimisation and analysis.


# 163213 10-Oct-2006 ru

Adhere to POSIX: the -m option only applies to the newly created
directories; it should not change the permission bits of already
existing directories.

Submitted by: Alex Unleashed (modified by me)


# 141578 09-Feb-2005 ru

Sync program's usage() with manpage's SYNOPSIS.


# 140816 25-Jan-2005 ssouhlal

- The first argument of getmode() is a void *
- Add WARNS?= 6

Approved by: stefanf, grehan (mentor)
Obtained from: DragonFlyBSD


# 139969 10-Jan-2005 imp

/*- or .\"- or #- to begin license clauses.


# 135718 24-Sep-2004 das

Don't read the byte at *argv[strlen(*argv) + 1].

PR: 71743


# 127958 06-Apr-2004 markm

Remove clause 3 from the UCB licenses.

OK'ed by: imp, core


# 114433 01-May-2003 obrien

Quiet warnings about copyright[].


# 99109 30-Jun-2002 obrien

Consistently use __FBSDID


# 91235 25-Feb-2002 sobomax

Fix a bug introduced in rev.1.23 - for some reason mkdir("/", ...) system
call returns `EISDIR', not `EEXIST', so that be prepared for that. This should
fix number of ports, that often call `mkdir -p //usr/local/foobar'. This
is just a quick workaround, the real fix would be either to avoid calling
mkdir("/", ...) or fix VFS code to return consistent errno for this case.


# 91084 22-Feb-2002 markm

Fix warnings inspired by lint, a commercial lint and WARNS=4.


# 90266 05-Feb-2002 zarzycki

Fix the race between the stat() and the mkdir().
Reviewed by: jkh


# 90110 02-Feb-2002 imp

o __P has been reoved
o Old-style K&R declarations have been converted to new C89 style
o register has been removed
o prototype for main() has been removed (gcc3 makes it an error)
o int main(int argc, char *argv[]) is the preferred main definition.
o Attempt to not break style(9) conformance for declarations more than
they already are.


# 76886 20-May-2001 kris

Silence WARNS=2 and BDECFLAGS except for stupid mode_t warnings.

MFC after: 1 week


# 71029 14-Jan-2001 alfred

Special case the error reporting when errno is ENOTDIR or ENOENT.

This makes "mkdir /nonexistant/foo" complain that /nonexistant
doesn't exist rather than /nonexistant/foo which doesn't make much
sense.

Submitted (in a different form) by: W.H.Scholten <whs@xs4all.nl>


# 50870 04-Sep-1999 mharo

brucify and add comment about -v being non-standard to manpage

Reviewed by: obrien


# 50528 28-Aug-1999 mharo

add verbose flag

Reviewed by: obrien


# 50471 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 41842 16-Dec-1998 imp

Free memory obtained from setmode.

Obtained from: OpenBSD


# 40606 23-Oct-1998 msmith

Fix behaviour for 'mkdir -m 777 / /tmp/foo'. Play "guess the style bug"
with Bruce again.

Reported by: bde


# 40602 22-Oct-1998 msmith

Honour the spirit rather than the implementation of the previous changes;
if we are invoked with -m, use chmod() on the final directory component
in order to ensure the mode is correctly set.


# 40537 20-Oct-1998 msmith

Make this compile, and honour the spirit of the original design while
incorporating the intended fix. Attempt to address some of the
putative style bugs introduced. Others doubtless remain.

Embarrassed by: bde


# 40535 20-Oct-1998 msmith

- mkdir -m should call chmod because the high-order bits get ignored
by the kernel as a security feature of some sort.

Submitted by: Wilfredo Sanchez <wsanchez@apple.com>


# 36048 15-May-1998 charnier

correct use of .Nm. Add rcsid.


# 24524 01-Apr-1997 mpp

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.


# 24348 28-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 22988 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 20418 14-Dec-1996 steve

Cleanup man page and -Wall cleaning.


# 3044 24-Sep-1994 dg

Added $Id$


# 2959 21-Sep-1994 bde

Remove bogus cast that was introduced in the previous commit.


# 2923 20-Sep-1994 phk

Applied patch to make -Wall and -Dlint shut up.

Reviewed by: phk
Submitted by: Josef Grosch <joeg@gagme.wwa.com>


# 2594 08-Sep-1994 jkh

[ From Dave Tweten ]

POSIX.2 looks pretty unequivocal to me, and it agrees with you.

Under the explanation of the "-p" option, it says, "Each dir operand that
names an existing directory shall be ignored without error." Under the
explanation of exit status zero, it says, "All the specified directories were
created successfully, or the-p option was specified and all the specified
directories now exist."

Seems to me POSIX requires exactly the behavior you want.

[ And I've made the change, which is also now compatible with 1.x - jkh ]

Reviewed by: jkh
Submitted by: jkh/tweten


# 1557 26-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1556,
which included commits to RCS files with non-trunk default branches.


# 1556 26-May-1994 rgrimes

BSD 4.4 Lite bin Sources