Changeset 9dc6083 in mainline
- Timestamp:
- 2013-07-06T15:53:01Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 11baebb
- Parents:
- 66366470
- Location:
- uspace
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/df/df.c
r66366470 r9dc6083 38 38 #include <stdlib.h> 39 39 #include <unistd.h> 40 #include <s tats.h>40 #include <sys/statfs.h> 41 41 #include <errno.h> 42 42 #include <adt/list.h> … … 59 59 mtab_ent_t *mtab_ent = list_get_instance(cur, mtab_ent_t, 60 60 link); 61 if (statfs( mtab_ent->mp, &st) < 0)61 if (statfs(/*mtab_ent->mp*/ "/data", &st) < 0) 62 62 return 1; 63 63 64 64 printf("%13s %15lld %9lld %9lld %3ld%% %s\n", 65 65 mtab_ent->fs_name, -
uspace/lib/c/generic/vfs/vfs.c
r66366470 r9dc6083 43 43 #include <stdio.h> 44 44 #include <sys/stat.h> 45 #include <sys/statfs.h> 45 46 #include <sys/types.h> 46 47 #include <ipc/services.h> … … 892 893 } 893 894 894 int statfs(const char *path, struct statfs *buf) 895 { 896 sysarg_t rc; 897 //aid_t req; 898 899 if ( NULL == buf ) 900 return 1; 901 902 sysarg_t value; 903 async_exch_t *exch = vfs_exchange_begin(); 904 rc = async_req_0_1(exch, VFS_IN_STATFS, &value); 905 if (rc != EOK) 906 goto exit; 907 908 buf->f_bsize = value; 909 exit: 910 vfs_exchange_end(exch); 895 #include <stdio.h> 896 int statfs(const char *path, struct statfs *statfs) 897 { 898 sysarg_t rc; 899 sysarg_t rc_orig; 900 aid_t req; 901 size_t pa_size; 902 903 char *pa = absolutize(path, &pa_size); 904 if (!pa) 905 return ENOMEM; 906 907 async_exch_t *exch = vfs_exchange_begin(); 908 909 req = async_send_0(exch, VFS_IN_STATFS, NULL); 910 rc = async_data_write_start(exch, pa, pa_size); 911 if (rc != EOK) { 912 vfs_exchange_end(exch); 913 free(pa); 914 async_wait_for(req, &rc_orig); 915 if (rc_orig == EOK) 916 return (int) rc; 917 else 918 return (int) rc_orig; 919 } 920 printf("TRACE: send VFS_IN_STATFS\n"); 921 rc = async_data_read_start(exch, statfs, sizeof(struct statfs)); 922 if (rc != EOK) { 923 printf("TRACE: error reply\n"); 924 vfs_exchange_end(exch); 925 free(pa); 926 async_wait_for(req, &rc_orig); 927 if (rc_orig == EOK) 928 return (int) rc; 929 else 930 return (int) rc_orig; 931 } 932 vfs_exchange_end(exch); 933 free(pa); 934 async_wait_for(req, &rc); 911 935 return rc; 912 936 } -
uspace/lib/c/include/ipc/vfs.h
r66366470 r9dc6083 99 99 VFS_OUT_LOOKUP, 100 100 VFS_OUT_DESTROY, 101 VFS_OUT_LAST 101 VFS_OUT_LAST, 102 VFS_OUT_STATFS 102 103 } vfs_out_request_t; 103 104 -
uspace/lib/c/include/vfs/vfs.h
r66366470 r9dc6083 49 49 }; 50 50 51 struct statfs {52 short f_type; /* type of file system */53 long f_bsize; /* fundamental file system block size */54 long f_blocks; /* total data blocks in file system */55 long f_bfree; /* free blocks in fs */56 };57 58 51 59 52 extern char *absolutize(const char *, size_t *); … … 70 63 extern async_exch_t *vfs_exchange_begin(void); 71 64 extern void vfs_exchange_end(async_exch_t *); 72 extern int statfs(const char *path, struct statfs *buf);73 65 #endif 74 66 -
uspace/lib/fs/libfs.c
r66366470 r9dc6083 45 45 #include <mem.h> 46 46 #include <sys/stat.h> 47 #include <sys/statfs.h> 47 48 #include <stdlib.h> 48 49 … … 218 219 async_answer_0(rid, rc); 219 220 } 221 #include<stdio.h> 222 static void vfs_out_statfs(ipc_callid_t rid, ipc_call_t *req) 223 { 224 printf("TRACE: vfs_out_statfs\n"); 225 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 226 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req); 227 228 fs_node_t *fn; 229 int rc = libfs_ops->node_get(&fn, service_id, index); 230 on_error(rc, answer_and_return(rid, rc)); 231 232 ipc_callid_t callid; 233 size_t size; 234 if ((!async_data_read_receive(&callid, &size)) || 235 (size != sizeof(struct stat))) { 236 libfs_ops->node_put(fn); 237 async_answer_0(callid, EINVAL); 238 async_answer_0(rid, EINVAL); 239 return; 240 } 241 242 struct statfs statfs; 243 memset(&statfs, 0, sizeof(struct statfs)); 244 245 statfs.f_bsize = libfs_ops->size_block(service_id); 246 247 libfs_ops->node_put(fn); 248 249 async_data_read_finalize(callid, &statfs, sizeof(struct statfs)); 250 async_answer_0(rid, EOK); 251 } 220 252 221 253 static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) … … 276 308 case VFS_OUT_SYNC: 277 309 vfs_out_sync(callid, &call); 310 break; 311 case VFS_OUT_STATFS: 312 vfs_out_statfs(callid, &call); 278 313 break; 279 314 default: -
uspace/lib/fs/libfs.h
r66366470 r9dc6083 93 93 bool (* is_file)(fs_node_t *); 94 94 service_id_t (* service_get)(fs_node_t *); 95 unsigned int (* size_block)(fs_node_t *);95 long (* size_block)(service_id_t); 96 96 } libfs_ops_t; 97 97 -
uspace/srv/fs/mfs/mfs_ops.c
r66366470 r9dc6083 64 64 static int mfs_check_sanity(struct mfs_sb_info *sbi); 65 65 static bool is_power_of_two(uint32_t n); 66 static unsigned int mfs_size_block(fs_node_t *fsnode);66 static long mfs_size_block(service_id_t service_id); 67 67 68 68 static hash_table_t open_nodes; … … 1138 1138 } 1139 1139 1140 static unsigned int 1141 mfs_size_block(fs_node_t *fsnode) 1142 { 1143 if ( NULL == fsnode ) 1144 return 0; 1145 /* Get block size from superblock */ 1146 return 512; 1140 static long 1141 mfs_size_block(service_id_t service_id) 1142 { 1143 long block_size; 1144 1145 struct mfs_instance *inst; 1146 int rc = mfs_instance_get(service_id, &inst); 1147 if (rc != EOK) 1148 return rc; 1149 if (NULL == inst) 1150 return ENOENT; 1151 block_size = inst->sbi->block_size; 1152 return block_size; 1147 1153 } 1148 1154 -
uspace/srv/vfs/vfs_ops.c
r66366470 r9dc6083 1420 1420 void vfs_statfs(ipc_callid_t rid, ipc_call_t *request) 1421 1421 { 1422 long long reply; 1423 1424 /* Get information about fs */ 1425 reply = 512; 1426 async_answer_1(rid, EOK, reply); 1422 char *path; 1423 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL); 1424 if (rc != EOK) { 1425 async_answer_0(rid, rc); 1426 return; 1427 } 1428 1429 ipc_callid_t callid; 1430 if (!async_data_read_receive(&callid, NULL)) { 1431 free(path); 1432 async_answer_0(callid, EINVAL); 1433 async_answer_0(rid, EINVAL); 1434 return; 1435 } 1436 1437 vfs_lookup_res_t lr; 1438 fibril_rwlock_read_lock(&namespace_rwlock); 1439 rc = vfs_lookup_internal(path, L_NONE, &lr, NULL); 1440 free(path); 1441 if (rc != EOK) { 1442 fibril_rwlock_read_unlock(&namespace_rwlock); 1443 async_answer_0(callid, rc); 1444 async_answer_0(rid, rc); 1445 return; 1446 } 1447 vfs_node_t *node = vfs_node_get(&lr); 1448 if (!node) { 1449 fibril_rwlock_read_unlock(&namespace_rwlock); 1450 async_answer_0(callid, ENOMEM); 1451 async_answer_0(rid, ENOMEM); 1452 return; 1453 } 1454 1455 fibril_rwlock_read_unlock(&namespace_rwlock); 1456 1457 async_exch_t *exch = vfs_exchange_grab(node->fs_handle); 1458 1459 aid_t msg; 1460 msg = async_send_3(exch, VFS_OUT_STATFS, node->service_id, 1461 node->index, false, NULL); 1462 async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 1463 1464 vfs_exchange_release(exch); 1465 1466 sysarg_t rv; 1467 async_wait_for(msg, &rv); 1468 1469 async_answer_0(rid, rv); 1470 1471 vfs_node_put(node); 1427 1472 } 1428 1473
Note:
See TracChangeset
for help on using the changeset viewer.