7
7
* it under the terms of the GNU General Public License version 2 as
8
8
* published by the Free Software Foundation.
10
#include <linux/smp_lock.h>
11
10
#include <linux/buffer_head.h>
12
11
#include <linux/writeback.h>
73
72
static const struct address_space_operations adfs_aops = {
74
73
.readpage = adfs_readpage,
75
74
.writepage = adfs_writepage,
76
.sync_page = block_sync_page,
77
75
.write_begin = adfs_write_begin,
78
76
.write_end = generic_write_end,
82
static inline unsigned int
83
adfs_filetype(struct inode *inode)
87
if (ADFS_I(inode)->stamped)
88
type = (ADFS_I(inode)->loadaddr >> 8) & 0xfff;
90
type = (unsigned int) -1;
96
81
* Convert ADFS attributes and filetype to Linux permission.
99
84
adfs_atts2mode(struct super_block *sb, struct inode *inode)
101
unsigned int filetype, attr = ADFS_I(inode)->attr;
86
unsigned int attr = ADFS_I(inode)->attr;
102
87
umode_t mode, rmask;
103
88
struct adfs_sb_info *asb = ADFS_SB(sb);
177
160
* Convert an ADFS time to Unix time. ADFS has a 40-bit centi-second time
178
* referenced to 1 Jan 1900 (til 2248)
161
* referenced to 1 Jan 1900 (til 2248) so we need to discard 2208988800 seconds
162
* of time to convert from RISC OS epoch to Unix epoch.
181
165
adfs_adfs2unix_time(struct timespec *tv, struct inode *inode)
183
167
unsigned int high, low;
168
/* 01 Jan 1970 00:00:00 (Unix epoch) as nanoseconds since
169
* 01 Jan 1900 00:00:00 (RISC OS epoch)
171
static const s64 nsec_unix_epoch_diff_risc_os_epoch =
172
2208988800000000000LL;
185
175
if (ADFS_I(inode)->stamped == 0)
188
high = ADFS_I(inode)->loadaddr << 24;
189
low = ADFS_I(inode)->execaddr;
178
high = ADFS_I(inode)->loadaddr & 0xFF; /* top 8 bits of timestamp */
179
low = ADFS_I(inode)->execaddr; /* bottom 32 bits of timestamp */
181
/* convert 40-bit centi-seconds to 32-bit seconds
182
* going via nanoseconds to retain precision
184
nsec = (((s64) high << 32) | (s64) low) * 10000000; /* cs to ns */
194
186
/* Files dated pre 01 Jan 1970 00:00:00. */
195
if (high < 0x336e996a)
187
if (nsec < nsec_unix_epoch_diff_risc_os_epoch)
198
/* Files dated post 18 Jan 2038 03:14:05. */
199
if (high >= 0x656e9969)
202
/* discard 2208988800 (0x336e996a00) seconds of time */
205
/* convert 40-bit centi-seconds to 32-bit seconds */
206
tv->tv_sec = (((high % 100) << 8) + low) / 100 + (high / 100 << 8);
190
/* convert from RISC OS to Unix epoch */
191
nsec -= nsec_unix_epoch_diff_risc_os_epoch;
193
*tv = ns_to_timespec(nsec);
211
*tv = CURRENT_TIME_SEC;
215
201
tv->tv_sec = tv->tv_nsec = 0;
219
tv->tv_sec = 0x7ffffffd;
280
261
ADFS_I(inode)->loadaddr = obj->loadaddr;
281
262
ADFS_I(inode)->execaddr = obj->execaddr;
282
263
ADFS_I(inode)->attr = obj->attr;
283
ADFS_I(inode)->stamped = ((obj->loadaddr & 0xfff00000) == 0xfff00000);
264
ADFS_I(inode)->filetype = obj->filetype;
265
ADFS_I(inode)->stamped = ((obj->loadaddr & 0xfff00000) == 0xfff00000);
285
267
inode->i_mode = adfs_atts2mode(sb, inode);
286
268
adfs_adfs2unix_time(&inode->i_mtime, inode);