ReactOS  0.4.15-dev-492-ga1108f6
fileobsup.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Named Pipe FileSystem
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: drivers/filesystems/npfs/fileobsup.c
5  * PURPOSE: Pipes File Object Support
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include "npfs.h"
12 
13 // File ID number for NPFS bugchecking support
14 #define NPFS_BUGCHECK_FILE_ID (NPFS_BUGCHECK_FILEOBSUP)
15 
16 /* FUNCTIONS ******************************************************************/
17 
19 NTAPI
21  OUT PVOID* PrimaryContext OPTIONAL,
22  OUT PNP_CCB* Ccb,
23  OUT PULONG NamedPipeEnd OPTIONAL)
24 {
26  PNP_CCB Node;
27  PAGED_CODE();
28 
29  Context = (ULONG_PTR)FileObject->FsContext;
30  if ((Context) && (Context != 1))
31  {
32  if (NamedPipeEnd) *NamedPipeEnd = Context & 1;
33 
34  Node = (PVOID)(Context & ~1);
35 
36  switch (Node->NodeType)
37  {
38  case NPFS_NTC_VCB:
39  return NPFS_NTC_VCB;
40 
41  case NPFS_NTC_ROOT_DCB:
42  *Ccb = FileObject->FsContext2;
43  if (PrimaryContext) *PrimaryContext = Node;
44  return NPFS_NTC_ROOT_DCB;
45 
46  case NPFS_NTC_CCB:
47  *Ccb = Node;
48  if (PrimaryContext) *PrimaryContext = Node->Fcb;
49  return NPFS_NTC_CCB;
50 
51  default:
52  NpBugCheck(Node->NodeType, 0, 0);
53  break;
54  }
55  }
56 
57  return 0;
58 }
59 
60 VOID
61 NTAPI
63  IN PVOID PrimaryContext,
64  IN PVOID Ccb,
65  IN ULONG NamedPipeEnd)
66 {
67  BOOLEAN FileIsPipe;
68  PAGED_CODE();
69 
70  if (!FileObject) return;
71 
72  if ((PrimaryContext) && (((PNP_CCB)PrimaryContext)->NodeType == NPFS_NTC_CCB))
73  {
74  FileIsPipe = TRUE;
75  if (NamedPipeEnd == FILE_PIPE_SERVER_END)
76  {
77  PrimaryContext = (PVOID) ((ULONG_PTR) PrimaryContext | 1);
78  }
79  }
80  else
81  {
82  FileIsPipe = FALSE;
83  }
84 
85  FileObject->FsContext = PrimaryContext;
86  FileObject->FsContext2 = Ccb;
87  FileObject->PrivateCacheMap = (PVOID)1;
88  if (FileIsPipe) FileObject->Flags |= FO_NAMED_PIPE;
89 }
90 
91 /* EOF */
#define IN
Definition: typedefs.h:39
#define TRUE
Definition: types.h:120
#define NPFS_NTC_CCB
Definition: npfs.h:115
uint32_t ULONG_PTR
Definition: typedefs.h:64
Definition: npfs.h:258
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
union node Node
Definition: types.h:1255
#define FO_NAMED_PIPE
Definition: iotypes.h:1741
unsigned char BOOLEAN
void * PVOID
Definition: retypes.h:9
NodeType
Definition: Node.h:5
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:588
#define NpBugCheck(p1, p2, p3)
Definition: npfs.h:106
if(!(yy_init))
Definition: macro.lex.yy.c:714
* PFILE_OBJECT
Definition: iotypes.h:1957
#define FILE_PIPE_SERVER_END
Definition: iotypes.h:85
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:588
#define NPFS_NTC_ROOT_DCB
Definition: npfs.h:113
VOID NTAPI NpSetFileObject(IN PFILE_OBJECT FileObject, IN PVOID PrimaryContext, IN PVOID Ccb, IN ULONG NamedPipeEnd)
Definition: fileobsup.c:62
unsigned int * PULONG
Definition: retypes.h:1
#define OUT
Definition: typedefs.h:40
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
NODE_TYPE_CODE NTAPI NpDecodeFileObject(IN PFILE_OBJECT FileObject, OUT PVOID *PrimaryContext OPTIONAL, OUT PNP_CCB *Ccb, OUT PULONG NamedPipeEnd OPTIONAL)
Definition: fileobsup.c:20
#define ULONG_PTR
Definition: config.h:101
USHORT NODE_TYPE_CODE
Definition: nodetype.h:22
#define NPFS_NTC_VCB
Definition: npfs.h:112
Definition: dlist.c:348
#define PAGED_CODE()
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68