summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepa Dinamani <deepa.kernel@gmail.com>2018-05-10 11:26:17 -0400
committerDeepa Dinamani <deepa.kernel@gmail.com>2018-05-25 18:31:14 -0400
commit0220eddac66daa2afdd6cf6d7d5198226d2abf0b (patch)
tree43e5e612c0386d2e4a3afd59cf5c9cecccbf393b
parent0a2dfbecb36119c3fa7d815308c6aa90789bbf02 (diff)
udf: Simplify calls to udf_disk_stamp_to_time
Subsequent patches in the series convert inode timestamps to use struct timespec64 instead of struct timespec as part of solving the y2038 problem. commit fd3cfad374d4 ("udf: Convert udf_disk_stamp_to_time() to use mktime64()") eliminated the NULL return condition from udf_disk_stamp_to_time(). udf_time_to_disk_time() is always called with a valid dest pointer and the return value is ignored. Further, caller can as well check the dest pointer being passed in rather than return argument. Make both the functions return void. This will make the inode timestamp conversion simpler. Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com> Cc: jack@suse.com ---- Changes from v1: * fixed the pointer error pointed by Jan
-rw-r--r--fs/udf/inode.c28
-rw-r--r--fs/udf/super.c17
-rw-r--r--fs/udf/udfdecl.h4
-rw-r--r--fs/udf/udftime.c9
4 files changed, 21 insertions, 37 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index c80765d62f7e..df2378d6ebb4 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1443,15 +1443,9 @@ reread:
1443 inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) << 1443 inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
1444 (inode->i_sb->s_blocksize_bits - 9); 1444 (inode->i_sb->s_blocksize_bits - 9);
1445 1445
1446 if (!udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime)) 1446 udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime);
1447 inode->i_atime = sbi->s_record_time; 1447 udf_disk_stamp_to_time(&inode->i_mtime, fe->modificationTime);
1448 1448 udf_disk_stamp_to_time(&inode->i_ctime, fe->attrTime);
1449 if (!udf_disk_stamp_to_time(&inode->i_mtime,
1450 fe->modificationTime))
1451 inode->i_mtime = sbi->s_record_time;
1452
1453 if (!udf_disk_stamp_to_time(&inode->i_ctime, fe->attrTime))
1454 inode->i_ctime = sbi->s_record_time;
1455 1449
1456 iinfo->i_unique = le64_to_cpu(fe->uniqueID); 1450 iinfo->i_unique = le64_to_cpu(fe->uniqueID);
1457 iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr); 1451 iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr);
@@ -1461,18 +1455,10 @@ reread:
1461 inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) << 1455 inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) <<
1462 (inode->i_sb->s_blocksize_bits - 9); 1456 (inode->i_sb->s_blocksize_bits - 9);
1463 1457
1464 if (!udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime)) 1458 udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime);
1465 inode->i_atime = sbi->s_record_time; 1459 udf_disk_stamp_to_time(&inode->i_mtime, efe->modificationTime);
1466 1460 udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime);
1467 if (!udf_disk_stamp_to_time(&inode->i_mtime, 1461 udf_disk_stamp_to_time(&inode->i_ctime, efe->attrTime);
1468 efe->modificationTime))
1469 inode->i_mtime = sbi->s_record_time;
1470
1471 if (!udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime))
1472 iinfo->i_crtime = sbi->s_record_time;
1473
1474 if (!udf_disk_stamp_to_time(&inode->i_ctime, efe->attrTime))
1475 inode->i_ctime = sbi->s_record_time;
1476 1462
1477 iinfo->i_unique = le64_to_cpu(efe->uniqueID); 1463 iinfo->i_unique = le64_to_cpu(efe->uniqueID);
1478 iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr); 1464 iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 7949c338efa5..8449e5190530 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -864,6 +864,9 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
864 struct buffer_head *bh; 864 struct buffer_head *bh;
865 uint16_t ident; 865 uint16_t ident;
866 int ret = -ENOMEM; 866 int ret = -ENOMEM;
867#ifdef UDFFS_DEBUG
868 struct timestamp *ts;
869#endif
867 870
868 outstr = kmalloc(128, GFP_NOFS); 871 outstr = kmalloc(128, GFP_NOFS);
869 if (!outstr) 872 if (!outstr)
@@ -882,15 +885,15 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
882 885
883 pvoldesc = (struct primaryVolDesc *)bh->b_data; 886 pvoldesc = (struct primaryVolDesc *)bh->b_data;
884 887
885 if (udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time, 888 udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time,
886 pvoldesc->recordingDateAndTime)) { 889 pvoldesc->recordingDateAndTime);
887#ifdef UDFFS_DEBUG 890#ifdef UDFFS_DEBUG
888 struct timestamp *ts = &pvoldesc->recordingDateAndTime; 891 ts = &pvoldesc->recordingDateAndTime;
889 udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n", 892 udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
890 le16_to_cpu(ts->year), ts->month, ts->day, ts->hour, 893 le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
891 ts->minute, le16_to_cpu(ts->typeAndTimezone)); 894 ts->minute, le16_to_cpu(ts->typeAndTimezone));
892#endif 895#endif
893 } 896
894 897
895 ret = udf_dstrCS0toUTF8(outstr, 31, pvoldesc->volIdent, 32); 898 ret = udf_dstrCS0toUTF8(outstr, 31, pvoldesc->volIdent, 32);
896 if (ret < 0) 899 if (ret < 0)
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 68e8a64d22e0..08e515c25a32 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -252,8 +252,8 @@ extern struct long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int);
252extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int); 252extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);
253 253
254/* udftime.c */ 254/* udftime.c */
255extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest, 255extern void udf_disk_stamp_to_time(struct timespec *dest,
256 struct timestamp src); 256 struct timestamp src);
257extern struct timestamp *udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src); 257extern void udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);
258 258
259#endif /* __UDF_DECL_H */ 259#endif /* __UDF_DECL_H */
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c
index 0927a4b2ecaf..67b33ac5d41b 100644
--- a/fs/udf/udftime.c
+++ b/fs/udf/udftime.c
@@ -40,7 +40,7 @@
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/time.h> 41#include <linux/time.h>
42 42
43struct timespec * 43void
44udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src) 44udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
45{ 45{
46 u16 typeAndTimezone = le16_to_cpu(src.typeAndTimezone); 46 u16 typeAndTimezone = le16_to_cpu(src.typeAndTimezone);
@@ -67,10 +67,9 @@ udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
67 * recorded with bogus sub-second values. 67 * recorded with bogus sub-second values.
68 */ 68 */
69 dest->tv_nsec %= NSEC_PER_SEC; 69 dest->tv_nsec %= NSEC_PER_SEC;
70 return dest;
71} 70}
72 71
73struct timestamp * 72void
74udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts) 73udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
75{ 74{
76 long seconds; 75 long seconds;
@@ -79,9 +78,6 @@ udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
79 78
80 offset = -sys_tz.tz_minuteswest; 79 offset = -sys_tz.tz_minuteswest;
81 80
82 if (!dest)
83 return NULL;
84
85 dest->typeAndTimezone = cpu_to_le16(0x1000 | (offset & 0x0FFF)); 81 dest->typeAndTimezone = cpu_to_le16(0x1000 | (offset & 0x0FFF));
86 82
87 seconds = ts.tv_sec + offset * 60; 83 seconds = ts.tv_sec + offset * 60;
@@ -97,7 +93,6 @@ udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
97 dest->centiseconds * 10000) / 100; 93 dest->centiseconds * 10000) / 100;
98 dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 - 94 dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
99 dest->hundredsOfMicroseconds * 100); 95 dest->hundredsOfMicroseconds * 100);
100 return dest;
101} 96}
102 97
103/* EOF */ 98/* EOF */