~vojtech-horky/helenos/helenos-qemu

« back to all changes in this revision

Viewing changes to uspace/app/bdsh/cmds/modules/mkdir/mkdir.c

  • Committer: Vojtech Horky
  • Date: 2017-06-14 06:22:31 UTC
  • mfrom: (2103.1.569 HelenOS.mainline)
  • Revision ID: vojtechhorky@users.sourceforge.net-20170614062231-q4ui9pyxp0gs2hrl
MergeĀ mainlineĀ changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
#include <stdio.h>
30
30
#include <stdlib.h>
 
31
#include <stdint.h>
31
32
#include <dirent.h>
32
 
#include <fcntl.h>
33
 
#include <sys/types.h>
34
 
#include <sys/stat.h>
35
33
#include <getopt.h>
36
34
#include <stdarg.h>
37
35
#include <str.h>
97
95
        int ret = 0;
98
96
 
99
97
        if (!create_parents) {
100
 
                if (mkdir(path, 0) != 0) {
 
98
                ret = vfs_link_path(path, KIND_DIRECTORY, NULL);
 
99
                if (ret != EOK) {
101
100
                        cli_error(CL_EFAIL, "%s: could not create %s (%s)",
102
 
                            cmdname, path, str_error(errno));
 
101
                            cmdname, path, str_error(ret));
103
102
                        ret = 1;
104
103
                }
105
104
        } else {
135
134
                        char slash_char = path[prev_off];
136
135
                        path[prev_off] = 0;
137
136
 
138
 
                        if (mkdir(path, 0) != 0 && errno != EEXIST) {
 
137
                        ret = vfs_link_path(path, KIND_DIRECTORY, NULL);
 
138
                        if (ret != EOK && ret != EEXIST) {
139
139
                                cli_error(CL_EFAIL, "%s: could not create %s (%s)",
140
 
                                    cmdname, path, str_error(errno));
 
140
                                    cmdname, path, str_error(ret));
141
141
                                ret = 1;
142
142
                                goto leave;
143
143
                        }
145
145
                        path[prev_off] = slash_char;
146
146
                }
147
147
                /* Create the final directory. */
148
 
                if (mkdir(path, 0) != 0) {
 
148
                ret = vfs_link_path(path, KIND_DIRECTORY, NULL);
 
149
                if (ret != EOK) {
149
150
                        cli_error(CL_EFAIL, "%s: could not create %s (%s)",
150
 
                            cmdname, path, str_error(errno));
 
151
                            cmdname, path, str_error(ret));
151
152
                        ret = 1;
152
153
                }
153
154
        }
206
207
        }
207
208
 
208
209
        if (follow && (argv[optind] != NULL)) {
209
 
                if (chdir(argv[optind]) != 0)
 
210
                if (vfs_cwd_set(argv[optind]) != EOK)
210
211
                        printf("%s: Error switching to directory.", cmdname);
211
212
        }
212
213