pre-2.3.4..
[davej-history.git] / include / linux / hfs_fs.h
blobef2bc41052cd1a8e223ec67f2d9d6dd731b2ffe5
1 /*
2 * linux/include/linux/hfs_fs.h
4 * Copyright (C) 1995-1997 Paul H. Hargrove
5 * This file may be distributed under the terms of the GNU Public License.
7 * The source code distribution of the Columbia AppleTalk Package for
8 * UNIX, version 6.0, (CAP) was used as a specification of the
9 * location and format of files used by CAP's Aufs. No code from CAP
10 * appears in hfs_fs. hfs_fs is not a work ``derived'' from CAP in
11 * the sense of intellectual property law.
13 * The source code distributions of Netatalk, versions 1.3.3b2 and
14 * 1.4b2, were used as a specification of the location and format of
15 * files used by Netatalk's afpd. No code from Netatalk appears in
16 * hfs_fs. hfs_fs is not a work ``derived'' from Netatalk in the
17 * sense of intellectual property law.
20 #ifndef _LINUX_HFS_FS_H
21 #define _LINUX_HFS_FS_H
23 #include <linux/hfs_sysdep.h>
25 /* magic numbers for Apple Double header files */
26 #define HFS_DBL_MAGIC 0x00051607
27 #define HFS_SNGL_MAGIC 0x00051600
28 #define HFS_HDR_VERSION_1 0x00010000
29 #define HFS_HDR_VERSION_2 0x00020000
31 /* magic numbers for various internal structures */
32 #define HFS_INO_MAGIC 0x4821
33 #define HFS_SB_MAGIC 0x4822
35 /* The space used for the AppleDouble or AppleSingle headers */
36 #define HFS_DBL_HDR_LEN 1024
38 /* The space used for the Netatalk header */
39 #define HFS_NAT_HDR_LEN 1024 /* 589 for an exact match */
41 /* Macros to extract CNID and file "type" from the Linux inode number */
42 #define HFS_CNID(X) ((X) & 0x3FFFFFFF)
43 #define HFS_ITYPE(X) ((X) & 0xC0000000)
45 /* Macros to enumerate types */
46 #define HFS_ITYPE_TO_INT(X) ((X) >> 30)
47 #define HFS_INT_TO_ITYPE(X) ((X) << 30)
49 /* generic ITYPEs */
50 #define HFS_ITYPE_0 0x00000000
51 #define HFS_ITYPE_1 0x40000000
52 #define HFS_ITYPE_2 0x80000000
53 #define HFS_ITYPE_3 0xC0000000
54 #define HFS_ITYPE_NORM HFS_ITYPE_0 /* "normal" directory or file */
56 /* ITYPEs for CAP */
57 #define HFS_CAP_NORM HFS_ITYPE_0 /* data fork or normal directory */
58 #define HFS_CAP_DATA HFS_ITYPE_0 /* data fork of file */
59 #define HFS_CAP_NDIR HFS_ITYPE_0 /* normal directory */
60 #define HFS_CAP_FNDR HFS_ITYPE_1 /* finder info for file or dir */
61 #define HFS_CAP_RSRC HFS_ITYPE_2 /* resource fork of file */
62 #define HFS_CAP_RDIR HFS_ITYPE_2 /* .resource directory */
63 #define HFS_CAP_FDIR HFS_ITYPE_3 /* .finderinfo directory */
65 /* ITYPEs for Apple Double */
66 #define HFS_DBL_NORM HFS_ITYPE_0 /* data fork or directory */
67 #define HFS_DBL_DATA HFS_ITYPE_0 /* data fork of file */
68 #define HFS_DBL_DIR HFS_ITYPE_0 /* directory */
69 #define HFS_DBL_HDR HFS_ITYPE_1 /* AD header of file or dir */
71 /* ITYPEs for netatalk */
72 #define HFS_NAT_NORM HFS_ITYPE_0 /* data fork or directory */
73 #define HFS_NAT_DATA HFS_ITYPE_0 /* data fork of file */
74 #define HFS_NAT_NDIR HFS_ITYPE_0 /* normal directory */
75 #define HFS_NAT_HDR HFS_ITYPE_1 /* AD header of file or dir */
76 #define HFS_NAT_HDIR HFS_ITYPE_2 /* directory holding AD headers */
78 /* ITYPEs for Apple Single */
79 #define HFS_SGL_NORM HFS_ITYPE_0 /* AppleSingle file or directory */
80 #define HFS_SGL_SNGL HFS_ITYPE_0 /* AppleSingle file */
81 #define HFS_SGL_DIR HFS_ITYPE_0 /* directory */
82 #define HFS_SGL_DINF HFS_ITYPE_1 /* %DirInfo for directory */
84 /* IDs for elements of an AppleDouble or AppleSingle header */
85 #define HFS_HDR_DATA 1 /* data fork */
86 #define HFS_HDR_RSRC 2 /* resource fork */
87 #define HFS_HDR_FNAME 3 /* full (31-character) name */
88 #define HFS_HDR_COMNT 4 /* comment */
89 #define HFS_HDR_BWICN 5 /* b/w icon */
90 #define HFS_HDR_CICON 6 /* color icon info */
91 #define HFS_HDR_OLDI 7 /* old file info */
92 #define HFS_HDR_DATES 8 /* file dates info */
93 #define HFS_HDR_FINFO 9 /* Finder info */
94 #define HFS_HDR_MACI 10 /* Macintosh info */
95 #define HFS_HDR_PRODOSI 11 /* ProDOS info */
96 #define HFS_HDR_MSDOSI 12 /* MSDOS info */
97 #define HFS_HDR_SNAME 13 /* short name */
98 #define HFS_HDR_AFPI 14 /* AFP file info */
99 #define HFS_HDR_DID 15 /* directory id */
100 #define HFS_HDR_MAX 16
103 * There are three time systems. All three are based on seconds since
104 * a particular time/date.
105 * Unix: unsigned lil-endian since 00:00 GMT, Jan. 1, 1970
106 * mac: unsigned big-endian since 00:00 GMT, Jan. 1, 1904
107 * header: SIGNED big-endian since 00:00 GMT, Jan. 1, 2000
110 #define hfs_h_to_mtime(ARG) htonl((hfs_s32)ntohl(ARG)+3029529600U)
111 #define hfs_m_to_htime(ARG) ((hfs_s32)htonl(ntohl(ARG)-3029529600U))
112 #define hfs_h_to_utime(ARG) ((hfs_s32)hfs_to_utc(ntohl(ARG)+946684800U))
113 #define hfs_u_to_htime(ARG) ((hfs_s32)htonl(hfs_from_utc(ARG)-946684800U))
114 #define hfs_u_to_mtime(ARG) htonl(hfs_from_utc(ARG)+2082844800U)
115 #define hfs_m_to_utime(ARG) (hfs_to_utc(ntohl(ARG)-2082844800U))
117 /*======== Data structures kept in memory ========*/
120 * A descriptor for a single entry within the header of an
121 * AppleDouble or AppleSingle header file.
122 * An array of these make up a table of contents for the file.
124 struct hfs_hdr_descr {
125 hfs_u32 id; /* The Apple assigned ID for the entry type */
126 hfs_u32 offset; /* The offset to reach the entry */
127 hfs_u32 length; /* The length of the entry */
131 * The info needed to reconstruct a given header layout
133 struct hfs_hdr_layout {
134 hfs_u32 magic; /* AppleSingle or AppleDouble */
135 hfs_u32 version; /* 0x00010000 or 0x00020000 */
136 hfs_u16 entries; /* How many entries used */
137 struct hfs_hdr_descr
138 descr[HFS_HDR_MAX]; /* Descriptors */
139 struct hfs_hdr_descr
140 *order[HFS_HDR_MAX]; /* 'descr' ordered by offset */
144 * Default header layout for Netatalk and AppleDouble
146 struct hfs_dbl_hdr {
147 hfs_lword_t magic;
148 hfs_lword_t version;
149 hfs_byte_t filler[16];
150 hfs_word_t entries;
151 hfs_byte_t descrs[12*HFS_HDR_MAX];
152 hfs_byte_t real_name[255]; /* id=3 */
153 hfs_byte_t comment[200]; /* id=4 XXX: not yet implemented */
154 hfs_u32 create_time; /* \ */
155 hfs_u32 modify_time; /* | id=8 (or 7) */
156 hfs_u32 backup_time; /* | */
157 hfs_u32 access_time; /* / (attributes with id=7) */
158 hfs_u8 finderinfo[32]; /* id=9 */
159 hfs_u32 fileinfo; /* id=10 */
160 hfs_u32 cnid; /* id=15 */
161 hfs_u8 short_name[12]; /* id=13 */
162 hfs_u8 prodosi[8]; /* id=11 */
166 /* finder metadata for CAP */
167 struct hfs_cap_info {
168 hfs_byte_t fi_fndr[32]; /* Finder's info */
169 hfs_word_t fi_attr; /* AFP attributes (f=file/d=dir) */
170 #define HFS_AFP_INV 0x001 /* Invisible bit (f/d) */
171 #define HFS_AFP_EXPFOLDER 0x002 /* exported folder (d) */
172 #define HFS_AFP_MULTI 0x002 /* Multiuser bit (f) */
173 #define HFS_AFP_SYS 0x004 /* System bit (f/d) */
174 #define HFS_AFP_DOPEN 0x008 /* data fork already open (f) */
175 #define HFS_AFP_MOUNTED 0x008 /* mounted folder (d) */
176 #define HFS_AFP_ROPEN 0x010 /* resource fork already open (f) */
177 #define HFS_AFP_INEXPFOLDER 0x010 /* folder in shared area (d) */
178 #define HFS_AFP_WRI 0x020 /* Write inhibit bit (readonly) (f) */
179 #define HFS_AFP_BACKUP 0x040 /* backup needed bit (f/d) */
180 #define HFS_AFP_RNI 0x080 /* Rename inhibit bit (f/d) */
181 #define HFS_AFP_DEI 0x100 /* Delete inhibit bit (f/d) */
182 #define HFS_AFP_NOCOPY 0x400 /* Copy protect bit (f) */
183 #define HFS_AFP_RDONLY ( HFS_AFP_WRI|HFS_AFP_RNI|HFS_AFP_DEI)
184 hfs_byte_t fi_magic1; /* Magic number: */
185 #define HFS_CAP_MAGIC1 0xFF
186 hfs_byte_t fi_version; /* Version of this structure: */
187 #define HFS_CAP_VERSION 0x10
188 hfs_byte_t fi_magic; /* Another magic number: */
189 #define HFS_CAP_MAGIC 0xDA
190 hfs_byte_t fi_bitmap; /* Bitmap of which names are valid: */
191 #define HFS_CAP_SHORTNAME 0x01
192 #define HFS_CAP_LONGNAME 0x02
193 hfs_byte_t fi_shortfilename[12+1]; /* "short name" (unused) */
194 hfs_byte_t fi_macfilename[32+1]; /* Original (Macintosh) name */
195 hfs_byte_t fi_comln; /* Length of comment (always 0) */
196 hfs_byte_t fi_comnt[200]; /* Finder comment (unused) */
197 /* optional: used by aufs only if compiled with USE_MAC_DATES */
198 hfs_byte_t fi_datemagic; /* Magic number for dates extension: */
199 #define HFS_CAP_DMAGIC 0xDA
200 hfs_byte_t fi_datevalid; /* Bitmap of which dates are valid: */
201 #define HFS_CAP_MDATE 0x01
202 #define HFS_CAP_CDATE 0x02
203 hfs_lword_t fi_ctime; /* Creation date (in AFP format) */
204 hfs_lword_t fi_mtime; /* Modify date (in AFP format) */
205 hfs_lword_t fi_utime; /* Un*x time of last mtime change */
206 hfs_byte_t pad;
209 #ifdef __KERNEL__
211 typedef ssize_t hfs_rwret_t;
212 typedef size_t hfs_rwarg_t;
214 #include <asm/uaccess.h>
216 /* Some forward declarations */
217 struct hfs_fork;
218 struct hfs_cat_key;
219 struct hfs_cat_entry;
220 extern struct hfs_cat_entry *hfs_cat_get(struct hfs_mdb *,
221 const struct hfs_cat_key *);
223 /* dir.c */
224 extern hfs_rwret_t hfs_dir_read(struct file *, char *, hfs_rwarg_t,
225 loff_t *);
226 extern int hfs_create(struct inode *, struct dentry *, int);
227 extern int hfs_mkdir(struct inode *, struct dentry *, int);
228 extern int hfs_unlink(struct inode *, struct dentry *);
229 extern int hfs_rmdir(struct inode *, struct dentry *);
230 extern int hfs_rename(struct inode *, struct dentry *,
231 struct inode *, struct dentry *);
233 /* dir_cap.c */
234 extern const struct hfs_name hfs_cap_reserved1[];
235 extern const struct hfs_name hfs_cap_reserved2[];
236 extern struct inode_operations hfs_cap_ndir_inode_operations;
237 extern struct inode_operations hfs_cap_fdir_inode_operations;
238 extern struct inode_operations hfs_cap_rdir_inode_operations;
239 extern void hfs_cap_drop_dentry(struct dentry *, const ino_t);
241 /* dir_dbl.c */
242 extern const struct hfs_name hfs_dbl_reserved1[];
243 extern const struct hfs_name hfs_dbl_reserved2[];
244 extern struct inode_operations hfs_dbl_dir_inode_operations;
245 extern void hfs_dbl_drop_dentry(struct dentry *, const ino_t);
247 /* dir_nat.c */
248 extern const struct hfs_name hfs_nat_reserved1[];
249 extern const struct hfs_name hfs_nat_reserved2[];
250 extern struct inode_operations hfs_nat_ndir_inode_operations;
251 extern struct inode_operations hfs_nat_hdir_inode_operations;
252 extern void hfs_nat_drop_dentry(struct dentry *, const ino_t);
254 /* dir_sngl.c */
255 extern const struct hfs_name hfs_sngl_reserved1[];
256 extern const struct hfs_name hfs_sngl_reserved2[];
257 extern struct inode_operations hfs_sngl_dir_inode_operations;
259 /* file.c */
260 extern hfs_s32 hfs_do_read(struct inode *, struct hfs_fork *, hfs_u32,
261 char *, hfs_u32, int);
262 extern hfs_s32 hfs_do_write(struct inode *, struct hfs_fork *, hfs_u32,
263 const char *, hfs_u32);
264 extern void hfs_file_fix_mode(struct hfs_cat_entry *entry);
265 extern struct inode_operations hfs_file_inode_operations;
267 /* file_cap.c */
268 extern struct inode_operations hfs_cap_info_inode_operations;
270 /* file_hdr.c */
271 extern struct inode_operations hfs_hdr_inode_operations;
272 extern const struct hfs_hdr_layout hfs_dbl_fil_hdr_layout;
273 extern const struct hfs_hdr_layout hfs_dbl_dir_hdr_layout;
274 extern const struct hfs_hdr_layout hfs_nat_hdr_layout;
275 extern const struct hfs_hdr_layout hfs_nat2_hdr_layout;
276 extern const struct hfs_hdr_layout hfs_sngl_hdr_layout;
278 /* inode.c */
279 extern void hfs_put_inode(struct inode *);
280 extern int hfs_notify_change(struct dentry *, struct iattr *);
281 extern struct inode *hfs_iget(struct hfs_cat_entry *, ino_t, struct dentry *);
283 extern void hfs_cap_ifill(struct inode *, ino_t, const int);
284 extern void hfs_dbl_ifill(struct inode *, ino_t, const int);
285 extern void hfs_nat_ifill(struct inode *, ino_t, const int);
286 extern void hfs_sngl_ifill(struct inode *, ino_t, const int);
288 /* super.c */
289 extern struct super_block *hfs_read_super(struct super_block *,void *,int);
290 extern int init_hfs_fs(void);
292 /* trans.c */
293 extern void hfs_colon2mac(struct hfs_name *, const char *, int);
294 extern void hfs_prcnt2mac(struct hfs_name *, const char *, int);
295 extern void hfs_triv2mac(struct hfs_name *, const char *, int);
296 extern void hfs_latin2mac(struct hfs_name *, const char *, int);
297 extern int hfs_mac2cap(char *, const struct hfs_name *);
298 extern int hfs_mac2nat(char *, const struct hfs_name *);
299 extern int hfs_mac2latin(char *, const struct hfs_name *);
300 extern int hfs_mac2seven(char *, const struct hfs_name *);
301 extern int hfs_mac2eight(char *, const struct hfs_name *);
302 extern int hfs_mac2alpha(char *, const struct hfs_name *);
303 extern int hfs_mac2triv(char *, const struct hfs_name *);
304 extern void hfs_tolower(unsigned char *, int);
306 #define HFS_I(X) (&((X)->u.hfs_i))
307 #define HFS_SB(X) (&((X)->u.hfs_sb))
309 extern __inline__ void hfs_nameout(struct inode *dir, struct hfs_name *out,
310 const char *in, int len) {
311 HFS_SB(dir->i_sb)->s_nameout(out, in, len);
314 extern __inline__ int hfs_namein(struct inode *dir, char *out,
315 const struct hfs_name *in) {
316 int len = HFS_SB(dir->i_sb)->s_namein(out, in);
317 if (HFS_SB(dir->i_sb)->s_lowercase) {
318 hfs_tolower(out, len);
320 return len;
323 #endif /* __KERNEL__ */
324 #endif