Skip to content

Commit 319d273

Browse files
yann-morin-1998jacmet
authored andcommitted
fs/ext2: generate Y2K38-resilient filesystems
When creating a filesystem, mkfs.ext will chose the inode size depending on the size of the filesystem. Small filesystem get 128-bytes inodes, while bigger filesystems use 256-byte inodes (inode must be a power of 2 larger or equal to 128, and smaller or equal to the blocksize). However, 128-byte inodes can't store timestamps past the dreaded 2038-01-19 03:14:07Z deadline, while inodes larger than or equal to 256 do not have the issue. It turns out that the tipping point to decide whether a filesystem is small or big, is about around the size of the filesystems we generate for our runtime tests. This causes the kernel to emit warning like: ext2 filesystem being remounted at / supports timestamps until 2038 (0x7fffffff) We add a new option to our ext2 filesystem, so that user can specify the size of the inode. That new option defaults to 256 to be resilient to the Y2K38 problem. Note: it was already possible for users to explicitly pass the -I option, through BR2_TARGET_ROOTFS_EXT2_MKFS_OPTIONS. We could have chosen to extend the existing value with a -I 256, but that is not satisfactory. Indeed, we do want to ensure that the default is now Y2K38-OK, even for existing configurations that did not have explicit setting. We also pass that new option before the user-specified arbitrary ones, so that BR2_TARGET_ROOTFS_EXT2_MKFS_OPTIONS still wins (in case -I was set there). Signed-off-by: Yann E. MORIN <[email protected]> [Peter: tweak help text] Signed-off-by: Peter Korsgaard <[email protected]>
1 parent be3a6bf commit 319d273

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

fs/ext2/Config.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ config BR2_TARGET_ROOTFS_EXT2_INODES
6060
int "exact number of inodes (leave at 0 for auto calculation)"
6161
default 0
6262

63+
config BR2_TARGET_ROOTFS_EXT2_INODE_SIZE
64+
int "inode size"
65+
default 256
66+
help
67+
Set the size of inodes, in bytes, as a power of 2 larger or
68+
equal to 128.
69+
70+
Set to 0 to let the filesystem generator decide based on the
71+
file system size. If unsure, keep the default, 256.
72+
73+
Note: 128-byte inodes suffer of the Y2K38 problem, and can't
74+
store timestamps beyond 2038-01-19 03:14:07Z.
75+
6376
config BR2_TARGET_ROOTFS_EXT2_RESBLKS
6477
int "reserved blocks percentage"
6578
default 5

fs/ext2/ext2.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ROOTFS_EXT2_OPTS = \
2222
-N $(BR2_TARGET_ROOTFS_EXT2_INODES) \
2323
-m $(BR2_TARGET_ROOTFS_EXT2_RESBLKS) \
2424
-L "$(ROOTFS_EXT2_LABEL)" \
25+
-I $(BR2_TARGET_ROOTFS_EXT2_INODE_SIZE) \
2526
$(ROOTFS_EXT2_MKFS_OPTS)
2627

2728
ROOTFS_EXT2_DEPENDENCIES = host-e2fsprogs

0 commit comments

Comments
 (0)