Changeset 9c0c0e1 in mainline for uspace/srv/fs/ext4fs/ext4fs_ops.c
- Timestamp:
- 2011-10-04T12:18:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a23297c
- Parents:
- 01ab41b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/ext4fs/ext4fs_ops.c
r01ab41b r9c0c0e1 41 41 #include <libfs.h> 42 42 #include <malloc.h> 43 #include <stdio.h> 43 44 #include <ipc/loc.h> 44 45 #include "ext4fs.h" … … 46 47 47 48 #define EXT4FS_NODE(node) ((node) ? (ext4fs_node_t *) (node)->data : NULL) 49 #define EXT4FS_DBG(format, ...) {if (true) printf("ext4fs: %s: " format "\n", __FUNCTION__, ##__VA_ARGS__);} 48 50 49 51 typedef struct ext4fs_instance { … … 67 69 static int ext4fs_instance_get(service_id_t, ext4fs_instance_t **); 68 70 static int ext4fs_node_get_core(fs_node_t **, ext4fs_instance_t *, fs_index_t); 69 71 static int ext4fs_node_put_core(ext4fs_node_t *); 70 72 71 73 /* … … 120 122 */ 121 123 124 /** 125 * TODO doxy 126 */ 122 127 int ext4fs_instance_get(service_id_t service_id, ext4fs_instance_t **inst) 123 128 { … … 145 150 } 146 151 152 /** 153 * TODO doxy 154 */ 147 155 int ext4fs_root_get(fs_node_t **rfn, service_id_t service_id) 148 156 { … … 150 158 } 151 159 160 /** 161 * TODO doxy 162 */ 152 163 int ext4fs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component) 153 164 { … … 156 167 } 157 168 169 /** 170 * TODO doxy 171 */ 158 172 int ext4fs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index) 159 173 { 160 // TODO 161 return 0; 162 } 163 174 ext4fs_instance_t *inst = NULL; 175 int rc; 176 177 rc = ext4fs_instance_get(service_id, &inst); 178 if (rc != EOK) { 179 return rc; 180 } 181 182 return ext4fs_node_get_core(rfn, inst, index); 183 } 184 185 /** 186 * TODO doxy 187 */ 164 188 int ext4fs_node_get_core(fs_node_t **rfn, ext4fs_instance_t *inst, 165 189 fs_index_t index) … … 172 196 * TODO doxy 173 197 */ 198 int ext4fs_node_put_core(ext4fs_node_t *enode) { 199 // TODO 200 return EOK; 201 } 202 203 /** 204 * TODO doxy 205 */ 174 206 int ext4fs_node_open(fs_node_t *fn) 175 207 { … … 180 212 int ext4fs_node_put(fs_node_t *fn) 181 213 { 182 // TODO 214 EXT4FS_DBG(""); 215 int rc; 216 ext4fs_node_t *enode = EXT4FS_NODE(fn); 217 218 fibril_mutex_lock(&open_nodes_lock); 219 220 assert(enode->references > 0); 221 enode->references--; 222 if (enode->references == 0) { 223 rc = ext4fs_node_put_core(enode); 224 if (rc != EOK) { 225 fibril_mutex_unlock(&open_nodes_lock); 226 return rc; 227 } 228 } 229 230 fibril_mutex_unlock(&open_nodes_lock); 231 183 232 return EOK; 184 233 } … … 278 327 */ 279 328 329 /** 330 * TODO doxy 331 */ 280 332 static int ext4fs_mounted(service_id_t service_id, const char *opts, 281 333 fs_index_t *index, aoff64_t *size, unsigned *lnkcnt) 282 334 { 335 336 EXT4FS_DBG("Mounting..."); 283 337 284 338 int rc; … … 300 354 } 301 355 302 /* Initialize the filesystem */ 356 EXT4FS_DBG("Basic structures allocated"); 357 358 /* Initialize the filesystem */ 303 359 rc = ext4_filesystem_init(fs, service_id); 304 360 if (rc != EOK) { … … 307 363 return rc; 308 364 } 365 366 EXT4FS_DBG("initialized"); 309 367 310 368 /* Do some sanity checking */ … … 317 375 } 318 376 377 EXT4FS_DBG("Checked and clean"); 378 319 379 /* Check flags */ 320 rc = ext4_filesystem_check_f lags(fs, &read_only);380 rc = ext4_filesystem_check_features(fs, &read_only); 321 381 if (rc != EOK) { 322 382 ext4_filesystem_fini(fs); … … 326 386 } 327 387 388 EXT4FS_DBG("Features checked"); 389 328 390 /* Initialize instance */ 329 391 link_initialize(&inst->link); … … 332 394 inst->open_nodes_count = 0; 333 395 396 EXT4FS_DBG("Instance initialized"); 397 334 398 /* Read root node */ 335 399 fs_node_t *root_node; 336 rc = ext4fs_ node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX);400 rc = ext4fs_root_get(&root_node, inst->service_id); 337 401 if (rc != EOK) { 338 402 ext4_filesystem_fini(fs); … … 343 407 ext4fs_node_t *enode = EXT4FS_NODE(root_node); 344 408 409 EXT4FS_DBG("Root node found"); 410 345 411 /* Add instance to the list */ 346 412 fibril_mutex_lock(&instance_list_mutex); … … 348 414 fibril_mutex_unlock(&instance_list_mutex); 349 415 416 EXT4FS_DBG("Instance added"); 417 350 418 *index = EXT4_INODE_ROOT_INDEX; 351 419 *size = 0; 352 420 *lnkcnt = ext4_inode_get_usage_count(enode->inode_ref->inode); 353 421 422 EXT4FS_DBG("Return values set"); 423 354 424 ext4fs_node_put(root_node); 355 425 356 return EOK; 357 } 358 426 EXT4FS_DBG("Mounting finished"); 427 428 return EOK; 429 } 430 431 /** 432 * TODO doxy 433 */ 359 434 static int ext4fs_unmounted(service_id_t service_id) 360 435 { … … 388 463 } 389 464 465 /** 466 * TODO doxy 467 */ 390 468 static int 391 469 ext4fs_read(service_id_t service_id, fs_index_t index, aoff64_t pos, … … 396 474 } 397 475 476 /** 477 * TODO doxy 478 */ 398 479 static int 399 480 ext4fs_write(service_id_t service_id, fs_index_t index, aoff64_t pos, … … 404 485 } 405 486 487 /** 488 * TODO doxy 489 */ 406 490 static int 407 491 ext4fs_truncate(service_id_t service_id, fs_index_t index, aoff64_t size) … … 411 495 } 412 496 497 /** 498 * TODO doxy 499 */ 413 500 static int ext4fs_close(service_id_t service_id, fs_index_t index) 414 501 { … … 417 504 } 418 505 506 /** 507 * TODO doxy 508 */ 419 509 static int ext4fs_destroy(service_id_t service_id, fs_index_t index) 420 510 { … … 423 513 } 424 514 515 /** 516 * TODO doxy 517 */ 425 518 static int ext4fs_sync(service_id_t service_id, fs_index_t index) 426 519 {
Note:
See TracChangeset
for help on using the changeset viewer.