2 * Copyright (c) 1996-2004 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
31 #ifndef _BTREESCANNER_H_
32 #define _BTREESCANNER_H_
34 #include <sys/appleapiopts.h>
37 #ifdef __APPLE_API_PRIVATE
40 #include "FileMgrInternal.h"
41 #include "BTreesPrivate.h"
43 // amount of time we are allowed to process a catalog search (in ยต secs)
44 // NOTE - code assumes kMaxMicroSecsInKernel is less than 1,000,000
45 enum { kMaxMicroSecsInKernel
= (1000 * 100) }; // 1 tenth of a second
47 // btree node scanner buffer size. at 32K we get 8 nodes. this is the size used
49 enum { kCatSearchBufferSize
= (32 * 1024) };
53 * ============ W A R N I N G ! ============
54 * DO NOT INCREASE THE SIZE OF THIS STRUCT!
55 * It must be less than or equal to the size of
56 * the opaque searchstate struct (in sys/attr.h).
58 /* Private description used in hfs_search */
61 u_int32_t writeCount
; /* The BTree's write count (to see if the catalog writeCount */
62 /* changed since the last search). If 0, the rest */
63 /* of the record is invalid, start from beginning. */
64 u_int32_t nextNode
; /* node number to resume search */
65 u_int32_t nextRecord
; /* record number to resume search */
66 u_int32_t recordsFound
; /* number of leaf records seen so far */
68 typedef struct CatPosition CatPosition
;
72 BTScanState - This structure is used to keep track of the current state
73 of a BTree scan. It contains both the dynamic state information (like
74 the current node number and record number) and information that is static
75 for the duration of a scan (such as buffer pointers).
77 NOTE: recordNum may equal or exceed the number of records in the node
78 number nodeNum. If so, then the next attempt to get a record will move
83 // The following fields are set up once at initialization time.
84 // They are not changed during a scan.
86 struct buf
* bufferPtr
;
87 BTreeControlBlock
* btcb
;
89 // The following fields are the dynamic state of the current scan.
90 u_int32_t nodeNum
; // zero is first node
91 u_int32_t recordNum
; // zero is first record
92 BTNodeDescriptor
* currentNodePtr
; // points to current node within buffer
93 u_int32_t nodesLeftInBuffer
; // number of valid nodes still in the buffer
94 u_int32_t recordsFound
; // number of leaf records seen so far
95 struct timeval startTime
; // time we started catalog search
97 typedef struct BTScanState BTScanState
;
100 /* *********************** PROTOTYPES *********************** */
102 int BTScanInitialize( const FCB
* btreeFile
,
103 u_int32_t startingNode
,
104 u_int32_t startingRecord
,
105 u_int32_t recordsFound
,
106 u_int32_t bufferSize
,
107 BTScanState
* scanState
);
109 int BTScanNextRecord( BTScanState
* scanState
,
113 u_int32_t
* dataSize
);
115 int BTScanTerminate( BTScanState
* scanState
,
116 u_int32_t
* startingNode
,
117 u_int32_t
* startingRecord
,
118 u_int32_t
* recordsFound
);
120 #endif /* __APPLE_API_PRIVATE */
122 #endif /* !_BTREESCANNER_H_ */