Changeset 79ea5af in mainline
- Timestamp:
- 2017-03-30T20:47:53Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 67e881c
- Parents:
- ae7bfbbd
- Location:
- uspace
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cp/cp.c
rae7bfbbd r79ea5af 236 236 */ 237 237 if (force && !interactive) { 238 if ( unlink(dest_path) != 0) {238 if (vfs_unlink_path(dest_path) != EOK) { 239 239 printf("Unable to remove %s\n", 240 240 dest_path); … … 247 247 if (overwrite) { 248 248 printf("Overwriting file: %s\n", dest_path); 249 if ( unlink(dest_path) != 0) {249 if (vfs_unlink_path(dest_path) != EOK) { 250 250 printf("Unable to remove %s\n", dest_path); 251 251 goto exit; -
uspace/app/bdsh/cmds/modules/rm/rm.c
rae7bfbbd r79ea5af 36 36 #include <mem.h> 37 37 #include <str.h> 38 #include <vfs/vfs.h> 38 39 39 40 #include "config.h" … … 132 133 static unsigned int rm_single(const char *path) 133 134 { 134 if ( unlink(path) != 0) {135 if (vfs_unlink_path(path) != EOK) { 135 136 cli_error(CL_EFAIL, "rm: could not remove file %s", path); 136 137 return 1; … … 201 202 202 203 /* First see if it will just go away */ 203 rc = rmdir(path);204 if (rc == 0)204 rc = vfs_unlink_path(path); 205 if (rc == EOK) 205 206 return 0; 206 207 … … 209 210 210 211 /* Delete directory */ 211 rc = rmdir(path);212 if (rc == 0)213 return errno;212 rc = vfs_unlink_path(path); 213 if (rc == EOK) 214 return EOK; 214 215 215 216 cli_error(CL_ENOTSUP, "Can not remove %s", path); -
uspace/app/tester/mm/pager1.c
rae7bfbbd r79ea5af 28 28 29 29 #include <stdio.h> 30 #include < unistd.h>30 #include <vfs/vfs.h> 31 31 #include <fcntl.h> 32 32 #include <stdlib.h> … … 51 51 if (fd < 0) 52 52 return NULL; 53 (void) unlink(TEST_FILE);53 (void) vfs_unlink_path(TEST_FILE); 54 54 55 55 if (write(fd, (aoff64_t []) {0}, text, sizeof(text)) != sizeof(text)) { -
uspace/app/tester/vfs/vfs1.c
rae7bfbbd r79ea5af 117 117 TPRINTF("Renamed %s to %s\n", TEST_FILE, TEST_FILE2); 118 118 119 if ( unlink(TEST_FILE2) != 0)120 return " unlink() failed";119 if (vfs_unlink_path(TEST_FILE2) != EOK) 120 return "vfs_unlink_path() failed"; 121 121 TPRINTF("Unlinked %s\n", TEST_FILE2); 122 122 123 if ( rmdir(TEST_DIRECTORY) != 0)124 return " rmdir() failed";123 if (vfs_unlink_path(TEST_DIRECTORY) != EOK) 124 return "vfs_unlink_path() failed"; 125 125 TPRINTF("Removed directory %s\n", TEST_DIRECTORY); 126 126 -
uspace/lib/c/generic/vfs/vfs.c
rae7bfbbd r79ea5af 792 792 } 793 793 794 static int _vfs_unlink(int parent, const char *path, int expect, int wflag)794 int vfs_unlink(int parent, const char *child, int expect) 795 795 { 796 796 sysarg_t rc; … … 799 799 async_exch_t *exch = vfs_exchange_begin(); 800 800 801 req = async_send_ 3(exch, VFS_IN_UNLINK, parent, expect, wflag, NULL);802 rc = async_data_write_start(exch, path, str_size(path));801 req = async_send_2(exch, VFS_IN_UNLINK, parent, expect, NULL); 802 rc = async_data_write_start(exch, child, str_size(child)); 803 803 804 804 vfs_exchange_end(exch); … … 815 815 * 816 816 * @param path Path 817 * @return EOk on success , error code on error818 */ 819 int unlink(const char *path)817 * @return EOk on success or a negative error code otherwise 818 */ 819 int vfs_unlink_path(const char *path) 820 820 { 821 821 size_t pa_size; 822 822 char *pa = vfs_absolutize(path, &pa_size); 823 if (!pa) { 824 errno = ENOMEM; 825 return -1; 826 } 827 828 int root = vfs_root(); 829 if (root < 0) { 823 if (!pa) 824 return ENOMEM; 825 826 int parent; 827 int expect = vfs_lookup(path, 0); 828 if (expect < 0) { 830 829 free(pa); 831 errno = ENOENT; 832 return -1; 833 } 834 835 int rc = _vfs_unlink(root, pa, -1, 0); 836 837 if (rc != EOK) { 838 errno = rc; 839 rc = -1; 840 } 841 830 return expect; 831 } 832 833 char *slash = str_rchr(pa, L'/'); 834 if (slash != pa) { 835 *slash = '\0'; 836 parent = vfs_lookup(pa, 0); 837 *slash = '/'; 838 } else { 839 parent = vfs_root(); 840 } 841 842 if (parent < 0) { 843 free(pa); 844 close(expect); 845 return parent; 846 } 847 848 int rc = vfs_unlink(parent, slash, expect); 849 842 850 free(pa); 843 close(root); 844 return rc; 845 } 846 847 /** Remove empty directory. 848 * 849 * @param path Path 850 * @return 0 on success. On error returns -1 and sets errno. 851 */ 852 int rmdir(const char *path) 853 { 854 size_t pa_size; 855 char *pa = vfs_absolutize(path, &pa_size); 856 if (!pa) { 857 errno = ENOMEM; 858 return -1; 859 } 860 861 int root = vfs_root(); 862 if (root < 0) { 863 free(pa); 864 errno = ENOENT; 865 return -1; 866 } 867 868 int rc = _vfs_unlink(root, pa, -1, WALK_DIRECTORY); 869 if (rc != EOK) { 870 errno = rc; 871 rc = -1; 872 } 873 874 free(pa); 875 close(root); 851 close(parent); 852 close(expect); 876 853 return rc; 877 854 } -
uspace/lib/c/include/unistd.h
rae7bfbbd r79ea5af 65 65 extern int close(int); 66 66 extern int fsync(int); 67 extern int unlink(const char *);68 67 69 68 extern char *getcwd(char *, size_t); 70 extern int rmdir(const char *);71 69 extern int chdir(const char *); 72 70 -
uspace/lib/c/include/vfs/vfs.h
rae7bfbbd r79ea5af 94 94 extern int vfs_statfs(int, struct statfs *); 95 95 extern int vfs_statfs_path(const char *, struct statfs *); 96 extern int vfs_unlink(int, const char *, int); 97 extern int vfs_unlink_path(const char *); 96 98 97 99 int vfs_mount(int, const char *, service_id_t, const char *, unsigned, unsigned, int *); -
uspace/lib/pcut/src/os/helenos.c
rae7bfbbd r79ea5af 43 43 #include <fcntl.h> 44 44 #include <fibril_synch.h> 45 #include <vfs/vfs.h> 45 46 #include "../internal.h" 46 47 … … 219 220 leave_close_tempfile: 220 221 close(tempfile); 221 unlink(tempfile_name);222 vfs_unlink_path(tempfile_name); 222 223 223 224 pcut_report_test_done_unparsed(test, status, extra_output_buffer, OUTPUT_BUFFER_SIZE); -
uspace/lib/posix/source/stdio.c
rae7bfbbd r79ea5af 576 576 int posix_remove(const char *path) 577 577 { 578 return negerrno(unlink, path); 578 if (rcerrno(vfs_unlink_path, path) != EOK) 579 return -1; 580 else 581 return 0; 579 582 } 580 583 -
uspace/lib/posix/source/unistd.c
rae7bfbbd r79ea5af 270 270 int posix_rmdir(const char *path) 271 271 { 272 return negerrno(rmdir, path); 272 if (rcerrno(vfs_unlink_path, path) != EOK) 273 return -1; 274 else 275 return 0; 273 276 } 274 277 … … 281 284 int posix_unlink(const char *path) 282 285 { 283 return negerrno(unlink, path); 286 if (rcerrno(vfs_unlink_path, path) != EOK) 287 return -1; 288 else 289 return 0; 284 290 } 285 291 -
uspace/srv/vfs/vfs.h
rae7bfbbd r79ea5af 215 215 extern int vfs_op_sync(int fd); 216 216 extern int vfs_op_truncate(int fd, int64_t size); 217 extern int vfs_op_unlink(int parentfd, int expectfd, int wflag,char *path);217 extern int vfs_op_unlink(int parentfd, int expectfd, char *path); 218 218 extern int vfs_op_unmount(int mpfd); 219 219 extern int vfs_op_wait_handle(bool high_fd); -
uspace/srv/vfs/vfs_ipc.c
rae7bfbbd r79ea5af 194 194 int parentfd = IPC_GET_ARG1(*request); 195 195 int expectfd = IPC_GET_ARG2(*request); 196 int wflag = IPC_GET_ARG3(*request);197 196 198 197 char *path; 199 198 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 200 199 if (rc == EOK) 201 rc = vfs_op_unlink(parentfd, expectfd, wflag,path);200 rc = vfs_op_unlink(parentfd, expectfd, path); 202 201 203 202 async_answer_0(rid, rc); -
uspace/srv/vfs/vfs_ops.c
rae7bfbbd r79ea5af 672 672 } 673 673 674 int vfs_op_unlink(int parentfd, int expectfd, int wflag,char *path)674 int vfs_op_unlink(int parentfd, int expectfd, char *path) 675 675 { 676 676 int rc = EOK; … … 683 683 fibril_rwlock_write_lock(&namespace_rwlock); 684 684 685 int lflag = (wflag & WALK_DIRECTORY) ? L_DIRECTORY: 0;686 687 685 /* 688 686 * Files are retrieved in order of file descriptors, to prevent … … 717 715 if (expectfd >= 0) { 718 716 vfs_lookup_res_t lr; 719 rc = vfs_lookup_internal(parent->node, path, lflag, &lr);717 rc = vfs_lookup_internal(parent->node, path, 0, &lr); 720 718 if (rc != EOK) 721 719 goto exit; … … 733 731 734 732 vfs_lookup_res_t lr; 735 rc = vfs_lookup_internal(parent->node, path, lflag |L_UNLINK, &lr);733 rc = vfs_lookup_internal(parent->node, path, L_UNLINK, &lr); 736 734 if (rc != EOK) 737 735 goto exit;
Note:
See TracChangeset
for help on using the changeset viewer.