ReactOS  0.4.14-dev-77-gd9e7c48
filobsup.c
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 1989-2000 Microsoft Corporation
4 
5 Module Name:
6 
7  FilObSup.c
8 
9 Abstract:
10 
11  This module implements the Cdfs File object support routines.
12 
13 
14 --*/
15 
16 #include "cdprocs.h"
17 
18 //
19 // The Bug check file id for this module
20 //
21 
22 #define BugCheckFileId (CDFS_BUG_CHECK_FILOBSUP)
23 
24 //
25 // Local constants.
26 //
27 
28 #define TYPE_OF_OPEN_MASK (0x00000007)
29 
30 #ifdef ALLOC_PRAGMA
31 #pragma alloc_text(PAGE, CdDecodeFileObject)
32 #pragma alloc_text(PAGE, CdFastDecodeFileObject)
33 #pragma alloc_text(PAGE, CdSetFileObject)
34 #endif
35 
36 
39 VOID
40 CdSetFileObject (
41  _In_ PIRP_CONTEXT IrpContext,
44  PFCB Fcb,
46  )
47 
48 /*++
49 
50 Routine Description:
51 
52  This routine will initialize the FileObject context fields based on the
53  input type and data structures.
54 
55 Arguments:
56 
57  FileObject - Supplies the file object pointer being initialized.
58 
59  TypeOfOpen - Sets the type of open.
60 
61  Fcb - Fcb for this file object. Ignored for UnopenedFileObject.
62 
63  Ccb - Ccb for the handle corresponding to this file object. Will not
64  be present for stream file objects.
65 
66 Return Value:
67 
68  None.
69 
70 --*/
71 
72 {
73  PAGED_CODE();
74 
75  UNREFERENCED_PARAMETER( IrpContext );
76 
77  //
78  // We only have values 0 to 7 available so make sure we didn't
79  // inadvertantly add a new type.
80  //
81 
82  NT_ASSERTMSG( "FileObject types exceed available bits\n", BeyondValidType <= 8 );
83 
84  //
85  // Setting a file object to type UnopenedFileObject means just
86  // clearing all of the context fields. All the other input
87  //
88 
90 
91  FileObject->FsContext =
92  FileObject->FsContext2 = NULL;
93 
94  return;
95  }
96 
97  //
98  // Check that the 3 low-order bits of the Ccb are clear.
99  //
100 
101  NT_ASSERTMSG( "Ccb is not quad-aligned\n", !FlagOn( ((ULONG_PTR) Ccb), TYPE_OF_OPEN_MASK ));
102 
103  //
104  // We will or the type of open into the low order bits of FsContext2
105  // along with the Ccb value.
106  // The Fcb is stored into the FsContext field.
107  //
108 
109  FileObject->FsContext = Fcb;
110  FileObject->FsContext2 = Ccb;
111 
112 #ifdef _MSC_VER
113 #pragma warning( suppress: 4213 )
114 #endif
115  SetFlag( (*(PULONG_PTR)&FileObject->FsContext2), TypeOfOpen ); /* ReactOS Change: GCC "invalid lvalue in assignment" */
116 
117  //
118  // Set the Vpb field in the file object.
119  //
120 
121  FileObject->Vpb = Fcb->Vcb->Vpb;
122 
123  return;
124 }
125 
126 
132 CdDecodeFileObject (
133  _In_ PIRP_CONTEXT IrpContext,
135  PFCB *Fcb,
136  PCCB *Ccb
137  )
138 
139 /*++
140 
141 Routine Description:
142 
143  This routine takes a file object and extracts the Fcb and Ccb (possibly NULL)
144  and returns the type of open.
145 
146 Arguments:
147 
148  FileObject - Supplies the file object pointer being initialized.
149 
150  Fcb - Address to store the Fcb contained in the file object.
151 
152  Ccb - Address to store the Ccb contained in the file object.
153 
154 Return Value:
155 
156  TYPE_OF_OPEN - Indicates the type of file object.
157 
158 --*/
159 
160 {
162 
163  PAGED_CODE();
164 
165  UNREFERENCED_PARAMETER( IrpContext );
166 
167  //
168  // If this is an unopened file object then return NULL for the
169  // Fcb/Ccb. Don't trust any other values in the file object.
170  //
171 
174 
176 
177  *Fcb = NULL;
178  *Ccb = NULL;
179 
180  } else {
181 
182  //
183  // The Fcb is pointed to by the FsContext field. The Ccb is in
184  // FsContext2 (after clearing the low three bits). The low three
185  // bits are the file object type.
186  //
187 
188  *Fcb = FileObject->FsContext;
189  *Ccb = FileObject->FsContext2;
190 
191 #ifdef _MSC_VER
192 #pragma warning( suppress: 4213 )
193 #endif
194  ClearFlag( (*(PULONG_PTR)Ccb), TYPE_OF_OPEN_MASK ); /* ReactOS Change: GCC "invalid lvalue in assignment" */
195  }
196 
197  //
198  // Now return the type of open.
199  //
200 
201  return TypeOfOpen;
202 }
203 
204 
208  _Out_ PFCB *Fcb
209  )
210 
211 /*++
212 
213 Routine Description:
214 
215  This procedure takes a pointer to a file object, that has already been
216  opened by Cdfs and does a quick decode operation. It will only return
217  a non null value if the file object is a user file open
218 
219 Arguments:
220 
221  FileObject - Supplies the file object pointer being interrogated
222 
223  Fcb - Address to store Fcb if this is a user file object. NULL
224  otherwise.
225 
226 Return Value:
227 
228  TYPE_OF_OPEN - type of open of this file object.
229 
230 --*/
231 
232 {
233  PAGED_CODE();
234 
236 
237  //
238  // The Fcb is in the FsContext field. The type of open is in the low
239  // bits of the Ccb.
240  //
241 
242  *Fcb = FileObject->FsContext;
243 
244  return (TYPE_OF_OPEN)
245  FlagOn( (ULONG_PTR) FileObject->FsContext2, TYPE_OF_OPEN_MASK );
246 }
247 
248 
249 
#define NT_ASSERTMSG
Definition: rtlfuncs.h:3313
return
Definition: dirsup.c:529
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
Definition: cdstruc.h:908
Definition: cdstruc.h:1073
#define _Outptr_
Definition: no_sal2.h:396
PVPB Vpb
Definition: cdstruc.h:517
#define ASSERT_FILE_OBJECT(FO)
Definition: cddata.h:253
_When_(TypeOfOpen==UnopenedFileObject, _At_(Fcb, _In_opt_))
Definition: filobsup.c:37
#define PAGED_CODE()
Definition: video.h:57
#define _In_opt_
Definition: no_sal2.h:213
uint32_t ULONG_PTR
Definition: typedefs.h:63
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN TypeOfOpen
Definition: cdprocs.h:593
smooth NULL
Definition: ftsmooth.c:416
#define _Out_
Definition: no_sal2.h:323
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define TYPE_OF_OPEN_MASK
Definition: filobsup.c:28
#define _Inout_
Definition: no_sal2.h:244
* PFILE_OBJECT
Definition: iotypes.h:1955
#define _Post_null_
Definition: no_sal2.h:461
TYPE_OF_OPEN CdFastDecodeFileObject(_In_ PFILE_OBJECT FileObject, _Out_ PFCB *Fcb)
Definition: filobsup.c:206
enum _TYPE_OF_OPEN TYPE_OF_OPEN
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
#define _In_
Definition: no_sal2.h:204
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_At_(Fcb, _Outptr_)
Definition: filobsup.c:128
uint32_t * PULONG_PTR
Definition: typedefs.h:63
PVCB Vcb
Definition: cdstruc.h:939
_In_ PFCB Fcb
Definition: cdprocs.h:151