From c3e76580acf17a4592597b02c2d63010f20e7674 Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 11 Oct 2006 03:49:30 +0000 Subject: [PATCH] --- yaml --- r: 39531 b: refs/heads/master c: 438dd926260f11ff01fc3441ac6dd4c412d20ea4 h: refs/heads/master i: 39529: f93f74b1832954f78e9ae37a73aad872975e3745 39527: 1886cd2a86ea5de2b7217af245d1952de02f0d8a v: v3 --- [refs] | 2 +- trunk/fs/cifs/netmisc.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index fd3e6c02b3fc..e383c5e73be7 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 268f3be177ce93791da38facc34126b5038cd851 +refs/heads/master: 438dd926260f11ff01fc3441ac6dd4c412d20ea4 diff --git a/trunk/fs/cifs/netmisc.c b/trunk/fs/cifs/netmisc.c index 3d86b31cf2e4..32562d199552 100644 --- a/trunk/fs/cifs/netmisc.c +++ b/trunk/fs/cifs/netmisc.c @@ -946,6 +946,15 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time) year = sd->Year; days += year * 365; days += (year/4); /* leap year */ + /* generalized leap year calculation is more complex, ie no leap year + for years/100 except for years/400, but since the maximum number for DOS + year is 2**7, the last year is 1980+127, which means we need only + consider 2 special case years, ie the years 2000 and 2100, and only + adjust for the lack of leap year for the year 2100, as 2000 was a + leap year (divisable by 400) */ + if(year >= 120) /* the year 2100 */ + days = days - 1; /* do not count leap year for the year 2100 */ + /* adjust for leap year where we are still before leap day */ days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0); sec += 24 * 60 * 60 * days;