Skip to content

Commit

Permalink
udf: Simplify calls to udf_disk_stamp_to_time
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Deepa Dinamani committed May 25, 2018
1 parent 0a2dfbe commit 0220edd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 37 deletions.
28 changes: 7 additions & 21 deletions fs/udf/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1443,15 +1443,9 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
(inode->i_sb->s_blocksize_bits - 9);

if (!udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime))
inode->i_atime = sbi->s_record_time;

if (!udf_disk_stamp_to_time(&inode->i_mtime,
fe->modificationTime))
inode->i_mtime = sbi->s_record_time;

if (!udf_disk_stamp_to_time(&inode->i_ctime, fe->attrTime))
inode->i_ctime = sbi->s_record_time;
udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime);
udf_disk_stamp_to_time(&inode->i_mtime, fe->modificationTime);
udf_disk_stamp_to_time(&inode->i_ctime, fe->attrTime);

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

if (!udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime))
inode->i_atime = sbi->s_record_time;

if (!udf_disk_stamp_to_time(&inode->i_mtime,
efe->modificationTime))
inode->i_mtime = sbi->s_record_time;

if (!udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime))
iinfo->i_crtime = sbi->s_record_time;

if (!udf_disk_stamp_to_time(&inode->i_ctime, efe->attrTime))
inode->i_ctime = sbi->s_record_time;
udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime);
udf_disk_stamp_to_time(&inode->i_mtime, efe->modificationTime);
udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime);
udf_disk_stamp_to_time(&inode->i_ctime, efe->attrTime);

iinfo->i_unique = le64_to_cpu(efe->uniqueID);
iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
Expand Down
17 changes: 10 additions & 7 deletions fs/udf/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,9 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
struct buffer_head *bh;
uint16_t ident;
int ret = -ENOMEM;
#ifdef UDFFS_DEBUG
struct timestamp *ts;
#endif

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

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

if (udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time,
pvoldesc->recordingDateAndTime)) {
udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time,
pvoldesc->recordingDateAndTime);
#ifdef UDFFS_DEBUG
struct timestamp *ts = &pvoldesc->recordingDateAndTime;
udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
ts->minute, le16_to_cpu(ts->typeAndTimezone));
ts = &pvoldesc->recordingDateAndTime;
udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
ts->minute, le16_to_cpu(ts->typeAndTimezone));
#endif
}


ret = udf_dstrCS0toUTF8(outstr, 31, pvoldesc->volIdent, 32);
if (ret < 0)
Expand Down
4 changes: 2 additions & 2 deletions fs/udf/udfdecl.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ extern struct long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int);
extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);

/* udftime.c */
extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest,
extern void udf_disk_stamp_to_time(struct timespec *dest,
struct timestamp src);
extern struct timestamp *udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);
extern void udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);

#endif /* __UDF_DECL_H */
9 changes: 2 additions & 7 deletions fs/udf/udftime.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <linux/kernel.h>
#include <linux/time.h>

struct timespec *
void
udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
{
u16 typeAndTimezone = le16_to_cpu(src.typeAndTimezone);
Expand All @@ -67,10 +67,9 @@ udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
* recorded with bogus sub-second values.
*/
dest->tv_nsec %= NSEC_PER_SEC;
return dest;
}

struct timestamp *
void
udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
{
long seconds;
Expand All @@ -79,9 +78,6 @@ udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)

offset = -sys_tz.tz_minuteswest;

if (!dest)
return NULL;

dest->typeAndTimezone = cpu_to_le16(0x1000 | (offset & 0x0FFF));

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

/* EOF */

0 comments on commit 0220edd

Please sign in to comment.