Ignore:
File:
1 edited

Legend:

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

    r738b549 r6afc9d7  
    8989{
    9090        /* Ensure we would always work with absolute and canonified path. */
    91         char *path = absolutize(user_path, NULL);
     91        char *path = vfs_absolutize(user_path, NULL);
    9292        if (path == NULL) {
    9393                cli_error(CL_ENOMEM, "%s: path too big?", cmdname);
     
    9595        }
    9696
    97         int rc;
    9897        int ret = 0;
    9998
    10099        if (!create_parents) {
    101                 rc = mkdir(path, 0);
    102                 if (rc != EOK) {
     100                if (mkdir(path, 0) != 0) {
    103101                        cli_error(CL_EFAIL, "%s: could not create %s (%s)",
    104                             cmdname, path, str_error(rc));
     102                            cmdname, path, str_error(errno));
    105103                        ret = 1;
    106104                }
     
    137135                        char slash_char = path[prev_off];
    138136                        path[prev_off] = 0;
    139                         rc = mkdir(path, 0);
    140                         if (rc == EEXIST) {
    141                                 rc = EOK;
    142                         }
    143 
    144                         if (rc != EOK) {
     137
     138                        if (mkdir(path, 0) != 0 && errno != EEXIST) {
    145139                                cli_error(CL_EFAIL, "%s: could not create %s (%s)",
    146                                     cmdname, path, str_error(rc));
     140                                    cmdname, path, str_error(errno));
    147141                                ret = 1;
    148142                                goto leave;
     
    152146                }
    153147                /* Create the final directory. */
    154                 rc = mkdir(path, 0);
    155                 if (rc != EOK) {
     148                if (mkdir(path, 0) != 0) {
    156149                        cli_error(CL_EFAIL, "%s: could not create %s (%s)",
    157                             cmdname, path, str_error(rc));
     150                            cmdname, path, str_error(errno));
    158151                        ret = 1;
    159152                }
     
    173166        argc = cli_count_args(argv);
    174167
    175         for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
     168        for (c = 0, optreset = 1, optind = 0, opt_ind = 0; c != -1;) {
    176169                c = getopt_long(argc, argv, "pvhVfm:", long_options, &opt_ind);
    177170                switch (c) {
     
    214207
    215208        if (follow && (argv[optind] != NULL)) {
    216                 chdir(argv[optind]);
     209                if (chdir(argv[optind]) != 0)
     210                        printf("%s: Error switching to directory.", cmdname);
    217211        }
    218212
Note: See TracChangeset for help on using the changeset viewer.