提交 cbf5676a 编写于 作者: M marcin.slusarz@gmail.com 提交者: Jan Kara

udf: convert udf_stamp_to_time to return struct timespec

Signed-off-by: NMarcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: NJan Kara <jack@suse.cz>
上级 c87e8e90
...@@ -1136,20 +1136,6 @@ static void __udf_read_inode(struct inode *inode) ...@@ -1136,20 +1136,6 @@ static void __udf_read_inode(struct inode *inode)
brelse(bh); brelse(bh);
} }
static void udf_fill_inode_time(struct timespec *tspec,
const timestamp *tstamp,
struct udf_sb_info *sbi)
{
time_t convtime;
long convtime_usec;
if (udf_stamp_to_time(&convtime, &convtime_usec,
lets_to_cpu(*tstamp))) {
tspec->tv_sec = convtime;
tspec->tv_nsec = convtime_usec * 1000;
} else
*tspec = sbi->s_record_time;
}
static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
{ {
struct fileEntry *fe; struct fileEntry *fe;
...@@ -1241,10 +1227,17 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) ...@@ -1241,10 +1227,17 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) << inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
(inode->i_sb->s_blocksize_bits - 9); (inode->i_sb->s_blocksize_bits - 9);
udf_fill_inode_time(&inode->i_atime, &fe->accessTime, sbi); if (!udf_stamp_to_time(&inode->i_atime,
udf_fill_inode_time(&inode->i_mtime, &fe->modificationTime, lets_to_cpu(fe->accessTime)))
sbi); inode->i_atime = sbi->s_record_time;
udf_fill_inode_time(&inode->i_ctime, &fe->attrTime, sbi);
if (!udf_stamp_to_time(&inode->i_mtime,
lets_to_cpu(fe->modificationTime)))
inode->i_mtime = sbi->s_record_time;
if (!udf_stamp_to_time(&inode->i_ctime,
lets_to_cpu(fe->attrTime)))
inode->i_ctime = sbi->s_record_time;
iinfo->i_unique = le64_to_cpu(fe->uniqueID); iinfo->i_unique = le64_to_cpu(fe->uniqueID);
iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr); iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr);
...@@ -1254,11 +1247,21 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) ...@@ -1254,11 +1247,21 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) << inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) <<
(inode->i_sb->s_blocksize_bits - 9); (inode->i_sb->s_blocksize_bits - 9);
udf_fill_inode_time(&inode->i_atime, &efe->accessTime, sbi); if (!udf_stamp_to_time(&inode->i_atime,
udf_fill_inode_time(&inode->i_mtime, &efe->modificationTime, lets_to_cpu(efe->accessTime)))
sbi); inode->i_atime = sbi->s_record_time;
udf_fill_inode_time(&iinfo->i_crtime, &efe->createTime, sbi);
udf_fill_inode_time(&inode->i_ctime, &efe->attrTime, sbi); if (!udf_stamp_to_time(&inode->i_mtime,
lets_to_cpu(efe->modificationTime)))
inode->i_mtime = sbi->s_record_time;
if (!udf_stamp_to_time(&iinfo->i_crtime,
lets_to_cpu(efe->createTime)))
iinfo->i_crtime = sbi->s_record_time;
if (!udf_stamp_to_time(&inode->i_ctime,
lets_to_cpu(efe->attrTime)))
inode->i_ctime = sbi->s_record_time;
iinfo->i_unique = le64_to_cpu(efe->uniqueID); iinfo->i_unique = le64_to_cpu(efe->uniqueID);
iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr); iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
......
...@@ -938,24 +938,19 @@ static int udf_find_fileset(struct super_block *sb, ...@@ -938,24 +938,19 @@ static int udf_find_fileset(struct super_block *sb,
static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh) static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
{ {
struct primaryVolDesc *pvoldesc; struct primaryVolDesc *pvoldesc;
time_t recording;
long recording_usec;
struct ustr instr; struct ustr instr;
struct ustr outstr; struct ustr outstr;
pvoldesc = (struct primaryVolDesc *)bh->b_data; pvoldesc = (struct primaryVolDesc *)bh->b_data;
if (udf_stamp_to_time(&recording, &recording_usec, if (udf_stamp_to_time(&UDF_SB(sb)->s_record_time,
lets_to_cpu(pvoldesc->recordingDateAndTime))) { lets_to_cpu(pvoldesc->recordingDateAndTime))) {
kernel_timestamp ts; kernel_timestamp ts;
ts = lets_to_cpu(pvoldesc->recordingDateAndTime); ts = lets_to_cpu(pvoldesc->recordingDateAndTime);
udf_debug("recording time %ld/%ld, %04u/%02u/%02u" udf_debug("recording time %04u/%02u/%02u"
" %02u:%02u (%x)\n", " %02u:%02u (%x)\n",
recording, recording_usec,
ts.year, ts.month, ts.day, ts.hour, ts.year, ts.month, ts.day, ts.hour,
ts.minute, ts.typeAndTimezone); ts.minute, ts.typeAndTimezone);
UDF_SB(sb)->s_record_time.tv_sec = recording;
UDF_SB(sb)->s_record_time.tv_nsec = recording_usec * 1000;
} }
if (!udf_build_ustr(&instr, pvoldesc->volIdent, 32)) if (!udf_build_ustr(&instr, pvoldesc->volIdent, 32))
......
...@@ -222,7 +222,7 @@ extern short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int); ...@@ -222,7 +222,7 @@ extern short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);
extern uint16_t udf_crc(const uint8_t *, uint32_t, uint16_t); extern uint16_t udf_crc(const uint8_t *, uint32_t, uint16_t);
/* udftime.c */ /* udftime.c */
extern time_t *udf_stamp_to_time(time_t *, long *, kernel_timestamp); extern struct timespec *udf_stamp_to_time(struct timespec *dest, kernel_timestamp src);
extern kernel_timestamp *udf_time_to_stamp(kernel_timestamp *, struct timespec); extern kernel_timestamp *udf_time_to_stamp(kernel_timestamp *dest, struct timespec src);
#endif /* __UDF_DECL_H */ #endif /* __UDF_DECL_H */
...@@ -85,7 +85,7 @@ extern struct timezone sys_tz; ...@@ -85,7 +85,7 @@ extern struct timezone sys_tz;
#define SECS_PER_HOUR (60 * 60) #define SECS_PER_HOUR (60 * 60)
#define SECS_PER_DAY (SECS_PER_HOUR * 24) #define SECS_PER_DAY (SECS_PER_HOUR * 24)
time_t *udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src) struct timespec *udf_stamp_to_time(struct timespec *dest, kernel_timestamp src)
{ {
int yday; int yday;
uint8_t type = src.typeAndTimezone >> 12; uint8_t type = src.typeAndTimezone >> 12;
...@@ -97,23 +97,20 @@ time_t *udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src) ...@@ -97,23 +97,20 @@ time_t *udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src)
offset = (offset >> 4); offset = (offset >> 4);
if (offset == -2047) /* unspecified offset */ if (offset == -2047) /* unspecified offset */
offset = 0; offset = 0;
} else { } else
offset = 0; offset = 0;
}
if ((src.year < EPOCH_YEAR) || if ((src.year < EPOCH_YEAR) ||
(src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) { (src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) {
*dest = -1;
*dest_usec = -1;
return NULL; return NULL;
} }
*dest = year_seconds[src.year - EPOCH_YEAR]; dest->tv_sec = year_seconds[src.year - EPOCH_YEAR];
*dest -= offset * 60; dest->tv_sec -= offset * 60;
yday = ((__mon_yday[__isleap(src.year)][src.month - 1]) + src.day - 1); yday = ((__mon_yday[__isleap(src.year)][src.month - 1]) + src.day - 1);
*dest += (((yday * 24) + src.hour) * 60 + src.minute) * 60 + src.second; dest->tv_sec += (((yday * 24) + src.hour) * 60 + src.minute) * 60 + src.second;
*dest_usec = src.centiseconds * 10000 + dest->tv_nsec = 1000 * (src.centiseconds * 10000 +
src.hundredsOfMicroseconds * 100 + src.microseconds; src.hundredsOfMicroseconds * 100 + src.microseconds);
return dest; return dest;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册