aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/udftime.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/udf/udftime.c')
-rw-r--r--fs/udf/udftime.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c
index 12fae6cd444c..5f811655c9b5 100644
--- a/fs/udf/udftime.c
+++ b/fs/udf/udftime.c
@@ -85,14 +85,16 @@ extern struct timezone sys_tz;
85#define SECS_PER_HOUR (60 * 60) 85#define SECS_PER_HOUR (60 * 60)
86#define SECS_PER_DAY (SECS_PER_HOUR * 24) 86#define SECS_PER_DAY (SECS_PER_HOUR * 24)
87 87
88struct timespec *udf_stamp_to_time(struct timespec *dest, kernel_timestamp src) 88struct timespec *udf_disk_stamp_to_time(struct timespec *dest, timestamp src)
89{ 89{
90 int yday; 90 int yday;
91 uint8_t type = src.typeAndTimezone >> 12; 91 u16 typeAndTimezone = le16_to_cpu(src.typeAndTimezone);
92 u16 year = le16_to_cpu(src.year);
93 uint8_t type = typeAndTimezone >> 12;
92 int16_t offset; 94 int16_t offset;
93 95
94 if (type == 1) { 96 if (type == 1) {
95 offset = src.typeAndTimezone << 4; 97 offset = typeAndTimezone << 4;
96 /* sign extent offset */ 98 /* sign extent offset */
97 offset = (offset >> 4); 99 offset = (offset >> 4);
98 if (offset == -2047) /* unspecified offset */ 100 if (offset == -2047) /* unspecified offset */
@@ -100,21 +102,21 @@ struct timespec *udf_stamp_to_time(struct timespec *dest, kernel_timestamp src)
100 } else 102 } else
101 offset = 0; 103 offset = 0;
102 104
103 if ((src.year < EPOCH_YEAR) || 105 if ((year < EPOCH_YEAR) ||
104 (src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) { 106 (year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) {
105 return NULL; 107 return NULL;
106 } 108 }
107 dest->tv_sec = year_seconds[src.year - EPOCH_YEAR]; 109 dest->tv_sec = year_seconds[year - EPOCH_YEAR];
108 dest->tv_sec -= offset * 60; 110 dest->tv_sec -= offset * 60;
109 111
110 yday = ((__mon_yday[__isleap(src.year)][src.month - 1]) + src.day - 1); 112 yday = ((__mon_yday[__isleap(year)][src.month - 1]) + src.day - 1);
111 dest->tv_sec += (((yday * 24) + src.hour) * 60 + src.minute) * 60 + src.second; 113 dest->tv_sec += (((yday * 24) + src.hour) * 60 + src.minute) * 60 + src.second;
112 dest->tv_nsec = 1000 * (src.centiseconds * 10000 + 114 dest->tv_nsec = 1000 * (src.centiseconds * 10000 +
113 src.hundredsOfMicroseconds * 100 + src.microseconds); 115 src.hundredsOfMicroseconds * 100 + src.microseconds);
114 return dest; 116 return dest;
115} 117}
116 118
117kernel_timestamp *udf_time_to_stamp(kernel_timestamp *dest, struct timespec ts) 119timestamp *udf_time_to_disk_stamp(timestamp *dest, struct timespec ts)
118{ 120{
119 long int days, rem, y; 121 long int days, rem, y;
120 const unsigned short int *ip; 122 const unsigned short int *ip;
@@ -125,7 +127,7 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp *dest, struct timespec ts)
125 if (!dest) 127 if (!dest)
126 return NULL; 128 return NULL;
127 129
128 dest->typeAndTimezone = 0x1000 | (offset & 0x0FFF); 130 dest->typeAndTimezone = cpu_to_le16(0x1000 | (offset & 0x0FFF));
129 131
130 ts.tv_sec += offset * 60; 132 ts.tv_sec += offset * 60;
131 days = ts.tv_sec / SECS_PER_DAY; 133 days = ts.tv_sec / SECS_PER_DAY;
@@ -148,7 +150,7 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp *dest, struct timespec ts)
148 - LEAPS_THRU_END_OF(y - 1)); 150 - LEAPS_THRU_END_OF(y - 1));
149 y = yg; 151 y = yg;
150 } 152 }
151 dest->year = y; 153 dest->year = cpu_to_le16(y);
152 ip = __mon_yday[__isleap(y)]; 154 ip = __mon_yday[__isleap(y)];
153 for (y = 11; days < (long int)ip[y]; --y) 155 for (y = 11; days < (long int)ip[y]; --y)
154 continue; 156 continue;