Changeset 984a9ba in mainline for uspace/lib/ext4/src/ops.c
- Timestamp:
- 2018-07-05T09:34:09Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63d46341
- Parents:
- 76f566d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/src/ops.c
r76f566d r984a9ba 58 58 /* Forward declarations of auxiliary functions */ 59 59 60 static errno_t ext4_read_directory( cap_call_handle_t, aoff64_t, size_t,60 static errno_t ext4_read_directory(ipc_call_t *, aoff64_t, size_t, 61 61 ext4_instance_t *, ext4_inode_ref_t *, size_t *); 62 static errno_t ext4_read_file( cap_call_handle_t, aoff64_t, size_t, ext4_instance_t *,62 static errno_t ext4_read_file(ipc_call_t *, aoff64_t, size_t, ext4_instance_t *, 63 63 ext4_inode_ref_t *, size_t *); 64 64 static bool ext4_is_dots(const uint8_t *, size_t); … … 1021 1021 * Receive the read request. 1022 1022 */ 1023 cap_call_handle_t chandle;1023 ipc_call_t call; 1024 1024 size_t size; 1025 if (!async_data_read_receive(&c handle, &size)) {1026 async_answer_0( chandle, EINVAL);1025 if (!async_data_read_receive(&call, &size)) { 1026 async_answer_0(&call, EINVAL); 1027 1027 return EINVAL; 1028 1028 } … … 1031 1031 errno_t rc = ext4_instance_get(service_id, &inst); 1032 1032 if (rc != EOK) { 1033 async_answer_0( chandle, rc);1033 async_answer_0(&call, rc); 1034 1034 return rc; 1035 1035 } … … 1039 1039 rc = ext4_filesystem_get_inode_ref(inst->filesystem, index, &inode_ref); 1040 1040 if (rc != EOK) { 1041 async_answer_0( chandle, rc);1041 async_answer_0(&call, rc); 1042 1042 return rc; 1043 1043 } … … 1046 1046 if (ext4_inode_is_type(inst->filesystem->superblock, inode_ref->inode, 1047 1047 EXT4_INODE_MODE_FILE)) { 1048 rc = ext4_read_file( chandle, pos, size, inst, inode_ref,1048 rc = ext4_read_file(&call, pos, size, inst, inode_ref, 1049 1049 rbytes); 1050 1050 } else if (ext4_inode_is_type(inst->filesystem->superblock, 1051 1051 inode_ref->inode, EXT4_INODE_MODE_DIRECTORY)) { 1052 rc = ext4_read_directory( chandle, pos, size, inst, inode_ref,1052 rc = ext4_read_directory(&call, pos, size, inst, inode_ref, 1053 1053 rbytes); 1054 1054 } else { 1055 1055 /* Other inode types not supported */ 1056 async_answer_0( chandle, ENOTSUP);1056 async_answer_0(&call, ENOTSUP); 1057 1057 rc = ENOTSUP; 1058 1058 } … … 1084 1084 /** Read data from directory. 1085 1085 * 1086 * @param c handle IPC id of call (for communication)1086 * @param call IPC call 1087 1087 * @param pos Position to start reading from 1088 1088 * @param size How many bytes to read … … 1094 1094 * 1095 1095 */ 1096 errno_t ext4_read_directory( cap_call_handle_t chandle, aoff64_t pos, size_t size,1096 errno_t ext4_read_directory(ipc_call_t *call, aoff64_t pos, size_t size, 1097 1097 ext4_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes) 1098 1098 { … … 1100 1100 errno_t rc = ext4_directory_iterator_init(&it, inode_ref, pos); 1101 1101 if (rc != EOK) { 1102 async_answer_0(c handle, rc);1102 async_answer_0(call, rc); 1103 1103 return rc; 1104 1104 } … … 1129 1129 if (buf == NULL) { 1130 1130 ext4_directory_iterator_fini(&it); 1131 async_answer_0(c handle, ENOMEM);1131 async_answer_0(call, ENOMEM); 1132 1132 return ENOMEM; 1133 1133 } … … 1137 1137 found = true; 1138 1138 1139 (void) async_data_read_finalize(c handle, buf, name_size + 1);1139 (void) async_data_read_finalize(call, buf, name_size + 1); 1140 1140 free(buf); 1141 1141 break; … … 1145 1145 if (rc != EOK) { 1146 1146 ext4_directory_iterator_fini(&it); 1147 async_answer_0(c handle, rc);1147 async_answer_0(call, rc); 1148 1148 return rc; 1149 1149 } … … 1168 1168 return EOK; 1169 1169 } else { 1170 async_answer_0(c handle, ENOENT);1170 async_answer_0(call, ENOENT); 1171 1171 return ENOENT; 1172 1172 } … … 1175 1175 /** Read data from file. 1176 1176 * 1177 * @param c handle IPC id of call (for communication)1177 * @param call IPC call 1178 1178 * @param pos Position to start reading from 1179 1179 * @param size How many bytes to read … … 1185 1185 * 1186 1186 */ 1187 errno_t ext4_read_file( cap_call_handle_t chandle, aoff64_t pos, size_t size,1187 errno_t ext4_read_file(ipc_call_t *call, aoff64_t pos, size_t size, 1188 1188 ext4_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes) 1189 1189 { … … 1193 1193 if (pos >= file_size) { 1194 1194 /* Read 0 bytes successfully */ 1195 async_data_read_finalize(c handle, NULL, 0);1195 async_data_read_finalize(call, NULL, 0); 1196 1196 *rbytes = 0; 1197 1197 return EOK; … … 1213 1213 file_block, &fs_block); 1214 1214 if (rc != EOK) { 1215 async_answer_0(c handle, rc);1215 async_answer_0(call, rc); 1216 1216 return rc; 1217 1217 } … … 1227 1227 buffer = malloc(bytes); 1228 1228 if (buffer == NULL) { 1229 async_answer_0(c handle, ENOMEM);1229 async_answer_0(call, ENOMEM); 1230 1230 return ENOMEM; 1231 1231 } … … 1233 1233 memset(buffer, 0, bytes); 1234 1234 1235 rc = async_data_read_finalize(c handle, buffer, bytes);1235 rc = async_data_read_finalize(call, buffer, bytes); 1236 1236 *rbytes = bytes; 1237 1237 … … 1244 1244 rc = block_get(&block, inst->service_id, fs_block, BLOCK_FLAGS_NONE); 1245 1245 if (rc != EOK) { 1246 async_answer_0(c handle, rc);1246 async_answer_0(call, rc); 1247 1247 return rc; 1248 1248 } 1249 1249 1250 1250 assert(offset_in_block + bytes <= block_size); 1251 rc = async_data_read_finalize(c handle, block->data + offset_in_block, bytes);1251 rc = async_data_read_finalize(call, block->data + offset_in_block, bytes); 1252 1252 if (rc != EOK) { 1253 1253 block_put(block); … … 1283 1283 return rc; 1284 1284 1285 cap_call_handle_t chandle;1285 ipc_call_t call; 1286 1286 size_t len; 1287 if (!async_data_write_receive(&c handle, &len)) {1287 if (!async_data_write_receive(&call, &len)) { 1288 1288 rc = EINVAL; 1289 async_answer_0( chandle, rc);1289 async_answer_0(&call, rc); 1290 1290 goto exit; 1291 1291 } … … 1311 1311 &fblock); 1312 1312 if (rc != EOK) { 1313 async_answer_0( chandle, rc);1313 async_answer_0(&call, rc); 1314 1314 goto exit; 1315 1315 } … … 1328 1328 &fblock, true); 1329 1329 if (rc != EOK) { 1330 async_answer_0( chandle, rc);1330 async_answer_0(&call, rc); 1331 1331 goto exit; 1332 1332 } … … 1336 1336 &fblock, false); 1337 1337 if (rc != EOK) { 1338 async_answer_0( chandle, rc);1338 async_answer_0(&call, rc); 1339 1339 goto exit; 1340 1340 } … … 1342 1342 rc = ext4_balloc_alloc_block(inode_ref, &fblock); 1343 1343 if (rc != EOK) { 1344 async_answer_0( chandle, rc);1344 async_answer_0(&call, rc); 1345 1345 goto exit; 1346 1346 } … … 1350 1350 if (rc != EOK) { 1351 1351 ext4_balloc_free_block(inode_ref, fblock); 1352 async_answer_0( chandle, rc);1352 async_answer_0(&call, rc); 1353 1353 goto exit; 1354 1354 } … … 1363 1363 rc = block_get(&write_block, service_id, fblock, flags); 1364 1364 if (rc != EOK) { 1365 async_answer_0( chandle, rc);1365 async_answer_0(&call, rc); 1366 1366 goto exit; 1367 1367 } … … 1370 1370 memset(write_block->data, 0, block_size); 1371 1371 1372 rc = async_data_write_finalize( chandle, write_block->data +1372 rc = async_data_write_finalize(&call, write_block->data + 1373 1373 (pos % block_size), bytes); 1374 1374 if (rc != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.