Skip to content

Commit 0220edd

Browse files
committed
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 fd3cfad ("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
1 parent 0a2dfbe commit 0220edd

4 files changed

Lines changed: 21 additions & 37 deletions

File tree

‎fs/udf/inode.c‎

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,15 +1443,9 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
14431443
inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
14441444
(inode->i_sb->s_blocksize_bits - 9);
14451445

1446-
if (!udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime))
1447-
inode->i_atime = sbi->s_record_time;
1448-
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;
1446+
udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime);
1447+
udf_disk_stamp_to_time(&inode->i_mtime, fe->modificationTime);
1448+
udf_disk_stamp_to_time(&inode->i_ctime, fe->attrTime);
14551449

14561450
iinfo->i_unique = le64_to_cpu(fe->uniqueID);
14571451
iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr);
@@ -1461,18 +1455,10 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
14611455
inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) <<
14621456
(inode->i_sb->s_blocksize_bits - 9);
14631457

1464-
if (!udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime))
1465-
inode->i_atime = sbi->s_record_time;
1466-
1467-
if (!udf_disk_stamp_to_time(&inode->i_mtime,
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;
1458+
udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime);
1459+
udf_disk_stamp_to_time(&inode->i_mtime, efe->modificationTime);
1460+
udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime);
1461+
udf_disk_stamp_to_time(&inode->i_ctime, efe->attrTime);
14761462

14771463
iinfo->i_unique = le64_to_cpu(efe->uniqueID);
14781464
iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);

‎fs/udf/super.c‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,9 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
864864
struct buffer_head *bh;
865865
uint16_t ident;
866866
int ret = -ENOMEM;
867+
#ifdef UDFFS_DEBUG
868+
struct timestamp *ts;
869+
#endif
867870

868871
outstr = kmalloc(128, GFP_NOFS);
869872
if (!outstr)
@@ -882,15 +885,15 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
882885

883886
pvoldesc = (struct primaryVolDesc *)bh->b_data;
884887

885-
if (udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time,
886-
pvoldesc->recordingDateAndTime)) {
888+
udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time,
889+
pvoldesc->recordingDateAndTime);
887890
#ifdef UDFFS_DEBUG
888-
struct timestamp *ts = &pvoldesc->recordingDateAndTime;
889-
udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
890-
le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
891-
ts->minute, le16_to_cpu(ts->typeAndTimezone));
891+
ts = &pvoldesc->recordingDateAndTime;
892+
udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
893+
le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
894+
ts->minute, le16_to_cpu(ts->typeAndTimezone));
892895
#endif
893-
}
896+
894897

895898
ret = udf_dstrCS0toUTF8(outstr, 31, pvoldesc->volIdent, 32);
896899
if (ret < 0)

‎fs/udf/udfdecl.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ extern struct long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int);
252252
extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);
253253

254254
/* udftime.c */
255-
extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest,
255+
extern void udf_disk_stamp_to_time(struct timespec *dest,
256256
struct timestamp src);
257-
extern struct timestamp *udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);
257+
extern void udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);
258258

259259
#endif /* __UDF_DECL_H */

‎fs/udf/udftime.c‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include <linux/kernel.h>
4141
#include <linux/time.h>
4242

43-
struct timespec *
43+
void
4444
udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
4545
{
4646
u16 typeAndTimezone = le16_to_cpu(src.typeAndTimezone);
@@ -67,10 +67,9 @@ udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
6767
* recorded with bogus sub-second values.
6868
*/
6969
dest->tv_nsec %= NSEC_PER_SEC;
70-
return dest;
7170
}
7271

73-
struct timestamp *
72+
void
7473
udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
7574
{
7675
long seconds;
@@ -79,9 +78,6 @@ udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
7978

8079
offset = -sys_tz.tz_minuteswest;
8180

82-
if (!dest)
83-
return NULL;
84-
8581
dest->typeAndTimezone = cpu_to_le16(0x1000 | (offset & 0x0FFF));
8682

8783
seconds = ts.tv_sec + offset * 60;
@@ -97,7 +93,6 @@ udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
9793
dest->centiseconds * 10000) / 100;
9894
dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
9995
dest->hundredsOfMicroseconds * 100);
100-
return dest;
10196
}
10297

10398
/* EOF */

0 commit comments

Comments
 (0)