aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf
diff options
context:
space:
mode:
Diffstat (limited to 'fs/udf')
-rw-r--r--fs/udf/inode.c45
-rw-r--r--fs/udf/super.c22
-rw-r--r--fs/udf/udfdecl.h5
-rw-r--r--fs/udf/udftime.c22
4 files changed, 41 insertions, 53 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index a7646e9bdbde..2362bf0c6900 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1227,16 +1227,14 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1227 inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) << 1227 inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
1228 (inode->i_sb->s_blocksize_bits - 9); 1228 (inode->i_sb->s_blocksize_bits - 9);
1229 1229
1230 if (!udf_stamp_to_time(&inode->i_atime, 1230 if (!udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime))
1231 lets_to_cpu(fe->accessTime)))
1232 inode->i_atime = sbi->s_record_time; 1231 inode->i_atime = sbi->s_record_time;
1233 1232
1234 if (!udf_stamp_to_time(&inode->i_mtime, 1233 if (!udf_disk_stamp_to_time(&inode->i_mtime,
1235 lets_to_cpu(fe->modificationTime))) 1234 fe->modificationTime))
1236 inode->i_mtime = sbi->s_record_time; 1235 inode->i_mtime = sbi->s_record_time;
1237 1236
1238 if (!udf_stamp_to_time(&inode->i_ctime, 1237 if (!udf_disk_stamp_to_time(&inode->i_ctime, fe->attrTime))
1239 lets_to_cpu(fe->attrTime)))
1240 inode->i_ctime = sbi->s_record_time; 1238 inode->i_ctime = sbi->s_record_time;
1241 1239
1242 iinfo->i_unique = le64_to_cpu(fe->uniqueID); 1240 iinfo->i_unique = le64_to_cpu(fe->uniqueID);
@@ -1247,20 +1245,17 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1247 inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) << 1245 inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) <<
1248 (inode->i_sb->s_blocksize_bits - 9); 1246 (inode->i_sb->s_blocksize_bits - 9);
1249 1247
1250 if (!udf_stamp_to_time(&inode->i_atime, 1248 if (!udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime))
1251 lets_to_cpu(efe->accessTime)))
1252 inode->i_atime = sbi->s_record_time; 1249 inode->i_atime = sbi->s_record_time;
1253 1250
1254 if (!udf_stamp_to_time(&inode->i_mtime, 1251 if (!udf_disk_stamp_to_time(&inode->i_mtime,
1255 lets_to_cpu(efe->modificationTime))) 1252 efe->modificationTime))
1256 inode->i_mtime = sbi->s_record_time; 1253 inode->i_mtime = sbi->s_record_time;
1257 1254
1258 if (!udf_stamp_to_time(&iinfo->i_crtime, 1255 if (!udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime))
1259 lets_to_cpu(efe->createTime)))
1260 iinfo->i_crtime = sbi->s_record_time; 1256 iinfo->i_crtime = sbi->s_record_time;
1261 1257
1262 if (!udf_stamp_to_time(&inode->i_ctime, 1258 if (!udf_disk_stamp_to_time(&inode->i_ctime, efe->attrTime))
1263 lets_to_cpu(efe->attrTime)))
1264 inode->i_ctime = sbi->s_record_time; 1259 inode->i_ctime = sbi->s_record_time;
1265 1260
1266 iinfo->i_unique = le64_to_cpu(efe->uniqueID); 1261 iinfo->i_unique = le64_to_cpu(efe->uniqueID);
@@ -1382,7 +1377,6 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1382 uint32_t udfperms; 1377 uint32_t udfperms;
1383 uint16_t icbflags; 1378 uint16_t icbflags;
1384 uint16_t crclen; 1379 uint16_t crclen;
1385 kernel_timestamp cpu_time;
1386 int err = 0; 1380 int err = 0;
1387 struct udf_sb_info *sbi = UDF_SB(inode->i_sb); 1381 struct udf_sb_info *sbi = UDF_SB(inode->i_sb);
1388 unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; 1382 unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits;
@@ -1485,12 +1479,9 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1485 (inode->i_blocks + (1 << (blocksize_bits - 9)) - 1) >> 1479 (inode->i_blocks + (1 << (blocksize_bits - 9)) - 1) >>
1486 (blocksize_bits - 9)); 1480 (blocksize_bits - 9));
1487 1481
1488 if (udf_time_to_stamp(&cpu_time, inode->i_atime)) 1482 udf_time_to_disk_stamp(&fe->accessTime, inode->i_atime);
1489 fe->accessTime = cpu_to_lets(cpu_time); 1483 udf_time_to_disk_stamp(&fe->modificationTime, inode->i_mtime);
1490 if (udf_time_to_stamp(&cpu_time, inode->i_mtime)) 1484 udf_time_to_disk_stamp(&fe->attrTime, inode->i_ctime);
1491 fe->modificationTime = cpu_to_lets(cpu_time);
1492 if (udf_time_to_stamp(&cpu_time, inode->i_ctime))
1493 fe->attrTime = cpu_to_lets(cpu_time);
1494 memset(&(fe->impIdent), 0, sizeof(regid)); 1485 memset(&(fe->impIdent), 0, sizeof(regid));
1495 strcpy(fe->impIdent.ident, UDF_ID_DEVELOPER); 1486 strcpy(fe->impIdent.ident, UDF_ID_DEVELOPER);
1496 fe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; 1487 fe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
@@ -1525,14 +1516,10 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1525 iinfo->i_crtime.tv_nsec > inode->i_ctime.tv_nsec)) 1516 iinfo->i_crtime.tv_nsec > inode->i_ctime.tv_nsec))
1526 iinfo->i_crtime = inode->i_ctime; 1517 iinfo->i_crtime = inode->i_ctime;
1527 1518
1528 if (udf_time_to_stamp(&cpu_time, inode->i_atime)) 1519 udf_time_to_disk_stamp(&efe->accessTime, inode->i_atime);
1529 efe->accessTime = cpu_to_lets(cpu_time); 1520 udf_time_to_disk_stamp(&efe->modificationTime, inode->i_mtime);
1530 if (udf_time_to_stamp(&cpu_time, inode->i_mtime)) 1521 udf_time_to_disk_stamp(&efe->createTime, iinfo->i_crtime);
1531 efe->modificationTime = cpu_to_lets(cpu_time); 1522 udf_time_to_disk_stamp(&efe->attrTime, inode->i_ctime);
1532 if (udf_time_to_stamp(&cpu_time, iinfo->i_crtime))
1533 efe->createTime = cpu_to_lets(cpu_time);
1534 if (udf_time_to_stamp(&cpu_time, inode->i_ctime))
1535 efe->attrTime = cpu_to_lets(cpu_time);
1536 1523
1537 memset(&(efe->impIdent), 0, sizeof(regid)); 1524 memset(&(efe->impIdent), 0, sizeof(regid));
1538 strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER); 1525 strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index f4cdd530c65f..4d2ecee1970b 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -943,8 +943,8 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
943 943
944 pvoldesc = (struct primaryVolDesc *)bh->b_data; 944 pvoldesc = (struct primaryVolDesc *)bh->b_data;
945 945
946 if (udf_stamp_to_time(&UDF_SB(sb)->s_record_time, 946 if (udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time,
947 lets_to_cpu(pvoldesc->recordingDateAndTime))) { 947 pvoldesc->recordingDateAndTime)) {
948 kernel_timestamp ts; 948 kernel_timestamp ts;
949 ts = lets_to_cpu(pvoldesc->recordingDateAndTime); 949 ts = lets_to_cpu(pvoldesc->recordingDateAndTime);
950 udf_debug("recording time %04u/%02u/%02u" 950 udf_debug("recording time %04u/%02u/%02u"
@@ -1589,7 +1589,6 @@ static void udf_open_lvid(struct super_block *sb)
1589 struct udf_sb_info *sbi = UDF_SB(sb); 1589 struct udf_sb_info *sbi = UDF_SB(sb);
1590 struct buffer_head *bh = sbi->s_lvid_bh; 1590 struct buffer_head *bh = sbi->s_lvid_bh;
1591 if (bh) { 1591 if (bh) {
1592 kernel_timestamp cpu_time;
1593 struct logicalVolIntegrityDesc *lvid = 1592 struct logicalVolIntegrityDesc *lvid =
1594 (struct logicalVolIntegrityDesc *)bh->b_data; 1593 (struct logicalVolIntegrityDesc *)bh->b_data;
1595 struct logicalVolIntegrityDescImpUse *lvidiu = 1594 struct logicalVolIntegrityDescImpUse *lvidiu =
@@ -1597,8 +1596,8 @@ static void udf_open_lvid(struct super_block *sb)
1597 1596
1598 lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; 1597 lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
1599 lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; 1598 lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
1600 if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) 1599 udf_time_to_disk_stamp(&lvid->recordingDateAndTime,
1601 lvid->recordingDateAndTime = cpu_to_lets(cpu_time); 1600 CURRENT_TIME);
1602 lvid->integrityType = LVID_INTEGRITY_TYPE_OPEN; 1601 lvid->integrityType = LVID_INTEGRITY_TYPE_OPEN;
1603 1602
1604 lvid->descTag.descCRC = cpu_to_le16( 1603 lvid->descTag.descCRC = cpu_to_le16(
@@ -1613,7 +1612,6 @@ static void udf_open_lvid(struct super_block *sb)
1613 1612
1614static void udf_close_lvid(struct super_block *sb) 1613static void udf_close_lvid(struct super_block *sb)
1615{ 1614{
1616 kernel_timestamp cpu_time;
1617 struct udf_sb_info *sbi = UDF_SB(sb); 1615 struct udf_sb_info *sbi = UDF_SB(sb);
1618 struct buffer_head *bh = sbi->s_lvid_bh; 1616 struct buffer_head *bh = sbi->s_lvid_bh;
1619 struct logicalVolIntegrityDesc *lvid; 1617 struct logicalVolIntegrityDesc *lvid;
@@ -1628,8 +1626,8 @@ static void udf_close_lvid(struct super_block *sb)
1628 udf_sb_lvidiu(sbi); 1626 udf_sb_lvidiu(sbi);
1629 lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; 1627 lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
1630 lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; 1628 lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
1631 if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) 1629 udf_time_to_disk_stamp(&lvid->recordingDateAndTime,
1632 lvid->recordingDateAndTime = cpu_to_lets(cpu_time); 1630 CURRENT_TIME);
1633 if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev)) 1631 if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev))
1634 lvidiu->maxUDFWriteRev = 1632 lvidiu->maxUDFWriteRev =
1635 cpu_to_le16(UDF_MAX_WRITE_VERSION); 1633 cpu_to_le16(UDF_MAX_WRITE_VERSION);
@@ -1801,12 +1799,12 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1801 } 1799 }
1802 1800
1803 if (!silent) { 1801 if (!silent) {
1804 kernel_timestamp ts; 1802 timestamp ts;
1805 udf_time_to_stamp(&ts, sbi->s_record_time); 1803 udf_time_to_disk_stamp(&ts, sbi->s_record_time);
1806 udf_info("UDF: Mounting volume '%s', " 1804 udf_info("UDF: Mounting volume '%s', "
1807 "timestamp %04u/%02u/%02u %02u:%02u (%x)\n", 1805 "timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
1808 sbi->s_volume_ident, ts.year, ts.month, ts.day, 1806 sbi->s_volume_ident, le16_to_cpu(ts.year), ts.month, ts.day,
1809 ts.hour, ts.minute, ts.typeAndTimezone); 1807 ts.hour, ts.minute, le16_to_cpu(ts.typeAndTimezone));
1810 } 1808 }
1811 if (!(sb->s_flags & MS_RDONLY)) 1809 if (!(sb->s_flags & MS_RDONLY))
1812 udf_open_lvid(sb); 1810 udf_open_lvid(sb);
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index b277524fe608..2cb2f5de4245 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -222,7 +222,8 @@ extern short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);
222extern uint16_t udf_crc(const uint8_t *, uint32_t, uint16_t); 222extern uint16_t udf_crc(const uint8_t *, uint32_t, uint16_t);
223 223
224/* udftime.c */ 224/* udftime.c */
225extern struct timespec *udf_stamp_to_time(struct timespec *dest, kernel_timestamp src); 225extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest,
226extern kernel_timestamp *udf_time_to_stamp(kernel_timestamp *dest, struct timespec src); 226 timestamp src);
227extern timestamp *udf_time_to_disk_stamp(timestamp *dest, struct timespec src);
227 228
228#endif /* __UDF_DECL_H */ 229#endif /* __UDF_DECL_H */
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;