Changeset 35f48f2 in mainline for uspace/lib/ext4/libext4_filesystem.c


Ignore:
Timestamp:
2011-11-09T08:48:06Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade
Children:
1e65444
Parents:
0f09d4ea
Message:

succesful writing (only for direct block)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4_filesystem.c

    r0f09d4ea r35f48f2  
    363363
    364364
     365int ext4_filesystem_set_inode_data_block_index(ext4_filesystem_t *fs,
     366                ext4_inode_t *inode, aoff64_t iblock, uint32_t fblock)
     367{
     368
     369//      int rc;
     370//      uint32_t offset_in_block;
     371//      uint32_t current_block;
     372//      aoff64_t block_offset_in_level;
     373//      int i;
     374//      int level;
     375//      block_t *block;
     376
     377        /* Handle inode using extents */
     378        if (ext4_superblock_has_feature_compatible(fs->superblock, EXT4_FEATURE_INCOMPAT_EXTENTS) &&
     379                        ext4_inode_has_flag(inode, EXT4_INODE_FLAG_EXTENTS)) {
     380                // TODO
     381                return ENOTSUP;
     382
     383        }
     384
     385        /* Handle simple case when we are dealing with direct reference */
     386        if (iblock < EXT4_INODE_DIRECT_BLOCK_COUNT) {
     387                ext4_inode_set_direct_block(inode, (uint32_t)iblock, fblock);
     388                return EOK;
     389        }
     390
     391//      /* Determine the indirection level needed to get the desired block */
     392//      level = -1;
     393//      for (i = 1; i < 4; i++) {
     394//              if (iblock < fs->inode_block_limits[i]) {
     395//                      level = i;
     396//                      break;
     397//              }
     398//      }
     399//
     400//      if (level == -1) {
     401//              return EIO;
     402//      }
     403//
     404//      /* Compute offsets for the topmost level */
     405//      block_offset_in_level = iblock - fs->inode_block_limits[level-1];
     406//      current_block = ext4_inode_get_indirect_block(inode, level-1);
     407//      offset_in_block = block_offset_in_level / fs->inode_blocks_per_level[level-1];
     408//
     409//      /* Navigate through other levels, until we find the block number
     410//       * or find null reference meaning we are dealing with sparse file
     411//       */
     412//      while (level > 0) {
     413//              rc = block_get(&block, fs->device, current_block, 0);
     414//              if (rc != EOK) {
     415//                      return rc;
     416//              }
     417//
     418//              current_block = uint32_t_le2host(((uint32_t*)block->data)[offset_in_block]);
     419//
     420//              rc = block_put(block);
     421//              if (rc != EOK) {
     422//                      return rc;
     423//              }
     424//
     425//              if (current_block == 0) {
     426//                      /* This is a sparse file */
     427//                      *fblock = 0;
     428//                      return EOK;
     429//              }
     430//
     431//              level -= 1;
     432//
     433//              /* If we are on the last level, break here as
     434//               * there is no next level to visit
     435//               */
     436//              if (level == 0) {
     437//                      break;
     438//              }
     439//
     440//              /* Visit the next level */
     441//              block_offset_in_level %= fs->inode_blocks_per_level[level];
     442//              offset_in_block = block_offset_in_level / fs->inode_blocks_per_level[level-1];
     443//      }
     444//
     445//      *fblock = current_block;
     446//
     447//      return EOK;
     448//
     449//
     450
     451        return EOK;
     452}
     453
    365454int ext4_filesystem_release_inode_block(ext4_filesystem_t *fs,
    366455                ext4_inode_ref_t *inode_ref, uint32_t iblock)
Note: See TracChangeset for help on using the changeset viewer.