Changeset 6e5562a in mainline
- Timestamp:
- 2017-03-31T19:57:38Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 80743a1
- Parents:
- a56cef9
- Location:
- uspace
- Files:
-
- 1 deleted
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cp/cp.c
ra56cef9 r6e5562a 36 36 #include <str.h> 37 37 #include <fcntl.h> 38 #include <sys/stat.h>39 38 #include <vfs/vfs.h> 40 39 #include <dirent.h> … … 296 295 merge_paths(dest_path, PATH_MAX, src_dirname); 297 296 298 if ( mkdir(dest_path, 0) != 0) {297 if (vfs_link_path(dest_path, KIND_DIRECTORY) != EOK) { 299 298 printf("Unable to create " 300 299 "dest directory %s\n", dest_path); … … 310 309 * e.g. cp -r /src /data/new_dir_src 311 310 */ 312 if ( mkdir(dest_path, 0) != 0) {311 if (vfs_link_path(dest_path, KIND_DIRECTORY) != EOK) { 313 312 printf("Unable to create " 314 313 "dest directory %s\n", dest_path); -
uspace/app/bdsh/cmds/modules/mkdir/mkdir.c
ra56cef9 r6e5562a 32 32 #include <fcntl.h> 33 33 #include <sys/types.h> 34 #include <sys/stat.h>35 34 #include <getopt.h> 36 35 #include <stdarg.h> … … 98 97 99 98 if (!create_parents) { 100 if (mkdir(path, 0) != 0) { 99 ret = vfs_link_path(path, KIND_DIRECTORY); 100 if (ret != EOK) { 101 101 cli_error(CL_EFAIL, "%s: could not create %s (%s)", 102 cmdname, path, str_error( errno));102 cmdname, path, str_error(ret)); 103 103 ret = 1; 104 104 } … … 136 136 path[prev_off] = 0; 137 137 138 if (mkdir(path, 0) != 0 && errno != EEXIST) { 138 ret = vfs_link_path(path, KIND_DIRECTORY); 139 if (ret != EOK && ret != EEXIST) { 139 140 cli_error(CL_EFAIL, "%s: could not create %s (%s)", 140 cmdname, path, str_error( errno));141 cmdname, path, str_error(ret)); 141 142 ret = 1; 142 143 goto leave; … … 146 147 } 147 148 /* Create the final directory. */ 148 if (mkdir(path, 0) != 0) { 149 ret = vfs_link_path(path, KIND_DIRECTORY); 150 if (ret != EOK) { 149 151 cli_error(CL_EFAIL, "%s: could not create %s (%s)", 150 cmdname, path, str_error( errno));152 cmdname, path, str_error(ret)); 151 153 ret = 1; 152 154 } -
uspace/app/bdsh/cmds/modules/mkfile/mkfile.c
ra56cef9 r6e5562a 33 33 #include <fcntl.h> 34 34 #include <sys/types.h> 35 #include <sys/stat.h>36 35 #include <macros.h> 37 36 #include <getopt.h> -
uspace/app/fontviewer/fontviewer.c
ra56cef9 r6e5562a 36 36 #include <unistd.h> 37 37 #include <fcntl.h> 38 #include <sys/stat.h>39 38 #include <errno.h> 40 39 #include <malloc.h> -
uspace/app/sysinst/futil.c
ra56cef9 r6e5562a 39 39 #include <stdio.h> 40 40 #include <stdlib.h> 41 #include <sys/stat.h>42 41 #include <vfs/vfs.h> 43 42 #include <sys/types.h> … … 130 129 } else if (s.is_directory) { 131 130 printf("Create directory '%s'\n", destp); 132 rc = mkdir(destp, 0);131 rc = vfs_link_path(destp, KIND_DIRECTORY); 133 132 if (rc != EOK) 134 133 return EIO; -
uspace/app/sysinst/sysinst.c
ra56cef9 r6e5562a 43 43 #include <stdio.h> 44 44 #include <stdlib.h> 45 #include <sys/stat.h>46 45 #include <task.h> 47 46 #include <vfs/vfs.h> … … 175 174 return EIO; 176 175 177 rc = mkdir(MOUNT_POINT, 0);176 rc = vfs_link_path(MOUNT_POINT, KIND_DIRECTORY); 178 177 if (rc != EOK) 179 178 return rc; … … 214 213 215 214 printf("sysinst_copy_boot_files(): create CD mount point\n"); 216 rc = mkdir(CD_MOUNT_POINT, 0);215 rc = vfs_link_path(CD_MOUNT_POINT, KIND_DIRECTORY); 217 216 if (rc != EOK) 218 217 return rc; -
uspace/app/taskdump/elf_core.c
ra56cef9 r6e5562a 54 54 #include <errno.h> 55 55 #include <sys/types.h> 56 #include <sys/stat.h>57 56 #include <unistd.h> 58 57 #include <fcntl.h> -
uspace/app/taskdump/symtab.c
ra56cef9 r6e5562a 41 41 #include <errno.h> 42 42 #include <sys/types.h> 43 #include <sys/stat.h>44 43 #include <fcntl.h> 45 44 -
uspace/app/tester/hw/misc/virtchar1.c
ra56cef9 r6e5562a 45 45 #include <vfs/vfs.h> 46 46 #include <vfs/vfs_sess.h> 47 #include <sys/stat.h>48 47 #include <fcntl.h> 49 48 #include "../../tester.h" -
uspace/app/tester/vfs/vfs1.c
ra56cef9 r6e5562a 37 37 #include <loc.h> 38 38 #include <sys/types.h> 39 #include <sys/stat.h>40 39 #include "../tester.h" 41 40 … … 71 70 { 72 71 aoff64_t pos = 0; 72 int rc; 73 73 74 if (mkdir(TEST_DIRECTORY, 0) != 0) { 75 TPRINTF("rc=%d\n", errno); 76 return "mkdir() failed"; 74 rc = vfs_link_path(TEST_DIRECTORY, KIND_DIRECTORY); 75 if (rc != EOK) { 76 TPRINTF("rc=%d\n", rc); 77 return "vfs_link_path() failed"; 77 78 } 78 79 TPRINTF("Created directory %s\n", TEST_DIRECTORY); -
uspace/app/untar/main.c
ra56cef9 r6e5562a 35 35 #include <stdio.h> 36 36 #include <stdlib.h> 37 #include <sys/stat.h>38 37 #include <errno.h> 39 38 #include <str_error.h> 39 #include <vfs/vfs.h> 40 40 #include "tar.h" 41 41 … … 103 103 static int handle_directory(const tar_header_t *header, FILE *tarfile) 104 104 { 105 if (mkdir(header->filename, 0755) != 0) { 106 if (errno != EEXIST) { 105 int rc; 106 107 rc = vfs_link_path(header->filename, KIND_DIRECTORY); 108 if (rc != EOK) { 109 if (rc != EEXIST) { 107 110 fprintf(stderr, "Failed to create directory %s: %s.\n", 108 header->filename, str_error( errno));109 return errno;111 header->filename, str_error(rc)); 112 return rc; 110 113 } 111 114 } -
uspace/app/websrv/websrv.c
ra56cef9 r6e5562a 39 39 #include <stdio.h> 40 40 #include <sys/types.h> 41 #include <sys/stat.h>42 41 #include <stdlib.h> 43 42 #include <fcntl.h> -
uspace/drv/char/ns8250/ns8250.c
ra56cef9 r6e5562a 49 49 #include <dirent.h> 50 50 #include <fcntl.h> 51 #include <sys/stat.h>52 51 #include <ddi.h> 53 52 -
uspace/lib/bithenge/src/failure.c
ra56cef9 r6e5562a 41 41 #include <stdio.h> 42 42 #include <stdlib.h> 43 #include <sys/stat.h>44 43 #include <sys/types.h> 45 44 #include <sys/wait.h> -
uspace/lib/bithenge/src/failure.h
ra56cef9 r6e5562a 42 42 #include <stdio.h> 43 43 #include <stdlib.h> 44 #include <sys/stat.h>45 44 #include <sys/types.h> 46 45 #include <unistd.h> -
uspace/lib/c/generic/vfs/vfs.c
ra56cef9 r6e5562a 43 43 #include <fcntl.h> 44 44 #include <stdio.h> 45 #include <sys/stat.h>46 45 #include <sys/types.h> 47 46 #include <ipc/services.h> … … 765 764 } 766 765 767 /** Create directory. 766 int vfs_link(int parent, const char *child, vfs_file_kind_t kind) 767 { 768 int flags = (kind == KIND_DIRECTORY) ? WALK_DIRECTORY : WALK_REGULAR; 769 int file = _vfs_walk(parent, child, WALK_MUST_CREATE | flags); 770 771 if (file < 0) 772 return file; 773 774 close(file); 775 776 return EOK; 777 } 778 779 /** Link a file or directory. 768 780 * 769 781 * @param path Path 770 * @param mode File mode 771 * @return 0 on success. On error returns -1 and sets errno. 772 */ 773 int mkdir(const char *path, mode_t mode) 774 { 775 int fd = vfs_lookup(path, WALK_MUST_CREATE | WALK_DIRECTORY); 776 if (fd < 0) { 777 errno = fd; 778 return -1; 779 } 780 781 return close(fd); 782 } 782 * @param kind Kind of the file to be created. 783 * @return EOK on success or a negative error code otherwise 784 */ 785 int vfs_link_path(const char *path, vfs_file_kind_t kind) 786 { 787 size_t pa_size; 788 char *pa = vfs_absolutize(path, &pa_size); 789 if (!pa) 790 return ENOMEM; 791 792 int parent; 793 char *slash = str_rchr(pa, L'/'); 794 if (slash != pa) { 795 *slash = '\0'; 796 parent = vfs_lookup(pa, WALK_DIRECTORY); 797 *slash = '/'; 798 } else { 799 parent = vfs_root(); 800 } 801 802 if (parent < 0) { 803 free(pa); 804 return parent; 805 } 806 807 int rc = vfs_link(parent, slash, kind); 808 809 free(pa); 810 close(parent); 811 return rc; 812 } 783 813 784 814 int vfs_unlink(int parent, const char *child, int expect) … … 802 832 } 803 833 804 /** Unlink file or directory.834 /** Unlink a file or directory. 805 835 * 806 836 * @param path Path 807 * @return EO kon success or a negative error code otherwise837 * @return EOK on success or a negative error code otherwise 808 838 */ 809 839 int vfs_unlink_path(const char *path) -
uspace/lib/c/include/vfs/vfs.h
ra56cef9 r6e5562a 49 49 }; 50 50 51 typedef enum { 52 KIND_FILE, 53 KIND_DIRECTORY, 54 } vfs_file_kind_t; 55 56 51 57 struct stat { 52 58 fs_handle_t fs_handle; … … 88 94 89 95 extern int vfs_clone(int, int, bool); 96 extern int vfs_link(int, const char *, vfs_file_kind_t); 97 extern int vfs_link_path(const char *, vfs_file_kind_t); 98 extern int vfs_resize(int, aoff64_t); 90 99 extern int vfs_root(void); 91 100 extern void vfs_root_set(int); 92 extern int vfs_resize(int, aoff64_t);93 101 extern int vfs_stat(int, struct stat *); 94 102 extern int vfs_stat_path(const char *, struct stat *); -
uspace/lib/fs/libfs.c
ra56cef9 r6e5562a 44 44 #include <mem.h> 45 45 #include <str.h> 46 #include <sys/stat.h>47 46 #include <stdlib.h> 48 47 #include <fibril_synch.h> -
uspace/lib/posix/include/posix/sys/stat.h
ra56cef9 r6e5562a 133 133 extern int __POSIX_DEF__(chmod)(const char *path, mode_t mode); 134 134 extern mode_t __POSIX_DEF__(umask)(mode_t mask); 135 extern int mkdir(const char *, mode_t);135 extern int __POSIX_DEF__(mkdir)(const char *path, mode_t mode); 136 136 137 137 -
uspace/lib/posix/source/stdio.c
ra56cef9 r6e5562a 53 53 #include "libc/malloc.h" 54 54 #include "libc/adt/list.h" 55 #include "libc/sys/stat.h"56 55 57 56 /** Clears the stream's error and end-of-file indicators. -
uspace/lib/posix/source/sys/stat.c
ra56cef9 r6e5562a 143 143 } 144 144 145 /** 146 * Create a directory. 147 * 148 * @param path Path to the new directory. 149 * @param mode Permission bits to be set. 150 * @return Zero on success, -1 otherwise. 151 */ 152 int posix_mkdir(const char *path, mode_t mode) 153 { 154 int rc = rcerrno(vfs_link_path, path, KIND_DIRECTORY); 155 if (rc != EOK) 156 return -1; 157 else 158 return 0; 159 } 160 145 161 /** @} 146 162 */ -
uspace/srv/fs/locfs/locfs_ops.c
ra56cef9 r6e5562a 45 45 #include <adt/hash_table.h> 46 46 #include <ipc/loc.h> 47 #include <sys/stat.h>48 47 #include <assert.h> 49 48 #include "locfs.h"
Note:
See TracChangeset
for help on using the changeset viewer.