diff options
Diffstat (limited to 'fs/udf/udftime.c')
-rw-r--r-- | fs/udf/udftime.c | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c index adcb87c2da7e..ce595732ba6f 100644 --- a/fs/udf/udftime.c +++ b/fs/udf/udftime.c | |||
@@ -18,8 +18,10 @@ | |||
18 | Boston, MA 02111-1307, USA. */ | 18 | Boston, MA 02111-1307, USA. */ |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * dgb 10/02/98: ripped this from glibc source to help convert timestamps to unix time | 21 | * dgb 10/02/98: ripped this from glibc source to help convert timestamps |
22 | * 10/04/98: added new table-based lookup after seeing how ugly the gnu code is | 22 | * to unix time |
23 | * 10/04/98: added new table-based lookup after seeing how ugly | ||
24 | * the gnu code is | ||
23 | * blf 09/27/99: ripped out all the old code and inserted new table from | 25 | * blf 09/27/99: ripped out all the old code and inserted new table from |
24 | * John Brockmeyer (without leap second corrections) | 26 | * John Brockmeyer (without leap second corrections) |
25 | * rewrote udf_stamp_to_time and fixed timezone accounting in | 27 | * rewrote udf_stamp_to_time and fixed timezone accounting in |
@@ -55,27 +57,27 @@ static const unsigned short int __mon_yday[2][13] = { | |||
55 | 57 | ||
56 | #define MAX_YEAR_SECONDS 69 | 58 | #define MAX_YEAR_SECONDS 69 |
57 | #define SPD 0x15180 /*3600*24 */ | 59 | #define SPD 0x15180 /*3600*24 */ |
58 | #define SPY(y,l,s) (SPD * (365*y+l)+s) | 60 | #define SPY(y, l, s) (SPD * (365 * y + l) + s) |
59 | 61 | ||
60 | static time_t year_seconds[MAX_YEAR_SECONDS]= { | 62 | static time_t year_seconds[MAX_YEAR_SECONDS] = { |
61 | /*1970*/ SPY( 0, 0,0), SPY( 1, 0,0), SPY( 2, 0,0), SPY( 3, 1,0), | 63 | /*1970*/ SPY(0, 0, 0), SPY(1, 0, 0), SPY(2, 0, 0), SPY(3, 1, 0), |
62 | /*1974*/ SPY( 4, 1,0), SPY( 5, 1,0), SPY( 6, 1,0), SPY( 7, 2,0), | 64 | /*1974*/ SPY(4, 1, 0), SPY(5, 1, 0), SPY(6, 1, 0), SPY(7, 2, 0), |
63 | /*1978*/ SPY( 8, 2,0), SPY( 9, 2,0), SPY(10, 2,0), SPY(11, 3,0), | 65 | /*1978*/ SPY(8, 2, 0), SPY(9, 2, 0), SPY(10, 2, 0), SPY(11, 3, 0), |
64 | /*1982*/ SPY(12, 3,0), SPY(13, 3,0), SPY(14, 3,0), SPY(15, 4,0), | 66 | /*1982*/ SPY(12, 3, 0), SPY(13, 3, 0), SPY(14, 3, 0), SPY(15, 4, 0), |
65 | /*1986*/ SPY(16, 4,0), SPY(17, 4,0), SPY(18, 4,0), SPY(19, 5,0), | 67 | /*1986*/ SPY(16, 4, 0), SPY(17, 4, 0), SPY(18, 4, 0), SPY(19, 5, 0), |
66 | /*1990*/ SPY(20, 5,0), SPY(21, 5,0), SPY(22, 5,0), SPY(23, 6,0), | 68 | /*1990*/ SPY(20, 5, 0), SPY(21, 5, 0), SPY(22, 5, 0), SPY(23, 6, 0), |
67 | /*1994*/ SPY(24, 6,0), SPY(25, 6,0), SPY(26, 6,0), SPY(27, 7,0), | 69 | /*1994*/ SPY(24, 6, 0), SPY(25, 6, 0), SPY(26, 6, 0), SPY(27, 7, 0), |
68 | /*1998*/ SPY(28, 7,0), SPY(29, 7,0), SPY(30, 7,0), SPY(31, 8,0), | 70 | /*1998*/ SPY(28, 7, 0), SPY(29, 7, 0), SPY(30, 7, 0), SPY(31, 8, 0), |
69 | /*2002*/ SPY(32, 8,0), SPY(33, 8,0), SPY(34, 8,0), SPY(35, 9,0), | 71 | /*2002*/ SPY(32, 8, 0), SPY(33, 8, 0), SPY(34, 8, 0), SPY(35, 9, 0), |
70 | /*2006*/ SPY(36, 9,0), SPY(37, 9,0), SPY(38, 9,0), SPY(39,10,0), | 72 | /*2006*/ SPY(36, 9, 0), SPY(37, 9, 0), SPY(38, 9, 0), SPY(39, 10, 0), |
71 | /*2010*/ SPY(40,10,0), SPY(41,10,0), SPY(42,10,0), SPY(43,11,0), | 73 | /*2010*/ SPY(40, 10, 0), SPY(41, 10, 0), SPY(42, 10, 0), SPY(43, 11, 0), |
72 | /*2014*/ SPY(44,11,0), SPY(45,11,0), SPY(46,11,0), SPY(47,12,0), | 74 | /*2014*/ SPY(44, 11, 0), SPY(45, 11, 0), SPY(46, 11, 0), SPY(47, 12, 0), |
73 | /*2018*/ SPY(48,12,0), SPY(49,12,0), SPY(50,12,0), SPY(51,13,0), | 75 | /*2018*/ SPY(48, 12, 0), SPY(49, 12, 0), SPY(50, 12, 0), SPY(51, 13, 0), |
74 | /*2022*/ SPY(52,13,0), SPY(53,13,0), SPY(54,13,0), SPY(55,14,0), | 76 | /*2022*/ SPY(52, 13, 0), SPY(53, 13, 0), SPY(54, 13, 0), SPY(55, 14, 0), |
75 | /*2026*/ SPY(56,14,0), SPY(57,14,0), SPY(58,14,0), SPY(59,15,0), | 77 | /*2026*/ SPY(56, 14, 0), SPY(57, 14, 0), SPY(58, 14, 0), SPY(59, 15, 0), |
76 | /*2030*/ SPY(60,15,0), SPY(61,15,0), SPY(62,15,0), SPY(63,16,0), | 78 | /*2030*/ SPY(60, 15, 0), SPY(61, 15, 0), SPY(62, 15, 0), SPY(63, 16, 0), |
77 | /*2034*/ SPY(64,16,0), SPY(65,16,0), SPY(66,16,0), SPY(67,17,0), | 79 | /*2034*/ SPY(64, 16, 0), SPY(65, 16, 0), SPY(66, 16, 0), SPY(67, 17, 0), |
78 | /*2038*/ SPY(68,17,0) | 80 | /*2038*/ SPY(68, 17, 0) |
79 | }; | 81 | }; |
80 | 82 | ||
81 | extern struct timezone sys_tz; | 83 | extern struct timezone sys_tz; |
@@ -115,7 +117,7 @@ time_t *udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src) | |||
115 | return dest; | 117 | return dest; |
116 | } | 118 | } |
117 | 119 | ||
118 | kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts) | 120 | kernel_timestamp *udf_time_to_stamp(kernel_timestamp *dest, struct timespec ts) |
119 | { | 121 | { |
120 | long int days, rem, y; | 122 | long int days, rem, y; |
121 | const unsigned short int *ip; | 123 | const unsigned short int *ip; |
@@ -137,7 +139,7 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts) | |||
137 | dest->second = rem % 60; | 139 | dest->second = rem % 60; |
138 | y = 1970; | 140 | y = 1970; |
139 | 141 | ||
140 | #define DIV(a,b) ((a) / (b) - ((a) % (b) < 0)) | 142 | #define DIV(a, b) ((a) / (b) - ((a) % (b) < 0)) |
141 | #define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400)) | 143 | #define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400)) |
142 | 144 | ||
143 | while (days < 0 || days >= (__isleap(y) ? 366 : 365)) { | 145 | while (days < 0 || days >= (__isleap(y) ? 366 : 365)) { |
@@ -145,8 +147,8 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts) | |||
145 | 147 | ||
146 | /* Adjust DAYS and Y to match the guessed year. */ | 148 | /* Adjust DAYS and Y to match the guessed year. */ |
147 | days -= ((yg - y) * 365 | 149 | days -= ((yg - y) * 365 |
148 | + LEAPS_THRU_END_OF (yg - 1) | 150 | + LEAPS_THRU_END_OF(yg - 1) |
149 | - LEAPS_THRU_END_OF (y - 1)); | 151 | - LEAPS_THRU_END_OF(y - 1)); |
150 | y = yg; | 152 | y = yg; |
151 | } | 153 | } |
152 | dest->year = y; | 154 | dest->year = y; |
@@ -158,7 +160,8 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts) | |||
158 | dest->day = days + 1; | 160 | dest->day = days + 1; |
159 | 161 | ||
160 | dest->centiseconds = ts.tv_nsec / 10000000; | 162 | dest->centiseconds = ts.tv_nsec / 10000000; |
161 | dest->hundredsOfMicroseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100; | 163 | dest->hundredsOfMicroseconds = (ts.tv_nsec / 1000 - |
164 | dest->centiseconds * 10000) / 100; | ||
162 | dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 - | 165 | dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 - |
163 | dest->hundredsOfMicroseconds * 100); | 166 | dest->hundredsOfMicroseconds * 100); |
164 | return dest; | 167 | return dest; |