aboutsummaryrefslogtreecommitdiff
path: root/util-linux/mkfs_ext2.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-10-21 23:23:55 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-10-21 23:23:55 +0200
commit010fb00708fd53159c32bd5da7052845f1ebff60 (patch)
tree998d3e823c54c9a4bf61748cd7e1d02deb19e32f /util-linux/mkfs_ext2.c
parenteaba48467c3bf185ce985ae369a9670bb8ee24a2 (diff)
downloadbusybox-w32-010fb00708fd53159c32bd5da7052845f1ebff60.tar.gz
busybox-w32-010fb00708fd53159c32bd5da7052845f1ebff60.tar.bz2
busybox-w32-010fb00708fd53159c32bd5da7052845f1ebff60.zip
mkfs_ext2: make sure we extend the image to requested size
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/mkfs_ext2.c')
-rw-r--r--util-linux/mkfs_ext2.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c
index 06858ef7b..7191a5f55 100644
--- a/util-linux/mkfs_ext2.c
+++ b/util-linux/mkfs_ext2.c
@@ -236,6 +236,13 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv)
236 // open the device, get size in kbytes 236 // open the device, get size in kbytes
237 if (argv[1]) { 237 if (argv[1]) {
238 kilobytes = xatoull(argv[1]); 238 kilobytes = xatoull(argv[1]);
239 // seek past end fails on block devices but works on files
240 if (lseek(fd, kilobytes * 1024 - 1, SEEK_SET) != (off_t)-1) {
241 xwrite(fd, "", 1); // file grows if needed
242 }
243 //else {
244 // bb_error_msg("warning, block device is smaller");
245 //}
239 } else { 246 } else {
240 kilobytes = (uoff_t)xlseek(fd, 0, SEEK_END) / 1024; 247 kilobytes = (uoff_t)xlseek(fd, 0, SEEK_END) / 1024;
241 } 248 }
@@ -610,7 +617,7 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv)
610 dir = (struct ext2_dir *)buf; 617 dir = (struct ext2_dir *)buf;
611 618
612 // dump 2nd+ blocks of "/lost+found" 619 // dump 2nd+ blocks of "/lost+found"
613 STORE_LE(dir->rec_len1, blocksize); // e2fsck 1.41.4 compat 620 STORE_LE(dir->rec_len1, blocksize); // e2fsck 1.41.4 compat (1.41.9 does not need this)
614 for (i = 1; i < lost_and_found_blocks; ++i) 621 for (i = 1; i < lost_and_found_blocks; ++i)
615 PUT((uint64_t)(FETCH_LE32(gd[0].bg_inode_table) + inode_table_blocks + 1+i) * blocksize, 622 PUT((uint64_t)(FETCH_LE32(gd[0].bg_inode_table) + inode_table_blocks + 1+i) * blocksize,
616 buf, blocksize); 623 buf, blocksize);