Changeset 7ea69a6 in mainline for uspace/srv
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.