]> git.saurik.com Git - apple/xnu.git/blame - bsd/hfs/hfs_catalog.h
xnu-344.23.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_catalog.h
CommitLineData
9bccf70c
A
1/*
2 * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
de355530
A
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
9bccf70c 11 *
de355530
A
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
9bccf70c
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
de355530
A
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
9bccf70c
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22#ifndef __HFS_CATALOG__
23#define __HFS_CATALOG__
24
25#include <sys/appleapiopts.h>
26
27#ifdef KERNEL
28#ifdef __APPLE_API_PRIVATE
29#include <sys/namei.h>
30#include <sys/vnode.h>
31#include <sys/lock.h>
32
33#include <hfs/hfs_format.h>
34
35/* HFS Catalog */
36
37
38/*
39 * Catalog ADTs
40 *
41 * The cat_desc, cat_attr, and cat_fork structures are
42 * use to import/export data to/from the Catalog file.
43 * The fields in these structures are always in BSD
44 * runtime format (e.g. dates and names).
45 */
46
47typedef u_int32_t cnid_t;
48
49/*
50 * Catalog Node Descriptor (runtime)
51 */
52struct cat_desc {
53 u_int8_t cd_flags; /* see below (8 bits) */
54 u_int8_t cd_encoding; /* name encoding */
55 int16_t cd_namelen; /* length of cnode name */
56 char * cd_nameptr; /* pointer to cnode name */
57 cnid_t cd_parentcnid; /* parent directory CNID */
58 u_long cd_hint; /* catalog file hint */
59 cnid_t cd_cnid; /* cnode id (for getattrlist) */
60};
61
62/* cd_flags */
63#define CD_HASBUF 0x01 /* allocated filename buffer */
64#define CD_DECOMPOSED 0x02 /* name is fully decomposed */
65#define CD_ISDIR 0x80 /* describes a directory */
66
67/*
68 * Catalog Node Attributes (runtime)
69 */
70struct cat_attr {
71 cnid_t ca_fileid; /* inode number (for stat) normally == cnid */
72 mode_t ca_mode; /* file access mode and type (16 bits) */
73 nlink_t ca_nlink; /* file link count (16 bit integer) */
74 uid_t ca_uid; /* file owner */
75 gid_t ca_gid; /* file group */
76 dev_t ca_rdev; /* device a special file represents */
77 time_t ca_atime; /* last access time */
78 time_t ca_mtime; /* last data modification time */
79 int32_t ca_mtime_nsec; /* last data modification time nanosec */
80 time_t ca_ctime; /* last file status change */
81 time_t ca_itime; /* file initialization time */
82 time_t ca_btime; /* last backup time */
83 u_long ca_flags; /* status flags (chflags) */
84 union {
85 u_int32_t cau_blocks; /* total file blocks used (rsrc + data) */
86 u_int32_t cau_entries; /* total directory entries (valence) */
87 } ca_union;
88 u_int8_t ca_finderinfo[32]; /* Opaque Finder information */
89};
90/* Aliases for common fields */
91#define ca_blocks ca_union.cau_blocks
92#define ca_entries ca_union.cau_entries
93
94/*
95 * Catalog Node Fork (runtime + on disk)
96 */
97struct cat_fork {
98 u_int64_t cf_size; /* fork's logical size in bytes */
99 u_int32_t cf_clump; /* fork's clump size in bytes */
100 u_int32_t cf_blocks; /* total blocks used by this fork */
101 struct HFSPlusExtentDescriptor cf_extents[8]; /* initial set of extents */
102};
103
104
105/*
106 * Catalog Node Entry
107 *
108 * A cat_entry is used for bulk enumerations (hfs_readdirattr).
109 */
110struct cat_entry {
111 struct cat_desc ce_desc;
112 struct cat_attr ce_attr;
113 off_t ce_datasize;
114 off_t ce_rsrcsize;
115 u_long ce_datablks;
116 u_long ce_rsrcblks;
117};
118
119#define MAXCATENTRIES 8
120/*
121 * Catalog Node Entry List
122 *
123 * A cat_entrylist is a list of Catalog Node Entries.
124 */
125struct cat_entrylist {
126 u_long maxentries; /* length of list */
127 u_long realentries; /* valid entry count */
128 struct cat_entry entry[MAXCATENTRIES]; /* array of entries */
129};
130
131/*
132 * Catalog Interface
133 *
134 * These functions perform a catalog transactions. The
135 * catalog b-tree is abstracted through this interface.
136 * (please don't go around it)
137 */
138
139struct hfsmount;
140
141extern void cat_releasedesc(struct cat_desc *descp);
142
143extern int cat_create ( struct hfsmount *hfsmp,
144 struct cat_desc *descp,
145 struct cat_attr *attrp,
146 struct cat_desc *out_descp);
147
148extern int cat_delete ( struct hfsmount *hfsmp,
149 struct cat_desc *descp,
150 struct cat_attr *attrp);
151
152extern int cat_lookup ( struct hfsmount *hfsmp,
153 struct cat_desc *descp,
154 int wantrsrc,
155 struct cat_desc *outdescp,
156 struct cat_attr *attrp,
157 struct cat_fork *forkp);
158
159extern int cat_idlookup (struct hfsmount *hfsmp,
160 cnid_t cnid,
161 struct cat_desc *outdescp,
162 struct cat_attr *attrp,
163 struct cat_fork *forkp);
164
165extern int cat_getentriesattr(
166 struct hfsmount *hfsmp,
167 struct cat_desc *prevdesc,
168 int index,
169 struct cat_entrylist *ce_list);
170
171extern int cat_rename ( struct hfsmount * hfsmp,
172 struct cat_desc * from_cdp,
173 struct cat_desc * todir_cdp,
174 struct cat_desc * to_cdp,
175 struct cat_desc * cdp);
176
177extern int cat_update ( struct hfsmount *hfsmp,
178 struct cat_desc *descp,
179 struct cat_attr *attrp,
180 struct cat_fork *dataforkp,
181 struct cat_fork *rsrcforkp);
182
183extern int cat_getdirentries(
184 struct hfsmount *hfsmp,
185 struct cat_desc *descp,
186 struct uio *uio,
187 int *eofflag);
188
189extern int cat_insertfilethread (
190 struct hfsmount *hfsmp,
191 struct cat_desc *descp);
192
193#endif /* __APPLE_API_PRIVATE */
194#endif /* KERNEL */
195#endif /* __HFS_CATALOG__ */