Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/mkdir/mkdir.c

    r6afc9d7 r738b549  
    8989{
    9090        /* Ensure we would always work with absolute and canonified path. */
    91         char *path = vfs_absolutize(user_path, NULL);
     91        char *path = absolutize(user_path, NULL);
    9292        if (path == NULL) {
    9393                cli_error(CL_ENOMEM, "%s: path too big?", cmdname);
     
    9595        }
    9696
     97        int rc;
    9798        int ret = 0;
    9899
    99100        if (!create_parents) {
    100                 if (mkdir(path, 0) != 0) {
     101                rc = mkdir(path, 0);
     102                if (rc != EOK) {
    101103                        cli_error(CL_EFAIL, "%s: could not create %s (%s)",
    102                             cmdname, path, str_error(errno));
     104                            cmdname, path, str_error(rc));
    103105                        ret = 1;
    104106                }
     
    135137                        char slash_char = path[prev_off];
    136138                        path[prev_off] = 0;
    137 
    138                         if (mkdir(path, 0) != 0 && errno != EEXIST) {
     139                        rc = mkdir(path, 0);
     140                        if (rc == EEXIST) {
     141                                rc = EOK;
     142                        }
     143
     144                        if (rc != EOK) {
    139145                                cli_error(CL_EFAIL, "%s: could not create %s (%s)",
    140                                     cmdname, path, str_error(errno));
     146                                    cmdname, path, str_error(rc));
    141147                                ret = 1;
    142148                                goto leave;
     
    146152                }
    147153                /* Create the final directory. */
    148                 if (mkdir(path, 0) != 0) {
     154                rc = mkdir(path, 0);
     155                if (rc != EOK) {
    149156                        cli_error(CL_EFAIL, "%s: could not create %s (%s)",
    150                             cmdname, path, str_error(errno));
     157                            cmdname, path, str_error(rc));
    151158                        ret = 1;
    152159                }
     
    166173        argc = cli_count_args(argv);
    167174
    168         for (c = 0, optreset = 1, optind = 0, opt_ind = 0; c != -1;) {
     175        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
    169176                c = getopt_long(argc, argv, "pvhVfm:", long_options, &opt_ind);
    170177                switch (c) {
     
    207214
    208215        if (follow && (argv[optind] != NULL)) {
    209                 if (chdir(argv[optind]) != 0)
    210                         printf("%s: Error switching to directory.", cmdname);
     216                chdir(argv[optind]);
    211217        }
    212218
Note: See TracChangeset for help on using the changeset viewer.