Changeset 23a0368 in mainline for uspace/lib/c/generic/vfs/vfs.c
- Timestamp:
- 2017-03-30T19:52:23Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ae7bfbbd
- Parents:
- b5b5d84
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/vfs/vfs.c
rb5b5d84 r23a0368 641 641 /** Get file status. 642 642 * 643 * @param fil desFile descriptor643 * @param file File descriptor 644 644 * @param stat Place to store file information 645 645 * 646 * @return 0 on success, -1 on error and sets errno.647 */ 648 int fstat(int fildes, struct stat *stat)646 * @return EOK on success or a negative error code otherwise. 647 */ 648 int vfs_stat(int file, struct stat *stat) 649 649 { 650 650 sysarg_t rc; … … 653 653 async_exch_t *exch = vfs_exchange_begin(); 654 654 655 req = async_send_1(exch, VFS_IN_STAT, fil des, NULL);655 req = async_send_1(exch, VFS_IN_STAT, file, NULL); 656 656 rc = async_data_read_start(exch, (void *) stat, sizeof(struct stat)); 657 657 if (rc != EOK) { … … 663 663 if (rc_orig != EOK) 664 664 rc = rc_orig; 665 if (rc != EOK) {666 errno = rc;667 return -1;668 }669 665 670 return 0;666 return rc; 671 667 } 672 668 … … 674 670 async_wait_for(req, &rc); 675 671 676 if (rc != EOK) { 677 errno = rc; 678 return -1; 679 } 680 681 return 0; 672 return rc; 682 673 } 683 674 … … 687 678 * @param stat Place to store file information 688 679 * 689 * @return 0 on success, -1 on error and sets errno. 690 */ 691 int stat(const char *path, struct stat *stat) 692 { 693 int fd = vfs_lookup(path, 0); 694 if (fd < 0) { 695 errno = fd; 696 return -1; 697 } 698 699 int rc = fstat(fd, stat); 700 if (rc != EOK) { 701 close(fd); 702 errno = rc; 703 rc = -1; 704 } else 705 rc = close(fd); 680 * @return EOK on success or a negative error code otherwise. 681 */ 682 int vfs_stat_path(const char *path, struct stat *stat) 683 { 684 int file = vfs_lookup(path, 0); 685 if (file < 0) 686 return file; 687 688 int rc = vfs_stat(file, stat); 689 690 close(file); 706 691 707 692 return rc; … … 1057 1042 * @return On success returns session pointer. On error returns @c NULL. 1058 1043 */ 1059 async_sess_t *vfs_fd_session(int fil des, iface_t iface)1044 async_sess_t *vfs_fd_session(int file, iface_t iface) 1060 1045 { 1061 1046 struct stat stat; 1062 int rc = fstat(fildes, &stat);1047 int rc = vfs_stat(file, &stat); 1063 1048 if (rc != 0) 1064 1049 return NULL; … … 1122 1107 child = pa; 1123 1108 1124 rc = stat(child, &st);1109 rc = vfs_stat_path(child, &st); 1125 1110 if (rc != 0) { 1126 1111 free(child); … … 1152 1137 struct stat st; 1153 1138 1154 int rc = stat("/", &st);1139 int rc = vfs_stat_path("/", &st); 1155 1140 if (rc != 0) 1156 1141 return rc; … … 1165 1150 * @param file File located on the queried file system 1166 1151 * @param st Buffer for storing information 1167 * @return 0 on success. On error -1 is returned and errno is set.1152 * @return EOK on success or a negative error code otherwise. 1168 1153 */ 1169 1154 int vfs_statfs(int file, struct statfs *st)
Note:
See TracChangeset
for help on using the changeset viewer.