Changeset b5b5d84 in mainline for uspace/lib/c/generic/vfs/vfs.c
- Timestamp:
- 2017-03-30T18:58:28Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 23a0368
- Parents:
- fe91f66
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/vfs/vfs.c
rfe91f66 rb5b5d84 44 44 #include <stdio.h> 45 45 #include <sys/stat.h> 46 #include <sys/statfs.h>47 46 #include <sys/types.h> 48 47 #include <ipc/services.h> … … 1084 1083 1085 1084 struct statfs stfs; 1086 if ( statfs(path, &stfs) == EOK)1085 if (vfs_statfs_path(path, &stfs) == EOK) 1087 1086 str_cpy(ent->fs_name, sizeof(ent->fs_name), stfs.fs_name); 1088 1087 else … … 1164 1163 /** Get filesystem statistics. 1165 1164 * 1165 * @param file File located on the queried file system 1166 * @param st Buffer for storing information 1167 * @return 0 on success. On error -1 is returned and errno is set. 1168 */ 1169 int vfs_statfs(int file, struct statfs *st) 1170 { 1171 sysarg_t rc, ret; 1172 aid_t req; 1173 1174 async_exch_t *exch = vfs_exchange_begin(); 1175 1176 req = async_send_1(exch, VFS_IN_STATFS, file, NULL); 1177 rc = async_data_read_start(exch, (void *) st, sizeof(*st)); 1178 1179 vfs_exchange_end(exch); 1180 async_wait_for(req, &ret); 1181 1182 rc = (ret != EOK ? ret : rc); 1183 1184 return rc; 1185 } 1186 /** Get filesystem statistics. 1187 * 1166 1188 * @param path Mount point path 1167 1189 * @param st Buffer for storing information 1168 * @return 0 on success. On error -1 is returned and errno is set. 1169 */ 1170 int statfs(const char *path, struct statfs *st) 1171 { 1172 int fd = vfs_lookup(path, 0); 1173 if (fd < 0) { 1174 errno = fd; 1175 return -1; 1176 } 1177 1178 sysarg_t rc, ret; 1179 aid_t req; 1180 1181 async_exch_t *exch = vfs_exchange_begin(); 1182 1183 req = async_send_1(exch, VFS_IN_STATFS, fd, NULL); 1184 rc = async_data_read_start(exch, (void *) st, sizeof(*st)); 1185 1186 vfs_exchange_end(exch); 1187 async_wait_for(req, &ret); 1188 close(fd); 1189 1190 rc = (ret != EOK ? ret : rc); 1191 if (rc != EOK) { 1192 errno = rc; 1193 return -1; 1194 } 1195 1196 return 0; 1190 * @return EOK on success or a negative error code otherwise. 1191 */ 1192 int vfs_statfs_path(const char *path, struct statfs *st) 1193 { 1194 int file = vfs_lookup(path, 0); 1195 if (file < 0) 1196 return file; 1197 1198 int rc = vfs_statfs(file, st); 1199 1200 close(file); 1201 1202 return rc; 1197 1203 } 1198 1204
Note:
See TracChangeset
for help on using the changeset viewer.