Skip to content

overflow error with mke2fs #264

@kvaneesh

Description

@kvaneesh

I get the below error

/misc/mke2fs -d //opensource/tools/buildroot/output/build/buildroot-fs/ext2/target -O extents  -t ext4  -L rootfs  //opensource/tools/buildroot/output/images/rootfs.ext2 3G
mke2fs 1.47.3 (8-Jul-2025)
/opensource/tools/buildroot/output/images/rootfs.ext2 contains a ext4 file system labelled 'rootfs'
        created on Wed Dec 31 18:25:01 2025
Proceed anyway? (y,N) y
Discarding device blocks: done                            
Creating filesystem with 786432 4k blocks and 196608 inodes
Filesystem UUID: 1d56ba77-5eb0-40e3-9a09-bf7cd2bb9bfa
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Copying files into the device: __populate_fs: Ext2 file too big while writing file "rootfs.ext2"
mke2fs: Ext2 file too big while populating file system

-d target_dir contain a file of size 3GB.

This is due to the overflow which is fixed by a change below

modified   misc/create_inode.c
@@ -414,7 +414,7 @@ static ssize_t my_pread(int fd, void *buf, size_t count, off_t offset)
 }
 #endif /* !defined HAVE_PREAD64 && !defined HAVE_PREAD */
 
-static errcode_t write_all(ext2_file_t e2_file, ext2_off_t off, const char *buf, unsigned int n_bytes) {
+static errcode_t write_all(ext2_file_t e2_file, ext2_off64_t off, const char *buf, ssize_t n_bytes) {
 	errcode_t err = ext2fs_file_llseek(e2_file, off, EXT2_SEEK_SET, NULL);
 	if (err)
 		return err;

I haven't looked at all the callers of write_all to verify they are passing the file offset correctly. The above change get the mke2fs to work correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions