Changeset 7ea69a6 in mainline
- Timestamp:
- 2011-03-23T10:40:17Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6f50bb0
- Parents:
- f2d665b4
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext2/libext2_filesystem.c
rf2d665b4 r7ea69a6 297 297 * of the given inode is located. 298 298 * 299 * @param fblock the number of filesystem block, or 0 if no such block is allocated yet 300 * 299 301 * @return EOK on success or negative error code on failure 300 302 */ … … 315 317 if (iblock < EXT2_INODE_DIRECT_BLOCKS) { 316 318 current_block = ext2_inode_get_direct_block(inode, (uint32_t)iblock); 317 if (current_block == 0) {318 return EIO;319 }320 319 *fblock = current_block; 321 320 return EOK; … … 365 364 366 365 if (current_block == 0) { 367 return EIO; 366 *fblock = 0; 367 return EOK; 368 368 } 369 369 -
uspace/srv/fs/ext2fs/ext2fs_ops.c
rf2d665b4 r7ea69a6 56 56 #include <align.h> 57 57 #include <adt/hash_table.h> 58 #include <sys/typefmt.h> 58 59 59 60 #define EXT2FS_NODE(node) ((node) ? (ext2fs_node_t *) (node)->data : NULL) … … 760 761 size_t bytes; 761 762 block_t *block; 763 uint8_t *buffer; 762 764 763 765 file_size = ext2_inode_get_size(inst->filesystem->superblock, … … 777 779 bytes = min(block_size - offset_in_block, size); 778 780 781 // Handle end of file 782 if (pos + bytes > file_size) { 783 bytes = file_size - pos; 784 } 785 779 786 rc = ext2_filesystem_get_inode_data_block_index(inst->filesystem, 780 787 inode_ref->inode, file_block, &fs_block); … … 785 792 } 786 793 794 // Check for sparse file 795 // If ext2_filesystem_get_inode_data_block_index returned 796 // fs_block == 0, it means that the given block is not allocated for the 797 // file and we need to return a buffer of zeros 798 if (fs_block == 0) { 799 buffer = malloc(bytes); 800 if (buffer == NULL) { 801 async_answer_0(callid, ENOMEM); 802 async_answer_0(rid, ENOMEM); 803 return; 804 } 805 806 memset(buffer, 0, bytes); 807 808 async_data_read_finalize(callid, buffer, bytes); 809 async_answer_1(rid, EOK, bytes); 810 811 free(buffer); 812 813 return; 814 } 815 816 // Usual case - we need to read a block from device 787 817 rc = block_get(&block, inst->devmap_handle, fs_block, BLOCK_FLAGS_NONE); 788 818 if (rc != EOK) { … … 792 822 } 793 823 794 async_data_read_finalize(callid, block->data, bytes); 824 assert(offset_in_block + bytes <= block_size); 825 async_data_read_finalize(callid, block->data + offset_in_block, bytes); 795 826 796 827 rc = block_put(block);
Note:
See TracChangeset
for help on using the changeset viewer.