Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

filobsup.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 FilObSup.c 00008 00009 Abstract: 00010 00011 This module implements the Udfs File object support routines. 00012 00013 Author: 00014 00015 Dan Lovinger [DanLo] 23-Sep-1996 00016 00017 Revision History: 00018 00019 --*/ 00020 00021 #include "UdfProcs.h" 00022 00023 // 00024 // The Bug check file id for this module 00025 // 00026 00027 #define BugCheckFileId (UDFS_BUG_CHECK_FILOBSUP) 00028 00029 // 00030 // The local debug trace level 00031 // 00032 00033 #define Dbg (UDFS_DEBUG_LEVEL_FILOBSUP) 00034 00035 // 00036 // Local constants. 00037 // 00038 00039 #define TYPE_OF_OPEN_MASK (0x00000007) 00040 00041 #ifdef ALLOC_PRAGMA 00042 #pragma alloc_text(PAGE, UdfDecodeFileObject) 00043 #pragma alloc_text(PAGE, UdfFastDecodeFileObject) 00044 #pragma alloc_text(PAGE, UdfSetFileObject) 00045 #endif 00046 00047 00048 VOID 00049 UdfSetFileObject ( 00050 IN PIRP_CONTEXT IrpContext, 00051 IN PFILE_OBJECT FileObject, 00052 IN TYPE_OF_OPEN TypeOfOpen, 00053 IN PFCB Fcb OPTIONAL, 00054 IN PCCB Ccb OPTIONAL 00055 ) 00056 00057 /*++ 00058 00059 Routine Description: 00060 00061 This routine will initialize the FileObject context fields based on the 00062 input type and data structures. 00063 00064 Arguments: 00065 00066 FileObject - Supplies the file object pointer being initialized. 00067 00068 TypeOfOpen - Sets the type of open. 00069 00070 Fcb - Fcb for this file object. Ignored for UnopenedFileObject. 00071 00072 Ccb - Ccb for the handle corresponding to this file object. Will not 00073 be present for stream file objects. 00074 00075 Return Value: 00076 00077 None. 00078 00079 --*/ 00080 00081 { 00082 PAGED_CODE(); 00083 00084 // 00085 // We only have values 0 to 7 available so make sure we didn't 00086 // inadvertantly add a new type. 00087 // 00088 00089 ASSERTMSG( "FileObject types exceed available bits\n", BeyondValidType <= 8 ); 00090 00091 // 00092 // Setting a file object to type UnopenedFileObject means just 00093 // clearing all of the context fields. All the other input 00094 // 00095 00096 if (TypeOfOpen == UnopenedFileObject) { 00097 00098 FileObject->FsContext = 00099 FileObject->FsContext2 = NULL; 00100 00101 return; 00102 } 00103 00104 // 00105 // Check that the 3 low-order bits of the Ccb are clear. 00106 // 00107 00108 ASSERTMSG( "Ccb is not quad-aligned\n", !FlagOn( ((ULONG_PTR) Ccb), TYPE_OF_OPEN_MASK )); 00109 00110 // 00111 // We will or the type of open into the low order bits of FsContext2 00112 // along with the Ccb value. 00113 // The Fcb is stored into the FsContext field. 00114 // 00115 00116 FileObject->FsContext = Fcb; 00117 FileObject->FsContext2 = Ccb; 00118 00119 SetFlag( ((ULONG_PTR) FileObject->FsContext2), TypeOfOpen ); 00120 00121 // 00122 // Set the Vpb field in the file object. 00123 // 00124 00125 FileObject->Vpb = Fcb->Vcb->Vpb; 00126 00127 return; 00128 } 00129 00130 00131 00132 TYPE_OF_OPEN 00133 UdfDecodeFileObject ( 00134 IN PFILE_OBJECT FileObject, 00135 OUT PFCB *Fcb, 00136 OUT PCCB *Ccb 00137 ) 00138 00139 /*++ 00140 00141 Routine Description: 00142 00143 This routine takes a file object and extracts the Fcb and Ccb (possibly NULL) 00144 and returns the type of open. 00145 00146 Arguments: 00147 00148 FileObject - Supplies the file object pointer being initialized. 00149 00150 Fcb - Address to store the Fcb contained in the file object. 00151 00152 Ccb - Address to store the Ccb contained in the file object. 00153 00154 Return Value: 00155 00156 TYPE_OF_OPEN - Indicates the type of file object. 00157 00158 --*/ 00159 00160 { 00161 TYPE_OF_OPEN TypeOfOpen; 00162 00163 PAGED_CODE(); 00164 00165 // 00166 // If this is an unopened file object then return NULL for the 00167 // Fcb/Ccb. Don't trust any other values in the file object. 00168 // 00169 00170 TypeOfOpen = (TYPE_OF_OPEN) FlagOn( (ULONG_PTR) FileObject->FsContext2, 00171 TYPE_OF_OPEN_MASK ); 00172 00173 if (TypeOfOpen == UnopenedFileObject) { 00174 00175 *Fcb = NULL; 00176 *Ccb = NULL; 00177 00178 } else { 00179 00180 // 00181 // The Fcb is pointed to by the FsContext field. The Ccb is in 00182 // FsContext2 (after clearing the low three bits). The low three 00183 // bits are the file object type. 00184 // 00185 00186 *Fcb = FileObject->FsContext; 00187 *Ccb = FileObject->FsContext2; 00188 00189 ClearFlag( (ULONG_PTR) *Ccb, TYPE_OF_OPEN_MASK ); 00190 } 00191 00192 // 00193 // Now return the type of open. 00194 // 00195 00196 return TypeOfOpen; 00197 } 00198 00199 00200 TYPE_OF_OPEN 00201 UdfFastDecodeFileObject ( 00202 IN PFILE_OBJECT FileObject, 00203 OUT PFCB *Fcb 00204 ) 00205 00206 /*++ 00207 00208 Routine Description: 00209 00210 This procedure takes a pointer to a file object, that has already been 00211 opened by Udfs and does a quick decode operation. It will only return 00212 a non null value if the file object is a user file open 00213 00214 Arguments: 00215 00216 FileObject - Supplies the file object pointer being interrogated 00217 00218 Fcb - Address to store Fcb if this is a user file object. NULL 00219 otherwise. 00220 00221 Return Value: 00222 00223 TYPE_OF_OPEN - type of open of this file object. 00224 00225 --*/ 00226 00227 { 00228 PAGED_CODE(); 00229 00230 ASSERT_FILE_OBJECT( FileObject ); 00231 00232 // 00233 // The Fcb is in the FsContext field. The type of open is in the low 00234 // bits of the Ccb. 00235 // 00236 00237 *Fcb = FileObject->FsContext; 00238 00239 return (TYPE_OF_OPEN) FlagOn( (ULONG_PTR) FileObject->FsContext2, TYPE_OF_OPEN_MASK ); 00240 } 00241

Generated on Sat May 15 19:40:00 2004 for test by doxygen 1.3.7