fs/fat/fat_test.c

Source file repositories/reference/linux-study-clean/fs/fat/fat_test.c

File Facts

System
Linux kernel
Corpus path
fs/fat/fat_test.c
Extension
.c
Size
10342 bytes
Lines
396
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct fat_timestamp_testcase {
	const char *name;
	struct timespec64 ts;
	__le16 time;
	__le16 date;
	u8 cs;
	int time_offset;
};

struct fat_unix2fat_clamp_testcase {
	const char *name;
	struct timespec64 ts;
	__le16 time;
	__le16 date;
	u8 cs;
	int time_offset;
};

struct fat_truncate_atime_testcase {
	const char *name;
	struct timespec64 ts;
	struct timespec64 expected;
	int time_offset;
};

static struct fat_timestamp_testcase time_test_cases[] = {
	{
		.name = "Earliest possible UTC (1980-01-01 00:00:00)",
		.ts = {.tv_sec = 315532800LL, .tv_nsec = 0L},
		.time = cpu_to_le16(0),
		.date = cpu_to_le16(33),
		.cs = 0,
		.time_offset = 0,
	},
	{
		.name = "Latest possible UTC (2107-12-31 23:59:58)",
		.ts = {.tv_sec = 4354819198LL, .tv_nsec = 0L},
		.time = cpu_to_le16(49021),
		.date = cpu_to_le16(65439),
		.cs = 0,
		.time_offset = 0,
	},
	{
		.name = "Earliest possible (UTC-11) (== 1979-12-31 13:00:00 UTC)",
		.ts = {.tv_sec = 315493200LL, .tv_nsec = 0L},
		.time = cpu_to_le16(0),
		.date = cpu_to_le16(33),
		.cs = 0,
		.time_offset = 11 * 60,
	},
	{
		.name = "Latest possible (UTC+11) (== 2108-01-01 10:59:58 UTC)",
		.ts = {.tv_sec = 4354858798LL, .tv_nsec = 0L},
		.time = cpu_to_le16(49021),
		.date = cpu_to_le16(65439),
		.cs = 0,
		.time_offset = -11 * 60,
	},
	{
		.name = "Leap Day / Year (1996-02-29 00:00:00)",
		.ts = {.tv_sec = 825552000LL, .tv_nsec = 0L},
		.time = cpu_to_le16(0),
		.date = cpu_to_le16(8285),
		.cs = 0,
		.time_offset = 0,
	},
	{
		.name = "Year 2000 is leap year (2000-02-29 00:00:00)",
		.ts = {.tv_sec = 951782400LL, .tv_nsec = 0L},
		.time = cpu_to_le16(0),
		.date = cpu_to_le16(10333),
		.cs = 0,
		.time_offset = 0,
	},
	{
		.name = "Year 2100 not leap year (2100-03-01 00:00:00)",
		.ts = {.tv_sec = 4107542400LL, .tv_nsec = 0L},
		.time = cpu_to_le16(0),
		.date = cpu_to_le16(61537),
		.cs = 0,
		.time_offset = 0,
	},
	{
		.name = "Leap year + timezone UTC+1 (== 2004-02-29 00:30:00 UTC)",
		.ts = {.tv_sec = 1078014600LL, .tv_nsec = 0L},
		.time = cpu_to_le16(48064),
		.date = cpu_to_le16(12380),
		.cs = 0,
		.time_offset = -60,
	},

Annotation

Implementation Notes