aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authormarcin.slusarz@gmail.com <marcin.slusarz@gmail.com>2008-02-27 16:50:14 -0500
committerJan Kara <jack@suse.cz>2008-04-17 08:22:29 -0400
commitcbf5676a0e0463f05e5073589f3194846dfb02e7 (patch)
tree80407064556f2c7043d44533a7c9224e6af3e715 /fs
parentc87e8e90d0da1134e42c89dc89559f4bfe282ef9 (diff)
udf: convert udf_stamp_to_time to return struct timespec
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs')
-rw-r--r--fs/udf/inode.c49
-rw-r--r--fs/udf/super.c9
-rw-r--r--fs/udf/udfdecl.h4
-rw-r--r--fs/udf/udftime.c17
4 files changed, 37 insertions, 42 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 3c0a60dad478..a7646e9bdbde 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1136,20 +1136,6 @@ static void __udf_read_inode(struct inode *inode)
1136 brelse(bh); 1136 brelse(bh);
1137} 1137}
1138 1138
1139static void udf_fill_inode_time(struct timespec *tspec,
1140 const timestamp *tstamp,
1141 struct udf_sb_info *sbi)
1142{
1143 time_t convtime;
1144 long convtime_usec;
1145 if (udf_stamp_to_time(&convtime, &convtime_usec,
1146 lets_to_cpu(*tstamp))) {
1147 tspec->tv_sec = convtime;
1148 tspec->tv_nsec = convtime_usec * 1000;
1149 } else
1150 *tspec = sbi->s_record_time;
1151}
1152
1153static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) 1139static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1154{ 1140{
1155 struct fileEntry *fe; 1141 struct fileEntry *fe;
@@ -1241,10 +1227,17 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1241 inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) << 1227 inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
1242 (inode->i_sb->s_blocksize_bits - 9); 1228 (inode->i_sb->s_blocksize_bits - 9);
1243 1229
1244 udf_fill_inode_time(&inode->i_atime, &fe->accessTime, sbi); 1230 if (!udf_stamp_to_time(&inode->i_atime,
1245 udf_fill_inode_time(&inode->i_mtime, &fe->modificationTime, 1231 lets_to_cpu(fe->accessTime)))
1246 sbi); 1232 inode->i_atime = sbi->s_record_time;
1247 udf_fill_inode_time(&inode->i_ctime, &fe->attrTime, sbi); 1233
1234 if (!udf_stamp_to_time(&inode->i_mtime,
1235 lets_to_cpu(fe->modificationTime)))
1236 inode->i_mtime = sbi->s_record_time;
1237
1238 if (!udf_stamp_to_time(&inode->i_ctime,
1239 lets_to_cpu(fe->attrTime)))
1240 inode->i_ctime = sbi->s_record_time;
1248 1241
1249 iinfo->i_unique = le64_to_cpu(fe->uniqueID); 1242 iinfo->i_unique = le64_to_cpu(fe->uniqueID);
1250 iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr); 1243 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 inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) << 1247 inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) <<
1255 (inode->i_sb->s_blocksize_bits - 9); 1248 (inode->i_sb->s_blocksize_bits - 9);
1256 1249
1257 udf_fill_inode_time(&inode->i_atime, &efe->accessTime, sbi); 1250 if (!udf_stamp_to_time(&inode->i_atime,
1258 udf_fill_inode_time(&inode->i_mtime, &efe->modificationTime, 1251 lets_to_cpu(efe->accessTime)))
1259 sbi); 1252 inode->i_atime = sbi->s_record_time;
1260 udf_fill_inode_time(&iinfo->i_crtime, &efe->createTime, sbi); 1253
1261 udf_fill_inode_time(&inode->i_ctime, &efe->attrTime, sbi); 1254 if (!udf_stamp_to_time(&inode->i_mtime,
1255 lets_to_cpu(efe->modificationTime)))
1256 inode->i_mtime = sbi->s_record_time;
1257
1258 if (!udf_stamp_to_time(&iinfo->i_crtime,
1259 lets_to_cpu(efe->createTime)))
1260 iinfo->i_crtime = sbi->s_record_time;
1261
1262 if (!udf_stamp_to_time(&inode->i_ctime,
1263 lets_to_cpu(efe->attrTime)))
1264 inode->i_ctime = sbi->s_record_time;
1262 1265
1263 iinfo->i_unique = le64_to_cpu(efe->uniqueID); 1266 iinfo->i_unique = le64_to_cpu(efe->uniqueID);
1264 iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr); 1267 iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index be0aa424b8f1..f4cdd530c65f 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -938,24 +938,19 @@ static int udf_find_fileset(struct super_block *sb,
938static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh) 938static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
939{ 939{
940 struct primaryVolDesc *pvoldesc; 940 struct primaryVolDesc *pvoldesc;
941 time_t recording;
942 long recording_usec;
943 struct ustr instr; 941 struct ustr instr;
944 struct ustr outstr; 942 struct ustr outstr;
945 943
946 pvoldesc = (struct primaryVolDesc *)bh->b_data; 944 pvoldesc = (struct primaryVolDesc *)bh->b_data;
947 945
948 if (udf_stamp_to_time(&recording, &recording_usec, 946 if (udf_stamp_to_time(&UDF_SB(sb)->s_record_time,
949 lets_to_cpu(pvoldesc->recordingDateAndTime))) { 947 lets_to_cpu(pvoldesc->recordingDateAndTime))) {
950 kernel_timestamp ts; 948 kernel_timestamp ts;
951 ts = lets_to_cpu(pvoldesc->recordingDateAndTime); 949 ts = lets_to_cpu(pvoldesc->recordingDateAndTime);
952 udf_debug("recording time %ld/%ld, %04u/%02u/%02u" 950 udf_debug("recording time %04u/%02u/%02u"
953 " %02u:%02u (%x)\n", 951 " %02u:%02u (%x)\n",
954 recording, recording_usec,
955 ts.year, ts.month, ts.day, ts.hour, 952 ts.year, ts.month, ts.day, ts.hour,
956 ts.minute, ts.typeAndTimezone); 953 ts.minute, ts.typeAndTimezone);
957 UDF_SB(sb)->s_record_time.tv_sec = recording;
958 UDF_SB(sb)->s_record_time.tv_nsec = recording_usec * 1000;
959 } 954 }
960 955
961 if (!udf_build_ustr(&instr, pvoldesc->volIdent, 32)) 956 if (!udf_build_ustr(&instr, pvoldesc->volIdent, 32))
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index cc15f58d497a..b277524fe608 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -222,7 +222,7 @@ 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 time_t *udf_stamp_to_time(time_t *, long *, kernel_timestamp); 225extern struct timespec *udf_stamp_to_time(struct timespec *dest, kernel_timestamp src);
226extern kernel_timestamp *udf_time_to_stamp(kernel_timestamp *, struct timespec); 226extern kernel_timestamp *udf_time_to_stamp(kernel_timestamp *dest, struct timespec src);
227 227
228#endif /* __UDF_DECL_H */ 228#endif /* __UDF_DECL_H */
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c
index ce595732ba6f..12fae6cd444c 100644
--- a/fs/udf/udftime.c
+++ b/fs/udf/udftime.c
@@ -85,7 +85,7 @@ 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
88time_t *udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src) 88struct timespec *udf_stamp_to_time(struct timespec *dest, kernel_timestamp src)
89{ 89{
90 int yday; 90 int yday;
91 uint8_t type = src.typeAndTimezone >> 12; 91 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 offset = (offset >> 4); 97 offset = (offset >> 4);
98 if (offset == -2047) /* unspecified offset */ 98 if (offset == -2047) /* unspecified offset */
99 offset = 0; 99 offset = 0;
100 } else { 100 } else
101 offset = 0; 101 offset = 0;
102 }
103 102
104 if ((src.year < EPOCH_YEAR) || 103 if ((src.year < EPOCH_YEAR) ||
105 (src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) { 104 (src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) {
106 *dest = -1;
107 *dest_usec = -1;
108 return NULL; 105 return NULL;
109 } 106 }
110 *dest = year_seconds[src.year - EPOCH_YEAR]; 107 dest->tv_sec = year_seconds[src.year - EPOCH_YEAR];
111 *dest -= offset * 60; 108 dest->tv_sec -= offset * 60;
112 109
113 yday = ((__mon_yday[__isleap(src.year)][src.month - 1]) + src.day - 1); 110 yday = ((__mon_yday[__isleap(src.year)][src.month - 1]) + src.day - 1);
114 *dest += (((yday * 24) + src.hour) * 60 + src.minute) * 60 + src.second; 111 dest->tv_sec += (((yday * 24) + src.hour) * 60 + src.minute) * 60 + src.second;
115 *dest_usec = src.centiseconds * 10000 + 112 dest->tv_nsec = 1000 * (src.centiseconds * 10000 +
116 src.hundredsOfMicroseconds * 100 + src.microseconds; 113 src.hundredsOfMicroseconds * 100 + src.microseconds);
117 return dest; 114 return dest;
118} 115}
119 116