Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/iFabio/i386/libsaio/ntfs_private.h

Source at commit 214 created 13 years 5 months ago.
By ifabio, update to chameleon trunk 630, and now the pakage folder is the same as blackosx branch, also add Icon "building" into buildpkg script, and add mint theme info into the English localizable.strings.
1/*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*$NetBSD: ntfs.h,v 1.9 1999/10/31 19:45:26 jdolecek Exp $*/
26
27/*-
28 * Copyright (c) 1998, 1999 Semen Ustimenko
29 * All rights reserved.
30 *
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
33 * are met:
34 * 1. Redistributions of source code must retain the above copyright
35 * notice, this list of conditions and the following disclaimer.
36 * 2. Redistributions in binary form must reproduce the above copyright
37 * notice, this list of conditions and the following disclaimer in the
38 * documentation and/or other materials provided with the distribution.
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50 * SUCH DAMAGE.
51 *
52 * $FreeBSD: src/sys/fs/ntfs/ntfs.h,v 1.14 2001/11/27 00:18:33 jhb Exp $
53 */
54
55/*#define NTFS_DEBUG 1*/
56
57#ifdef APPLE
58/* We're using FreeBSD style byte order macros in the source. */
59#include <libkern/OSByteOrder.h>
60#define le16toh(x)OSSwapLittleToHostInt16(x)
61#define le32toh(x)OSSwapLittleToHostInt32(x)
62#define le64toh(x)OSSwapLittleToHostInt64(x)
63
64/* FreeBSD mutexes correspond to Darwin's simple locks */
65#define mtx_lock(lock)simple_lock(lock)
66#define mtx_unlock(lock)simple_unlock(lock)
67#define mtx_destroy(lock)/* Nothing. */
68
69#define lockdestroy(lock)/* Nothing. */
70
71#endif
72
73typedef u_int64_t cn_t;
74typedef u_int16_t wchar;
75
76#pragma pack(1)
77#define BBSIZE1024
78#defineBBOFF((off_t)(0))
79#defineBBLOCK((daddr_t)(0))
80#defineNTFS_MFTINO0
81#defineNTFS_VOLUMEINO3
82#defineNTFS_ATTRDEFINO4
83#defineNTFS_ROOTINO5
84#defineNTFS_BITMAPINO6
85#defineNTFS_BOOTINO7
86#defineNTFS_BADCLUSINO8
87#defineNTFS_UPCASEINO10
88#define NTFS_MAXFILENAME255
89
90struct fixuphdr {
91u_int32_t fh_magic;
92u_int16_t fh_foff;
93u_int16_t fh_fnum;
94};
95
96#define NTFS_AF_INRUN0x00000001
97struct attrhdr {
98u_int32_t a_type;
99u_int32_t reclen;
100u_int8_t a_flag;
101u_int8_t a_namelen;
102u_int8_t a_nameoff;
103u_int8_t reserved1;
104u_int8_t a_compression;
105u_int8_t reserved2;
106u_int16_t a_index;
107};
108#define NTFS_A_STD0x10
109#define NTFS_A_ATTRLIST0x20
110#define NTFS_A_NAME0x30
111#define NTFS_A_VOLUMENAME0x60
112#define NTFS_A_DATA0x80
113#defineNTFS_A_INDXROOT0x90
114#defineNTFS_A_INDX0xA0
115#define NTFS_A_INDXBITMAP 0xB0
116
117#define NTFS_MAXATTRNAME255
118struct attr {
119struct attrhdr a_hdr;
120union {
121struct {
122u_int16_t a_datalen;
123u_int16_t reserved1;
124u_int16_t a_dataoff;
125u_int16_t a_indexed;
126} a_S_r;
127struct {
128cn_t a_vcnstart;
129cn_t a_vcnend;
130u_int16_t a_dataoff;
131u_int16_t a_compressalg;
132u_int32_t reserved1;
133u_int64_t a_allocated;
134u_int64_t a_datalen;
135u_int64_t a_initialized;
136} a_S_nr;
137} a_S;
138};
139#define a_ra_S.a_S_r
140#define a_nra_S.a_S_nr
141
142typedef struct {
143u_int64_t t_create;
144u_int64_t t_write;
145u_int64_t t_mftwrite;
146u_int64_t t_access;
147} ntfs_times_t;
148
149#define NTFS_FFLAG_RDONLY0x01LL
150#define NTFS_FFLAG_HIDDEN0x02LL
151#define NTFS_FFLAG_SYSTEM0x04LL
152#define NTFS_FFLAG_ARCHIVE0x20LL
153#define NTFS_FFLAG_COMPRESSED0x0800LL
154#define NTFS_FFLAG_DIR0x10000000LL
155
156struct attr_name {
157u_int32_tn_pnumber;/* Parent ntnode */
158u_int32_t reserved;
159ntfs_times_t n_times;
160u_int64_t n_size;
161u_int64_t n_attrsz;
162u_int64_t n_flag;
163u_int8_t n_namelen;
164u_int8_t n_nametype;
165u_int16_t n_name[1];
166};
167
168#define NTFS_IRFLAG_INDXALLOC0x00000001
169struct attr_indexroot {
170u_int32_t ir_unkn1;/* attribute type (0x30 for $FILE_NAME) */
171u_int32_t ir_unkn2;/* collation rule (0x01 for file names) */
172u_int32_t ir_size;/* size of index allocation entry */
173u_int32_t ir_unkn3;/* clusters per index record, and 3 bytes padding */
174u_int32_t ir_unkn4;/* (offset to first index entry?) always 0x10 */
175u_int32_t ir_datalen;/* (total size of index enties?) sizeof something */
176u_int32_t ir_allocated;/* (allocated size of index entries?) */
177u_int8_t ir_flag;/* 1=index allocation needed (large index) */
178 u_int8_tir_pad1;/* padding */
179u_int16_t ir_pad2;/* padding */
180};
181
182struct attr_attrlist {
183u_int32_t al_type;/* Attribute type */
184u_int16_t reclen;/* length of this entry */
185u_int8_t al_namelen;/* Attribute name len */
186u_int8_t al_nameoff;/* Name offset from entry start */
187u_int64_t al_vcnstart;/* VCN number */
188u_int32_t al_inumber;/* Parent ntnode */
189u_int32_t reserved;
190u_int16_t al_index;/* Attribute index in MFT record */
191u_int16_t al_name[1];/* Name */
192};
193
194#defineNTFS_INDXMAGIC(u_int32_t)(0x58444E49)
195struct attr_indexalloc {
196struct fixuphdr ia_fixup;
197u_int64_t unknown1;
198cn_t ia_bufcn;
199u_int16_t ia_hdrsize;
200u_int16_t unknown2;
201u_int32_t ia_inuse;
202u_int32_t ia_allocated;
203};
204
205#defineNTFS_IEFLAG_SUBNODE0x00000001
206#defineNTFS_IEFLAG_LAST0x00000002
207
208struct attr_indexentry {
209u_int32_t ie_number;
210u_int32_t unknown1;
211u_int16_t reclen;
212u_int16_t ie_size;
213u_int32_t ie_flag;/* 1 - has subnodes, 2 - last */
214u_int32_t ie_fpnumber;
215u_int32_t unknown2;
216ntfs_times_t ie_ftimes;
217u_int64_t ie_fallocated;
218u_int64_t ie_fsize;
219u_int32_t ie_fflag;
220 u_int32_tunknown3;/* used by reparse points and external attributes? */
221u_int8_t ie_fnamelen;
222u_int8_t ie_fnametype;
223wchar ie_fname[NTFS_MAXFILENAME];
224/* cn_tie_bufcn; buffer with subnodes */
225};
226
227#defineNTFS_FILEMAGIC(u_int32_t)(0x454C4946)
228#defineNTFS_FRFLAG_DIR0x0002
229struct filerec {
230struct fixuphdr fr_fixup;
231u_int8_t reserved[8];
232u_int16_t fr_seqnum;/* Sequence number */
233u_int16_t fr_nlink;
234u_int16_t fr_attroff;/* offset to attributes */
235u_int16_t fr_flags;/* 1-nonresident attr, 2-directory */
236u_int32_t fr_size;/* hdr + attributes */
237u_int32_t fr_allocated;/* allocated length of record */
238u_int64_t fr_mainrec;/* main record */
239u_int16_t fr_attrnum;/* maximum attr number + 1 ??? */
240};
241
242#defineNTFS_ATTRNAME_MAXLEN0x40
243#defineNTFS_ADFLAG_NONRES0x0080/* Attrib can be non resident */
244#defineNTFS_ADFLAG_INDEX0x0002/* Attrib can be indexed */
245struct attrdef {
246wcharad_name[NTFS_ATTRNAME_MAXLEN];
247u_int32_tad_type;
248u_int32_treserved1[2];
249u_int32_tad_flag;
250u_int64_tad_minlen;
251u_int64_tad_maxlen;/* -1 for nonlimited */
252};
253
254struct ntvattrdef {
255charad_name[0x40];
256intad_namelen;
257u_int32_tad_type;
258};
259
260#defineNTFS_BBID"NTFS "
261#defineNTFS_BBIDLEN8
262struct bootfile {
263u_int8_t reserved1[3];/* asm jmp near ... */
264u_int8_t bf_sysid[8];/* 'NTFS ' */
265u_int16_t bf_bps;/* bytes per sector */
266u_int8_t bf_spc;/* sectors per cluster */
267u_int8_t reserved2[7];/* unused (zeroed) */
268u_int8_t bf_media;/* media desc. (0xF8) */
269u_int8_t reserved3[2];
270u_int16_t bf_spt;/* sectors per track */
271u_int16_t bf_heads;/* number of heads */
272u_int8_t reserver4[12];
273u_int64_t bf_spv;/* sectors per volume */
274cn_t bf_mftcn;/* $MFT cluster number */
275cn_t bf_mftmirrcn;/* $MFTMirr cn */
276u_int8_t bf_mftrecsz;/* MFT record size (clust) */
277/* 0xF6 inducates 1/4 */
278 u_int8_t reserved5[3];
279u_int8_t bf_ibsz;/* index buffer size */
280 u_int8_t reserved6[3];
281u_int64_t bf_volsn;/* volume ser. num. */
282};
283
284/*
285 * Darwin's ntfs.util needs to include this file to get definitions
286 * for the on-disk structures. It doesn't need the ntfsmount structure.
287 * In fact, since it doesn't #define KERNEL, the struct netexport below
288 * won't be defined.
289 *
290 * So, I'm using #ifdef KERNEL around the things that are only relevant
291 * to the in-kernel implementation.
292 *
293
294 * invent a different conditional here.
295 */
296#ifdef KERNEL
297
298#defineNTFS_SYSNODESNUM0x0B
299struct ntfsmount {
300struct mount *ntm_mountp;/* filesystem vfs structure */
301struct bootfile ntm_bootfile;
302dev_t ntm_dev;/* device mounted */
303struct vnode *ntm_devvp;/* block device mounted vnode */
304struct vnode *ntm_sysvn[NTFS_SYSNODESNUM];
305u_int32_t ntm_bpmftrec;
306uid_t ntm_uid;
307gid_t ntm_gid;
308mode_t ntm_mode;
309u_long ntm_flag;
310cn_tntm_cfree;
311struct ntvattrdef *ntm_ad;/* attribute names are stored in native byte order */
312intntm_adnum;
313 wchar *ntm_82u;/* 8bit to Unicode */
314 char **ntm_u28;/* Unicode to 8 bit */
315#ifdef APPLE
316struct netexport ntm_export;/* NFS export information */
317#endif
318};
319
320#define ntm_mftcnntm_bootfile.bf_mftcn
321#define ntm_mftmirrcnntm_bootfile.bf_mftmirrcn
322#definentm_mftrecszntm_bootfile.bf_mftrecsz
323#definentm_spcntm_bootfile.bf_spc
324#definentm_bpsntm_bootfile.bf_bps
325
326#pragma pack()
327
328#defineNTFS_NEXTREC(s, type) ((type)(((caddr_t) s) + le16toh((s)->reclen)))
329
330/* Convert mount ptr to ntfsmount ptr. */
331#define VFSTONTFS(mp)((struct ntfsmount *)((mp)->mnt_data))
332#define VTONT(v)FTONT(VTOF(v))
333#defineVTOF(v)((struct fnode *)((v)->v_data))
334#defineFTOV(f)((f)->f_vp)
335#defineFTONT(f)((f)->f_ip)
336#define ntfs_cntobn(cn)((daddr_t)(cn) * (ntmp->ntm_spc))
337#define ntfs_cntob(cn)((off_t)(cn) * (ntmp)->ntm_spc * (ntmp)->ntm_bps)
338#define ntfs_btocn(off)(cn_t)((off) / ((ntmp)->ntm_spc * (ntmp)->ntm_bps))
339#define ntfs_btocl(off)(cn_t)((off + ntfs_cntob(1) - 1) / ((ntmp)->ntm_spc * (ntmp)->ntm_bps))
340#define ntfs_btocnoff(off)(off_t)((off) % ((ntmp)->ntm_spc * (ntmp)->ntm_bps))
341#define ntfs_bntob(bn)(daddr_t)((bn) * (ntmp)->ntm_bps)
342
343#definentfs_bpbl(daddr_t)((ntmp)->ntm_bps)
344
345#ifdef MALLOC_DECLARE
346MALLOC_DECLARE(M_NTFSMNT);
347MALLOC_DECLARE(M_NTFSNTNODE);
348MALLOC_DECLARE(M_NTFSFNODE);
349MALLOC_DECLARE(M_NTFSDIR);
350MALLOC_DECLARE(M_NTFSNTHASH);
351#endif
352
353#ifndef M_NTFSMNT
354#define M_NTFSMNT M_TEMP
355#endif
356#ifndef M_NTFSNTNODE
357#define M_NTFSNTNODE M_TEMP
358#endif
359#ifndef M_NTFSFNODE
360#define M_NTFSFNODE M_TEMP
361#endif
362#ifndef M_NTFSDIR
363#define M_NTFSDIR M_TEMP
364#endif
365#ifndef M_NTFSNTHASH
366#define M_NTFSNTHASH M_TEMP
367#endif
368#ifndef M_NTFSRUN
369#define M_NTFSRUN M_TEMP
370#endif
371#ifndef M_NTFSRDATA
372#define M_NTFSRDATA M_TEMP
373#endif
374#ifndef M_NTFSNTVATTR
375#define M_NTFSNTVATTR M_TEMP
376#endif
377#ifndef M_NTFSDECOMP
378#define M_NTFSDECOMP M_TEMP
379#endif
380#define VT_NTFS VT_OTHER
381
382#if defined(NTFS_DEBUG)
383#define dprintf(a) printf a
384#if NTFS_DEBUG > 1
385#define ddprintf(a) printf a
386#else
387#define ddprintf(a)
388#endif
389#else
390#define dprintf(a)
391#define ddprintf(a)
392#endif
393
394#ifdef APPLE
395typedef int vop_t(void *);
396#else
397#endif
398extern vop_t **ntfs_vnodeop_p;
399#endif /* KERNEL */
400

Archive Download this file

Revision: 214