python-ext4fs
Advanced tools
@@ -11,3 +11,3 @@ /* tell python that PyArg_ParseTuple(t#) means Py_ssize_t, not int */ | ||
| #include <bytesobject.h> | ||
| #define y "y" | ||
| #define y "s" | ||
| #else | ||
@@ -51,2 +51,3 @@ #define PyBytes_FromStringAndSize PyString_FromStringAndSize | ||
| int android = mountpoint[0] != '\0'? 1: 0; | ||
| if (directorylen == 0) directory = NULL; | ||
@@ -80,3 +81,3 @@ | ||
| PyObject * | ||
| PyInitext4fs(void) | ||
| PyInit_ext4fs(void) | ||
| { | ||
@@ -83,0 +84,0 @@ return PyModule_Create(&ext4_module); |
@@ -95,2 +95,3 @@ /* | ||
| len = blocks * info.block_size; | ||
| //printf("QQQ make_directory blocks=%d\n", blocks); | ||
@@ -117,5 +118,9 @@ if (dir_inode_num) { | ||
| data = inode_allocate_data_extents(inode, len, len); | ||
| if (info.feat_incompat & EXT4_FEATURE_INCOMPAT_EXTENTS) { | ||
| data = inode_allocate_data_extents(inode, len, len); | ||
| } else { | ||
| data = inode_allocate_data_indirect(inode, len, len); | ||
| } | ||
| if (data == NULL) { | ||
| error("failed to allocate %llu extents", len); | ||
| error("failed to allocate %u", len); | ||
| return EXT4_ALLOCATE_FAILED; | ||
@@ -182,4 +187,9 @@ } | ||
| if (len > 0) | ||
| inode_allocate_file_extents(inode, len, filename); | ||
| if (len > 0) { | ||
| if (info.feat_incompat & EXT4_FEATURE_INCOMPAT_EXTENTS) { | ||
| inode_allocate_file_extents(inode, len, filename); | ||
| } else { | ||
| inode_allocate_file_indirect(inode, len, filename); | ||
| } | ||
| } | ||
@@ -186,0 +196,0 @@ inode->i_mode = S_IFREG; |
+54
-17
@@ -32,4 +32,4 @@ /* | ||
| { | ||
| if (DIV_ROUND_UP(backing_len, info.block_size) > EXT4_NDIR_BLOCKS) | ||
| critical_error("indirect backing larger than %d blocks", EXT4_NDIR_BLOCKS); | ||
| //if (DIV_ROUND_UP(backing_len, info.block_size) > EXT4_NDIR_BLOCKS) | ||
| // critical_error("indirect backing larger than %d blocks", EXT4_NDIR_BLOCKS); | ||
@@ -46,3 +46,3 @@ u8 *data = calloc(backing_len, 1); | ||
| get_region(alloc, ®ion_block, ®ion_len); | ||
| //printf("QQQ indirect create_backing region_block=%u, reglen=%u\n", region_block, region_len); | ||
| len = min(region_len * info.block_size, backing_len); | ||
@@ -58,2 +58,22 @@ | ||
| /* Queues each chunk of a file to be written to contiguous data block | ||
| regions */ | ||
| static void create_backing_file(struct block_allocation *alloc, | ||
| unsigned long backing_len, const char *filename) | ||
| { | ||
| off_t offset = 0; | ||
| for (; alloc != NULL && backing_len > 0; get_next_region(alloc)) { | ||
| u32 region_block; | ||
| u32 region_len; | ||
| u32 len; | ||
| get_region(alloc, ®ion_block, ®ion_len); | ||
| len = min(region_len * info.block_size, backing_len); | ||
| queue_data_file(filename, offset, len, region_block); | ||
| offset += len; | ||
| backing_len -= len; | ||
| } | ||
| } | ||
| static void reserve_indirect_block(struct block_allocation *alloc, int len) | ||
@@ -387,5 +407,7 @@ { | ||
| static struct block_allocation *do_inode_allocate_indirect( | ||
| struct ext4_inode *inode, u32 block_len) | ||
| struct ext4_inode *inode, u32 len) | ||
| { | ||
| u32 block_len = DIV_ROUND_UP(len, info.block_size); | ||
| u32 indirect_len = indirect_blocks_needed(block_len); | ||
| //printf("QQQ do_inode_allocate_indirect block_len=%d, ind_len=%d\n", block_len, indirect_len); | ||
@@ -399,2 +421,12 @@ struct block_allocation *alloc = allocate_blocks(block_len + indirect_len); | ||
| reserve_all_indirect_blocks(alloc, block_len); | ||
| rewind_alloc(alloc); | ||
| if (do_inode_attach_indirect(inode, alloc, block_len)) | ||
| error("failed to attach blocks to indirect inode"); | ||
| inode->i_flags = 0; | ||
| inode->i_blocks_lo = (block_len + indirect_len) * info.block_size / 512; | ||
| inode->i_size_lo = len; | ||
| return alloc; | ||
@@ -407,6 +439,4 @@ } | ||
| struct block_allocation *alloc; | ||
| u32 block_len = DIV_ROUND_UP(len, info.block_size); | ||
| u32 indirect_len = indirect_blocks_needed(block_len); | ||
| alloc = do_inode_allocate_indirect(inode, block_len); | ||
| alloc = do_inode_allocate_indirect(inode, len); | ||
| if (alloc == NULL) { | ||
@@ -417,12 +447,2 @@ error("failed to allocate extents for %lu bytes", len); | ||
| reserve_all_indirect_blocks(alloc, block_len); | ||
| rewind_alloc(alloc); | ||
| if (do_inode_attach_indirect(inode, alloc, block_len)) | ||
| error("failed to attach blocks to indirect inode"); | ||
| inode->i_flags = 0; | ||
| inode->i_blocks_lo = (block_len + indirect_len) * info.block_size / 512; | ||
| inode->i_size_lo = len; | ||
| free_alloc(alloc); | ||
@@ -512,1 +532,18 @@ } | ||
| } | ||
| void inode_allocate_file_indirect(struct ext4_inode *inode, unsigned long len, | ||
| const char *filename) | ||
| { | ||
| struct block_allocation *alloc; | ||
| alloc = do_inode_allocate_indirect(inode, len); | ||
| if (alloc == NULL) { | ||
| error("failed to allocate extents for %lu bytes", len); | ||
| return; | ||
| } | ||
| create_backing_file(alloc, len, filename); | ||
| free_alloc(alloc); | ||
| } | ||
@@ -25,2 +25,4 @@ /* | ||
| unsigned long backing_len); | ||
| void inode_allocate_file_indirect(struct ext4_inode *inode, unsigned long len, | ||
| const char *filename); | ||
| void inode_attach_resize(struct ext4_inode *inode, | ||
@@ -27,0 +29,0 @@ struct block_allocation *alloc); |
@@ -235,3 +235,3 @@ /* | ||
| u16 root_mode; | ||
| //printf("QQQ make_ext4fs %s, %s, %s, %d, %d, %d\n", filename, directory, mountpoint, android, gzip, sparse); | ||
| if (info.len == 0) | ||
@@ -278,3 +278,3 @@ info.len = get_file_size(filename); | ||
| info.feat_incompat |= | ||
| EXT4_FEATURE_INCOMPAT_EXTENTS | | ||
| //EXT4_FEATURE_INCOMPAT_EXTENTS | | ||
| EXT4_FEATURE_INCOMPAT_FILETYPE; | ||
@@ -281,0 +281,0 @@ |
@@ -378,3 +378,3 @@ /* | ||
| return; | ||
| //printf("QQQ write_data_block off=%llu data:%x %x %x len=%d\n", off, data[0], data[1], data[2], len); | ||
| ret = out->ops->write(out, data, len); | ||
@@ -381,0 +381,0 @@ if (ret < 0) |
+1
-4
| Metadata-Version: 2.1 | ||
| Name: python-ext4fs | ||
| Version: 0.1a10 | ||
| Version: 0.1a14 | ||
| Summary: Some android tools | ||
@@ -17,4 +17,1 @@ Author: Tarek Galal | ||
| License-File: LICENSE | ||
| UNKNOWN | ||
| Metadata-Version: 2.1 | ||
| Name: python-ext4fs | ||
| Version: 0.1a10 | ||
| Version: 0.1a14 | ||
| Summary: Some android tools | ||
@@ -17,4 +17,1 @@ Author: Tarek Galal | ||
| License-File: LICENSE | ||
| UNKNOWN | ||
+1
-1
@@ -19,3 +19,3 @@ from __future__ import print_function | ||
| packages= find_packages(), | ||
| version="0.1a10", | ||
| version="0.1a14", | ||
| license='GPLv3 License', | ||
@@ -22,0 +22,0 @@ author='Tarek Galal', |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
245446
0.68%1299
-0.08%