1 /* mkdir.c - Make directories
3 * Copyright 2012 Georgi Chorbadzhiyski <georgi@unixsol.org>
5 * See http://opengroup.org/onlinepubs/9699919799/utilities/mkdir.html
7 USE_MKDIR(NEWTOY(mkdir, "<1"USE_MKDIR_Z("Z:")"vpm:", TOYFLAG_BIN|TOYFLAG_UMASK))
13 usage: mkdir [-vp] [-m mode] [dirname...]
15 Create one or more directories.
17 -m set permissions of directory to mode.
18 -p make parent directories as needed.
24 depends on MKDIR && !TOYBOX_LSM_NONE
28 -Z set security context
42 mode_t mode = (0777&~toys.old_umask);
44 if (CFG_MKDIR_Z && (toys.optflags&FLAG_Z))
45 if (0>lsm_set_create(TT.arg_context))
46 perror_exit("-Z '%s' failed", TT.arg_context);
48 if (TT.arg_mode) mode = string_to_mode(TT.arg_mode, 0777);
50 // Note, -p and -v flags line up with mkpathat() flags
51 for (s=toys.optargs; *s; s++) {
52 if (mkpathat(AT_FDCWD, *s, mode, toys.optflags|1))
53 perror_msg("'%s'", *s);