Commit Graph

28 Commits

Author SHA1 Message Date
Michael Forney 529e50a7ad mkdir: Fix created directory permissions
Previously, with -p, the specified directory and all of its parents
would be 0777&~filemask (regardless of the -m flag). POSIX says parent
directories must created as (0300|~filemask)&0777, and of course if -m
is set, the specified directory should be created with those
permissions.

Additionally, POSIX says that for symbolic_mode strings, + and - should
be interpretted relative to a default mode of 0777 (not 0).

Without -p, previously the directory would be created first with
0777&~filemask (before a chmod), but POSIX says that the directory shall
at no point in time have permissions less restrictive than the -m mode
argument.

Rather than dealing with mkdir removing the filemask bits by calling
chmod afterward, just clear the umask and remove the bits manually.
2017-07-03 21:03:11 +02:00
Michael Forney e795946971 mkdir: Fail on EEXIST with no -p flag
mkdir without the -p flag should only exit success if it actually made
the directory.
2017-07-03 21:03:07 +02:00
sin 2366164de7 No need for semicolon after ARGEND
This is also the style used in Plan 9.
2015-11-01 10:18:55 +00:00
sin b9d60bee87 Move mkdirp() to libutil 2015-04-20 18:04:08 +01:00
sin 6e30efb9bb Fix mkdir -p with a leading / 2015-04-20 17:47:14 +01:00
sin d6885987e5 Fix mkdir -p and allow -m to be specified along with -p
The mkdirp() function would not create the entire path but it just
happened to work because of the extra mkdir in the main loop.
2015-04-20 16:36:02 +01:00
FRIGN c82425e128 Three bugfixes in mkdir(1)
1) Any path passed to mkdir -p beginning with '/' failed, because
   it would cut out the first '/' immediately, passing "" to mkdir.
2) Running mkdir -p with a path/to/dir without trailing '/' would
   not create the directory.
   This is due to a wrong flag-check I added in the main-loop.
   It should now work as expected.
3) With the p-flag given, don't report an error in case the last
   dir also exists.
2015-03-13 12:23:22 +01:00
FRIGN 90751ab4ba Small fix in mkdir.c
Don't initialize p twice.
2015-03-06 00:34:43 +01:00
FRIGN d9fa4b3ae7 Audit mkdir(1)
1) No need for strchr() in mkdirp or a while-loop. Rewrite it in
   a sane and readable way.
2) fix usage according to the manpage.
3) order includes, don't align local variables.
4) argc-style-fix.
5) BUGFIX: Don't try to chmod() *argv when mkdir() / mkdirp() failed.
6) Add newline before return in two places.
2015-03-05 18:03:08 +01:00
FRIGN 31572c8b0e Clean up #includes 2015-02-14 21:12:23 +01:00
FRIGN 9119365c91 Add full mode support to mkdir(1) and fix return values
Same as with mkfifo(1). Also, somehow the return-values were
ignored and it would always return 0 no matter how many errors
happened.
2015-01-28 20:57:32 +01:00
sin d00d73fd4a mkdir: Don't stop after the first failure 2015-01-26 15:10:24 +00:00
FRIGN 58dac5cf0a Add mandoc-manpage for mkdir(1) and clean up code
and mark it as finished in the README.
2015-01-26 15:30:56 +01:00
FRIGN 1436518f9d Use < 0 instead of == -1 2014-11-19 20:09:29 +00:00
FRIGN ec8246bbc6 Un-boolify sbase
It actually makes the binaries smaller, the code easier to read
(gems like "val == true", "val == false" are gone) and actually
predictable in the sense of that we actually know what we're
working with (one bitwise operator was quite adventurous and
should now be fixed).

This is also more consistent with the other suckless projects
around which don't use boolean types.
2014-11-14 10:54:20 +00:00
FRIGN 7d2683ddf2 Sort includes and more cleanup and fixes in util/ 2014-11-14 10:54:10 +00:00
FRIGN eee98ed3a4 Fix coding style
It was about damn time. Consistency is very important in such a
big codebase.
2014-11-13 18:08:43 +00:00
sin 0c5b7b9155 Stop using EXIT_{SUCCESS,FAILURE} 2014-10-02 23:46:59 +01:00
Hiltjo Posthuma 953ebf3573 code style
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:02:30 +01:00
Markus Wichmann a4eb639ba7 Make mkdir read mode argument as octal. 2013-10-20 10:41:31 +01:00
sin b5a511dacf Exit with EXIT_SUCCESS/EXIT_FAILURE instead of 0 and 1
Fixed for consistency purposes.
2013-10-07 16:44:22 +01:00
sin 4d014e66fd Implement -m option for mkdir 2013-10-05 13:51:45 +01:00
sin 428cd4fe84 None of these work without the proper # of arguments so print usage 2013-10-05 13:51:45 +01:00
David Galos 48e6870bb7 Making `mkdir -p` handle empty paths. Thanks, Willem van de Krol! 2013-07-11 21:43:38 -04:00
stateless 7216a53a7e Remove unnecessary exit(1) in usage()
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2013-06-19 19:58:19 +02:00
Christoph Lohmann 4d38f60685 Eliminating the getopt disgrace. 2013-06-14 20:20:47 +02:00
Connor Lane Smith d90ced2047 consistent error check 2011-06-04 12:20:41 +01:00
Connor Lane Smith 5629972223 add mkdir 2011-05-26 05:47:58 +01:00