view toys/posix/mkdir.c @ 1676:cbb1aca81eca draft

Make toy_exec() check if argc is in optargs and deal with it there so we don't need a separate xexec_optargs().
author Rob Landley <>
date Sat, 07 Feb 2015 16:17:44 -0600
parents fc1bb49e58a9
line wrap: on
line source

/* mkdir.c - Make directories
 * Copyright 2012 Georgi Chorbadzhiyski <>
 * See


config MKDIR
  bool "mkdir"
  default y
    usage: mkdir [-vp] [-m mode] [dirname...]

    Create one or more directories.

    -m	set permissions of directory to mode.
    -p	make parent directories as needed.
    -v	verbose

#define FOR_mkdir
#include "toys.h"

  char *arg_mode;

void mkdir_main(void)
  char **s;
  mode_t mode = (0777&~toys.old_umask);

  if (TT.arg_mode) mode = string_to_mode(TT.arg_mode, 0777);

  // Note, -p and -v flags line up with mkpathat() flags

  for (s=toys.optargs; *s; s++)
    if (mkpathat(AT_FDCWD, *s, mode, toys.optflags|1))
      perror_msg("'%s'", *s);