4 #include <linux/types.h>
6 * Structures of data on the disk
10 * Disc Record at disc address 0xc00
12 struct adfs_discrecord
{
13 unsigned char log2secsize
;
14 unsigned char secspertrack
;
16 unsigned char density
;
18 unsigned char log2bpmb
;
20 unsigned char bootoption
;
21 unsigned char lowsector
;
23 unsigned short zone_spare
;
25 unsigned long disc_size
;
26 unsigned short disc_id
;
27 unsigned char disc_name
[10];
28 unsigned long disc_type
;
29 unsigned long disc_size_high
;
30 unsigned char log2sharesize
:4;
31 unsigned char unused
:4;
32 unsigned char big_flag
:1;
35 #define ADFS_DISCRECORD (0xc00)
36 #define ADFS_DR_OFFSET (0x1c0)
37 #define ADFS_DR_SIZE 60
38 #define ADFS_SUPER_MAGIC 0xadf5
39 #define ADFS_FREE_FRAG 0
40 #define ADFS_BAD_FRAG 1
41 #define ADFS_ROOT_FRAG 2
46 struct adfs_dirheader
{
47 unsigned char startmasseq
;
48 unsigned char startname
[4];
51 #define ADFS_NEWDIR_SIZE 2048
52 #define ADFS_OLDDIR_SIZE 1024
53 #define ADFS_NUM_DIR_ENTRIES 77
58 struct adfs_direntry
{
60 #define ADFS_NAME_LEN 10
64 __u8 dirinddiscadd
[3];
66 #define ADFS_NDA_OWNER_READ (1 << 0)
67 #define ADFS_NDA_OWNER_WRITE (1 << 1)
68 #define ADFS_NDA_LOCKED (1 << 2)
69 #define ADFS_NDA_DIRECTORY (1 << 3)
70 #define ADFS_NDA_EXECUTE (1 << 4)
71 #define ADFS_NDA_PUBLIC_READ (1 << 5)
72 #define ADFS_NDA_PUBLIC_WRITE (1 << 6)
75 #define ADFS_MAX_NAME_LEN 255
76 struct adfs_idir_entry
{
77 __u32 inode_no
; /* Address */
78 __u32 file_id
; /* file id */
79 __u32 name_len
; /* name length */
80 __u32 size
; /* size */
81 __u32 mtime
; /* modification time */
82 __u32 filetype
; /* RiscOS file type */
83 __u8 mode
; /* internal mode */
84 char name
[ADFS_MAX_NAME_LEN
]; /* file name */
92 unsigned char dirlastmask
;
94 unsigned char dirparent
[3];
96 unsigned char reserved
[14];
97 unsigned char endmasseq
;
98 unsigned char endname
[4];
99 unsigned char dircheckbyte
;
102 unsigned char dirlastmask
;
103 unsigned char reserved
[2];
104 unsigned char dirparent
[3];
107 unsigned char endmasseq
;
108 unsigned char endname
[4];
109 unsigned char dircheckbyte
;
115 * Calculate the boot block checksum on an ADFS drive. Note that this will
116 * appear to be correct if the sector contains all zeros, so also check that
117 * the disk size is non-zero!!!
119 extern inline int adfs_checkbblk(unsigned char *ptr
)
121 unsigned int result
= 0;
122 unsigned char *p
= ptr
+ 511;
125 result
= (result
& 0xff) + (result
>> 8);
126 result
= result
+ *--p
;
129 return (result
& 0xff) != ptr
[511];
133 extern unsigned int adfs_val (unsigned char *p
, int len
);
134 extern int adfs_dir_read_parent (struct inode
*inode
, struct buffer_head
**bhp
);
135 extern int adfs_dir_read (struct inode
*inode
, struct buffer_head
**bhp
);
136 extern int adfs_dir_check (struct inode
*inode
, struct buffer_head
**bhp
,
137 int buffers
, union adfs_dirtail
*dtp
);
138 extern void adfs_dir_free (struct buffer_head
**bhp
, int buffers
);
139 extern int adfs_dir_get (struct super_block
*sb
, struct buffer_head
**bhp
,
140 int buffers
, int pos
, unsigned long parent_object_id
,
141 struct adfs_idir_entry
*ide
);
142 extern int adfs_dir_find_entry (struct super_block
*sb
, struct buffer_head
**bhp
,
143 int buffers
, unsigned int index
,
144 struct adfs_idir_entry
*ide
);
147 extern int adfs_inode_validate (struct inode
*inode
);
148 extern unsigned long adfs_inode_generate (unsigned long parent_id
, int diridx
);
149 extern unsigned long adfs_inode_objid (struct inode
*inode
);
150 extern unsigned int adfs_parent_bmap (struct inode
*inode
, int block
);
151 extern int adfs_bmap (struct inode
*inode
, int block
);
152 extern void adfs_read_inode (struct inode
*inode
);
155 extern int adfs_map_lookup (struct super_block
*sb
, int frag_id
, int offset
);
158 extern struct dentry
*adfs_lookup (struct inode
*dir
, struct dentry
*dentry
);
161 extern int init_adfs_fs (void);
162 extern void adfs_error (struct super_block
*, const char *, const char *, ...);
165 * Inodes and file operations
169 extern struct inode_operations adfs_dir_inode_operations
;
172 extern struct inode_operations adfs_file_inode_operations
;