.. | .. |
---|
242 | 242 | /* |
---|
243 | 243 | * There are two time systems. Both are based on seconds since |
---|
244 | 244 | * a particular time/date. |
---|
245 | | - * Unix: unsigned lil-endian since 00:00 GMT, Jan. 1, 1970 |
---|
| 245 | + * Unix: signed little-endian since 00:00 GMT, Jan. 1, 1970 |
---|
246 | 246 | * mac: unsigned big-endian since 00:00 GMT, Jan. 1, 1904 |
---|
247 | 247 | * |
---|
| 248 | + * HFS implementations are highly inconsistent, this one matches the |
---|
| 249 | + * traditional behavior of 64-bit Linux, giving the most useful |
---|
| 250 | + * time range between 1970 and 2106, by treating any on-disk timestamp |
---|
| 251 | + * under HFS_UTC_OFFSET (Jan 1 1970) as a time between 2040 and 2106. |
---|
248 | 252 | */ |
---|
249 | | -#define __hfs_u_to_mtime(sec) cpu_to_be32(sec + 2082844800U - sys_tz.tz_minuteswest * 60) |
---|
250 | | -#define __hfs_m_to_utime(sec) (be32_to_cpu(sec) - 2082844800U + sys_tz.tz_minuteswest * 60) |
---|
| 253 | +#define HFS_UTC_OFFSET 2082844800U |
---|
251 | 254 | |
---|
| 255 | +static inline time64_t __hfs_m_to_utime(__be32 mt) |
---|
| 256 | +{ |
---|
| 257 | + time64_t ut = (u32)(be32_to_cpu(mt) - HFS_UTC_OFFSET); |
---|
| 258 | + |
---|
| 259 | + return ut + sys_tz.tz_minuteswest * 60; |
---|
| 260 | +} |
---|
| 261 | + |
---|
| 262 | +static inline __be32 __hfs_u_to_mtime(time64_t ut) |
---|
| 263 | +{ |
---|
| 264 | + ut -= sys_tz.tz_minuteswest * 60; |
---|
| 265 | + |
---|
| 266 | + return cpu_to_be32(lower_32_bits(ut) + HFS_UTC_OFFSET); |
---|
| 267 | +} |
---|
252 | 268 | #define HFS_I(inode) (container_of(inode, struct hfs_inode_info, vfs_inode)) |
---|
253 | 269 | #define HFS_SB(sb) ((struct hfs_sb_info *)(sb)->s_fs_info) |
---|
254 | 270 | |
---|
255 | | -#define hfs_m_to_utime(time) (struct timespec){ .tv_sec = __hfs_m_to_utime(time) } |
---|
256 | | -#define hfs_u_to_mtime(time) __hfs_u_to_mtime((time).tv_sec) |
---|
257 | | -#define hfs_mtime() __hfs_u_to_mtime(get_seconds()) |
---|
| 271 | +#define hfs_m_to_utime(time) (struct timespec64){ .tv_sec = __hfs_m_to_utime(time) } |
---|
| 272 | +#define hfs_u_to_mtime(time) __hfs_u_to_mtime((time).tv_sec) |
---|
| 273 | +#define hfs_mtime() __hfs_u_to_mtime(ktime_get_real_seconds()) |
---|
258 | 274 | |
---|
259 | 275 | static inline const char *hfs_mdb_name(struct super_block *sb) |
---|
260 | 276 | { |
---|