3 Copyright (c) 1989-2000 Microsoft Corporation
11 This module implements the Cdfs File object support routines.
19 // The Bug check file id for this module
22 #define BugCheckFileId (CDFS_BUG_CHECK_FILOBSUP)
28 #define TYPE_OF_OPEN_MASK (0x00000007)
31 #pragma alloc_text(PAGE, CdDecodeFileObject)
32 #pragma alloc_text(PAGE, CdFastDecodeFileObject)
33 #pragma alloc_text(PAGE, CdSetFileObject)
39 IN PIRP_CONTEXT IrpContext
,
40 IN PFILE_OBJECT FileObject
,
41 IN TYPE_OF_OPEN TypeOfOpen
,
50 This routine will initialize the FileObject context fields based on the
51 input type and data structures.
55 FileObject - Supplies the file object pointer being initialized.
57 TypeOfOpen - Sets the type of open.
59 Fcb - Fcb for this file object. Ignored for UnopenedFileObject.
61 Ccb - Ccb for the handle corresponding to this file object. Will not
62 be present for stream file objects.
74 // We only have values 0 to 7 available so make sure we didn't
75 // inadvertantly add a new type.
78 ASSERTMSG( "FileObject types exceed available bits\n", BeyondValidType
<= 8 );
81 // Setting a file object to type UnopenedFileObject means just
82 // clearing all of the context fields. All the other input
85 if (TypeOfOpen
== UnopenedFileObject
) {
87 FileObject
->FsContext
=
88 FileObject
->FsContext2
= NULL
;
94 // Check that the 3 low-order bits of the Ccb are clear.
97 ASSERTMSG( "Ccb is not quad-aligned\n", !FlagOn( ((ULONG_PTR
) Ccb
), TYPE_OF_OPEN_MASK
));
100 // We will or the type of open into the low order bits of FsContext2
101 // along with the Ccb value.
102 // The Fcb is stored into the FsContext field.
105 FileObject
->FsContext
= Fcb
;
106 FileObject
->FsContext2
= Ccb
;
108 SetFlag( (*(PULONG_PTR
)&FileObject
->FsContext2
), TypeOfOpen
); /* ReactOS Change: GCC "invalid lvalue in assignment" */
111 // Set the Vpb field in the file object.
114 FileObject
->Vpb
= Fcb
->Vcb
->Vpb
;
123 IN PIRP_CONTEXT IrpContext
,
124 IN PFILE_OBJECT FileObject
,
133 This routine takes a file object and extracts the Fcb and Ccb (possibly NULL)
134 and returns the type of open.
138 FileObject - Supplies the file object pointer being initialized.
140 Fcb - Address to store the Fcb contained in the file object.
142 Ccb - Address to store the Ccb contained in the file object.
146 TYPE_OF_OPEN - Indicates the type of file object.
151 TYPE_OF_OPEN TypeOfOpen
;
156 // If this is an unopened file object then return NULL for the
157 // Fcb/Ccb. Don't trust any other values in the file object.
160 TypeOfOpen
= (TYPE_OF_OPEN
) FlagOn( (ULONG_PTR
) FileObject
->FsContext2
,
163 if (TypeOfOpen
== UnopenedFileObject
) {
171 // The Fcb is pointed to by the FsContext field. The Ccb is in
172 // FsContext2 (after clearing the low three bits). The low three
173 // bits are the file object type.
176 *Fcb
= FileObject
->FsContext
;
177 *Ccb
= FileObject
->FsContext2
;
179 ClearFlag( (*(PULONG_PTR
)Ccb
), TYPE_OF_OPEN_MASK
); /* ReactOS Change: GCC "invalid lvalue in assignment" */
183 // Now return the type of open.
191 CdFastDecodeFileObject (
192 IN PFILE_OBJECT FileObject
,
200 This procedure takes a pointer to a file object, that has already been
201 opened by Cdfs and does a quick decode operation. It will only return
202 a non null value if the file object is a user file open
206 FileObject - Supplies the file object pointer being interrogated
208 Fcb - Address to store Fcb if this is a user file object. NULL
213 TYPE_OF_OPEN - type of open of this file object.
220 ASSERT_FILE_OBJECT( FileObject
);
223 // The Fcb is in the FsContext field. The type of open is in the low
227 *Fcb
= FileObject
->FsContext
;
229 return (TYPE_OF_OPEN
)
230 FlagOn( (ULONG_PTR
) FileObject
->FsContext2
, TYPE_OF_OPEN_MASK
);