2 * Copyright (c) 1996-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
28 #ifndef _BTREESCANNER_H_
29 #define _BTREESCANNER_H_
31 #include <sys/appleapiopts.h>
34 #ifdef __APPLE_API_PRIVATE
37 #include "FileMgrInternal.h"
38 #include "BTreesPrivate.h"
40 // amount of time we are allowed to process a catalog search (in ยต secs)
41 // NOTE - code assumes kMaxMicroSecsInKernel is less than 1,000,000
42 // jertodo - what should we set this to?
43 enum { kMaxMicroSecsInKernel
= (1000 * 100) }; // 1 tenth of a second
45 // btree node scanner buffer size. at 32K we get 8 nodes. this is the size used
47 enum { kCatSearchBufferSize
= (32 * 1024) };
51 * ============ W A R N I N G ! ============
52 * DO NOT INCREASE THE SIZE OF THIS STRUCT!
53 * It must be less than or equal to the size of
54 * the opaque searchstate struct (in sys/attr.h).
56 /* Private description used in hfs_search */
59 u_int32_t writeCount
; /* The BTree's write count (to see if the catalog writeCount */
60 /* changed since the last search). If 0, the rest */
61 /* of the record is invalid, start from beginning. */
62 u_int32_t nextNode
; /* node number to resume search */
63 u_int32_t nextRecord
; /* record number to resume search */
64 u_int32_t recordsFound
; /* number of leaf records seen so far */
66 typedef struct CatPosition CatPosition
;
70 BTScanState - This structure is used to keep track of the current state
71 of a BTree scan. It contains both the dynamic state information (like
72 the current node number and record number) and information that is static
73 for the duration of a scan (such as buffer pointers).
75 NOTE: recordNum may equal or exceed the number of records in the node
76 number nodeNum. If so, then the next attempt to get a record will move
81 // The following fields are set up once at initialization time.
82 // They are not changed during a scan.
84 struct buf
* bufferPtr
;
85 BTreeControlBlock
* btcb
;
87 // The following fields are the dynamic state of the current scan.
88 u_int32_t nodeNum
; // zero is first node
89 u_int32_t recordNum
; // zero is first record
90 BTNodeDescriptor
* currentNodePtr
; // points to current node within buffer
91 u_int32_t nodesLeftInBuffer
; // number of valid nodes still in the buffer
92 u_int32_t recordsFound
; // number of leaf records seen so far
93 struct timeval startTime
; // time we started catalog search
95 typedef struct BTScanState BTScanState
;
98 /* *********************** PROTOTYPES *********************** */
100 int BTScanInitialize( const FCB
* btreeFile
,
101 u_int32_t startingNode
,
102 u_int32_t startingRecord
,
103 u_int32_t recordsFound
,
104 u_int32_t bufferSize
,
105 BTScanState
* scanState
);
107 int BTScanNextRecord( BTScanState
* scanState
,
111 u_int32_t
* dataSize
);
113 int BTScanTerminate( BTScanState
* scanState
,
114 u_int32_t
* startingNode
,
115 u_int32_t
* startingRecord
,
116 u_int32_t
* recordsFound
);
118 #endif /* __APPLE_API_PRIVATE */
120 #endif /* !_BTREESCANNER_H_ */