2 * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $FreeBSD: src/sys/fs/hpfs/hpfs.h,v 1.1 1999/12/09 19:09:58 semenu Exp $
27 * $DragonFly: src/sys/vfs/hpfs/hpfs.h,v 1.23 2006/12/23 00:41:29 swildner Exp $
30 /*#define HPFS_DEBUG 10*/
31 typedef u_int32_t lsn_t
; /* Logical Sector Number */
35 } rsp_t
; /* Redundant Sector Pointer */
39 } sptr_t
; /* Storage Pointer */
42 #define SUSIZE DEV_BSIZE
44 #define SPSIZE DEV_BSIZE
45 #define BMSIZE (4 * DEV_BSIZE)
46 #define HPFS_MAXFILENAME 255
48 #define SU_MAGIC ((u_int64_t)0xFA53E9C5F995E849ULL)
54 lsn_t su_rootfno
; /* Root Fnode */
55 u_int32_t su_btotal
; /* Total blocks */
56 u_int32_t su_badbtotal
; /* Bad Sectors total */
61 u_int32_t su_dbbsz
; /* Sectors in DirBlock Band */
65 char su_volname
[0x20];
66 lsn_t su_uidt
; /* Ptr to User ID Table (8 sect) */
69 #define SP_MAGIC ((u_int64_t)0xFA5229C5F9911849ULL)
70 #define SP_DIRTY 0x0001
71 #define SP_SPDBINUSE 0x0002
72 #define SP_HFINUSE 0x0004
73 #define SP_BADSECT 0x0008
74 #define SP_BADBMBL 0x0010
75 #define SP_FASTFRMT 0x0020
76 #define SP_OLDHPFS 0x0080
77 #define SP_IDASD 0x0100
78 #define SP_RDASD 0x0200
79 #define SP_DASD 0x0400
80 #define SP_MMACTIVE 0x0800
81 #define SP_DCEACLS 0x1000
82 #define SP_DSADDIRTY 0x2000
88 lsn_t sp_hf
; /* HotFix list */
89 u_int32_t sp_hfinuse
; /* HotFixes in use */
90 u_int32_t sp_hfavail
; /* HotFixes available */
91 u_int32_t sp_spdbavail
; /* Spare DirBlocks available */
92 u_int32_t sp_spdbmax
; /* Spare DirBlocks maximum */
95 u_int32_t sp_suchecksum
;
96 u_int32_t sp_spchecksum
;
97 u_int8_t reserved
[0x3C];
101 #define DE_SPECIAL 0x0001
102 #define DE_ACL 0x0002
103 #define DE_DOWN 0x0004
104 #define DE_END 0x0008
105 #define DE_EALIST 0x0010
106 #define DE_EPERM 0x0020
107 #define DE_EXPLACL 0x0040
108 #define DE_NEEDEA 0x0080
109 #define DE_RONLY 0x0100
110 #define DE_HIDDEN 0x0200
111 #define DE_SYSTEM 0x0400
112 #define DE_VOLLABEL 0x0800
113 #define DE_DIR 0x1000
114 #define DE_ARCHIV 0x2000
115 #define DE_DOWNLSN(dep) (*(lsn_t *)((caddr_t)(dep) + (dep)->de_reclen - sizeof(lsn_t)))
116 #define DE_NEXTDE(dep) ((struct hpfsdirent *)((caddr_t)(dep) + (dep)->de_reclen))
117 typedef struct hpfsdirent
{
126 u_int8_t de_flexflag
;
134 #define D_BSIZE (DEV_BSIZE*4)
135 #define D_MAGIC 0x77E40AAE
136 #define D_DIRENT(dbp) ((hpfsdirent_t *)((caddr_t)dbp + sizeof(dirblk_t)))
137 #define D_DE(dbp, deoff) ((hpfsdirent_t *)((caddr_t)dbp + sizeof(dirblk_t) + (deoff)))
138 typedef struct dirblk
{
140 u_int32_t d_freeoff
; /* Offset of first free byte */
141 u_int32_t d_chcnt
; /* Change count */
147 * Allocation Block (ALBLK)
149 #define AB_HBOFFEO 0x01
150 #define AB_FNPARENT 0x20
151 #define AB_SUGGBSCH 0x40
152 #define AB_NODES 0x80
153 #define AB_ALLEAF(abp) ((alleaf_t *)((caddr_t)(abp) + sizeof(alblk_t)))
154 #define AB_ALNODE(abp) ((alnode_t *)((caddr_t)(abp) + sizeof(alblk_t)))
155 #define AB_FREEALP(abp) ((alleaf_t *)((caddr_t)(abp) + (abp)->ab_freeoff))
156 #define AB_FREEANP(abp) ((alnode_t *)((caddr_t)(abp) + (abp)->ab_freeoff))
157 #define AB_LASTALP(abp) (AB_ALLEAF(abp) + (abp)->ab_busycnt - 1)
158 #define AB_LASTANP(abp) (AB_ALNODE(abp) + (abp)->ab_busycnt - 1)
159 #define AB_ADDNREC(abp, sz, n) { \
160 (abp)->ab_busycnt += (n); \
161 (abp)->ab_freecnt -= (n); \
162 (abp)->ab_freeoff += (n) * (sz); \
164 #define AB_RMNREC(abp, sz, n) { \
165 (abp)->ab_busycnt -= (n); \
166 (abp)->ab_freecnt += (n); \
167 (abp)->ab_freeoff -= (n) * (sz);\
169 #define AB_ADDAL(abp) AB_ADDNREC(abp,sizeof(alleaf_t), 1)
170 #define AB_ADDAN(abp) AB_ADDNREC(abp,sizeof(alnode_t), 1)
171 #define AB_RMAL(abp) AB_RMNREC(abp,sizeof(alleaf_t), 1)
172 #define AB_RMAN(abp) AB_RMNREC(abp,sizeof(alnode_t), 1)
173 typedef struct alblk
{
178 u_int16_t ab_freeoff
;
184 #define FNODESIZE DEV_BSIZE
185 #define FN_MAGIC 0xF7E40AAE
188 u_int64_t fn_readhist
;
190 char fn_name
[0xF]; /* First 15 symbols or less */
194 u_int8_t fn_extaclflag
;
195 u_int8_t fn_histbitcount
;
197 u_int16_t fn_ealen
; /* Len of EAs in Fnode */
198 u_int8_t fn_exteaflag
; /* EAs in exteas */
201 u_int8_t fn_abd
[0x60];
204 u_int8_t fn_uid
[0x10];
206 u_int8_t fn_1dasdthr
;
208 u_int32_t fn_dasdlim
;
209 u_int32_t fn_dasdusage
;
210 u_int8_t fn_int
[0x13c];
213 #define EA_NAME(eap) ((char *)(((caddr_t)(eap)) + sizeof(struct ea)))
215 u_int8_t ea_type
; /* 0 - plain val */
216 /* 1 - sptr to val */
217 /* 3 - lsn point to AlSec, cont. val */
220 /*u_int8_t ea_name[]; */
221 /*u_int8_t ea_val[]; */
225 * Allocation Block Data (ALNODE)
227 * NOTE: AlNodes are used when there are too many fragments
228 * to represent the data in the AlBlk
230 #define AN_SET(anp,nextoff,lsn) { \
231 (anp)->an_nextoff = (nextoff); \
232 (anp)->an_lsn = (lsn); \
234 typedef struct alnode
{
235 u_int32_t an_nextoff
; /* next node offset in blocks */
236 lsn_t an_lsn
; /* position of AlSec structure */
240 * Allocaion Block Data (ALLEAF)
242 * NOTE: Leaves are used to point at contiguous block of data
243 * (a fragment or an "extent");
245 #define AL_SET(alp,off,len,lsn) { \
246 (alp)->al_off = (off); \
247 (alp)->al_len = (len); \
248 (alp)->al_lsn = (lsn); \
250 typedef struct alleaf
{
251 u_int32_t al_off
; /* offset in blocks */
252 u_int32_t al_len
; /* len in blocks */
253 lsn_t al_lsn
; /* phys position */
259 * NOTE: AlSecs are not initialized before use, so they ussually
260 * look full of junk. Use the AlBlk tto validate the data.
262 #define AS_MAGIC 0x37E40AAE
263 typedef struct alsec
{
268 u_int8_t as_abd
[0x1E0];
272 * Code Page structures
275 u_int16_t b_country
; /* Country code */
276 u_int16_t b_cpid
; /* CP ID */
277 u_int16_t b_dbcscnt
; /* Count of DBCS ranges in CP */
278 char b_upcase
[0x80]; /* Case conversion table */
279 u_int16_t b_dbcsrange
; /* Start/End DBCS range pairs */
283 #define CPD_MAGIC ((u_int32_t)0x894521F7)
286 u_int16_t d_cpcnt
; /* CP Data count */
287 u_int16_t d_cpfirst
; /* Index of first CP Data */
288 u_int32_t d_checksum
[3]; /* CP Data checksumms */
289 u_int16_t d_offset
[3]; /* Offsets of CP Data blocks */
290 struct cpdblk d_cpdblk
[3]; /* Array of CP Data Blocks */
294 u_int16_t b_country
; /* Country code */
295 u_int16_t b_cpid
; /* CP ID */
296 u_int32_t b_checksum
;
297 lsn_t b_cpdsec
; /* Pointer to CP Data Sector */
298 u_int16_t b_vcpid
; /* Volume spec. CP ID */
299 u_int16_t b_dbcscnt
; /* Count of DBCS ranges in CP */
302 #define CPI_MAGIC ((u_int32_t)0x494521F7)
305 u_int32_t s_cpicnt
; /* Count of CPI's in this sector */
306 u_int32_t s_cpifirst
; /* Index of first CPI in this sector */
307 lsn_t s_next
; /* Pointer to next CPI Sector */
308 struct cpiblk s_cpi
[0x1F]; /* Array of CPI blocks */
312 struct sublock hpm_su
;
313 struct spblock hpm_sp
;
314 struct netexport hpm_export
;
315 struct mount
* hpm_mp
;
316 struct vnode
* hpm_devvp
;
323 struct cpdblk
* hpm_cpdblk
; /* Array of CP Data Blocks */
324 u_char hpm_u2d
[0x80]; /* Unix to DOS Table*/
325 u_char hpm_d2u
[0x80]; /* DOS to Unix Table*/
327 u_long hpm_bavail
; /* Blocks available */
328 u_long hpm_dbnum
; /* Data Band number */
329 u_int8_t
* hpm_bitmap
;
332 #define H_HASHED 0x0001 /* Present in hash */
333 #define H_PARVALID 0x0002 /* parent info is valid */
334 #define H_CHANGE 0x0004 /* node date was changed */
335 #define H_PARCHANGE 0x0008 /* parent node date was changed */
336 #define H_INVAL 0x0010 /* Invalid node */
338 struct lwkt_token h_interlock
;
340 LIST_ENTRY(hpfsnode
) h_hash
;
342 struct hpfsmount
*h_hpmp
;
345 struct vnode
* h_devvp
;
353 /* parent dir information */
357 char h_name
[HPFS_MAXFILENAME
+1]; /* Used to speedup dirent */
358 int h_namelen
; /* lookup */
361 /* This overlays the fid structure (see <sys/mount.h>) */
363 u_int16_t hpfid_len
; /* Length of structure. */
364 u_int16_t hpfid_pad
; /* Force 32-bit alignment. */
365 lsn_t hpfid_ino
; /* File number (ino). */
366 int32_t hpfid_gen
; /* Generation number. */
369 #if defined(HPFS_DEBUG)
370 #define dprintf(a) kprintf a
372 #define ddprintf(a) kprintf a
380 MALLOC_DECLARE(M_HPFSMNT
);
381 MALLOC_DECLARE(M_HPFSNO
);
382 #define VFSTOHPFS(mp) ((struct hpfsmount *)((mp)->mnt_data))
383 #define VTOHP(v) ((struct hpfsnode *)((v)->v_data))
384 #define HPTOV(h) ((struct vnode *)((h)->h_vp))
385 #define FID(f) (*((lsn_t *)(f)->fid_data))
386 #define dbtodoff(dbn) ((off_t)(dbn) << DEV_BSHIFT)
388 #define HASHINIT(a, b, c, d) hashinit((a), (b), (d))
389 #define VOP__LOCK(a, b) vn_lock((a), (b))
390 #define VOP__UNLOCK(a, b) vn_unlock((a))
391 #define VGET(a, b, c) vget((a), (b))
392 #define VN_LOCK(a, b) vn_lock((a), (b))
393 #define LOCKMGR(a, b) lockmgr((a), (b))
397 /* Hash routines, too small to be separate header */
398 void hpfs_hphashinit (void);
399 int hpfs_hphash_uninit (struct vfsconf
*);
400 struct hpfsnode
*hpfs_hphashlookup (cdev_t
, lsn_t
);
401 struct hpfsnode
*hpfs_hphashget (cdev_t
, lsn_t
);
402 struct vnode
*hpfs_hphashvget (cdev_t
, lsn_t
);
403 void hpfs_hphashins (struct hpfsnode
*);
404 void hpfs_hphashrem (struct hpfsnode
*);
405 extern struct lock hpfs_hphash_lock
;