Changeset 6e5562a in mainline for uspace/lib/c/generic/vfs/vfs.c
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note:
See TracChangeset
for help on using the changeset viewer.