Skip to content

Commit 8434f9a

Browse files
John Sperbeckakpm00
authored andcommitted
init: open output files from cpio unpacking with O_LARGEFILE
If a member of a cpio archive for an initrd or initrams is larger than 2Gb, we'll eventually fail to write to that file when we get to that limit, unless O_LARGEFILE is set. The problem can be seen with this recipe, assuming that BLK_DEV_RAM is not configured: cd /tmp dd if=/dev/zero of=BIGFILE bs=1048576 count=2200 echo BIGFILE | cpio -o -H newc -R root:root > initrd.img kexec -l /boot/vmlinuz-$(uname -r) --initrd=initrd.img --reuse-cmdline kexec -e The console will show 'Initramfs unpacking failed: write error'. With the patch, the error is gone. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: John Sperbeck <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 65291dc commit 8434f9a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

init/initramfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static int __init do_name(void)
367367
if (S_ISREG(mode)) {
368368
int ml = maybe_link();
369369
if (ml >= 0) {
370-
int openflags = O_WRONLY|O_CREAT;
370+
int openflags = O_WRONLY|O_CREAT|O_LARGEFILE;
371371
if (ml != 1)
372372
openflags |= O_TRUNC;
373373
wfile = filp_open(collected, openflags, mode);

0 commit comments

Comments
 (0)