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
9 /* INCLUDES *******************************************************************/
13 // File ID number for NPFS bugchecking support
14 #define NPFS_BUGCHECK_FILE_ID (NPFS_BUGCHECK_FILEOBSUP)
16 /* FUNCTIONS ******************************************************************/
20 NpDecodeFileObject(IN PFILE_OBJECT FileObject
,
21 OUT PVOID
* PrimaryContext OPTIONAL
,
23 OUT PULONG NamedPipeEnd OPTIONAL
)
29 Context
= (ULONG_PTR
)FileObject
->FsContext
;
30 if ((Context
) && (Context
!= 1))
32 if (NamedPipeEnd
) *NamedPipeEnd
= Context
& 1;
34 Node
= (PVOID
)(Context
& ~1);
36 switch (Node
->NodeType
)
41 case NPFS_NTC_ROOT_DCB
:
42 *Ccb
= FileObject
->FsContext2
;
43 if (PrimaryContext
) *PrimaryContext
= Node
;
44 return NPFS_NTC_ROOT_DCB
;
48 if (PrimaryContext
) *PrimaryContext
= Node
->Fcb
;
52 NpBugCheck(Node
->NodeType
, 0, 0);
62 NpSetFileObject(IN PFILE_OBJECT FileObject
,
63 IN PVOID PrimaryContext
,
65 IN ULONG NamedPipeEnd
)
70 if (!FileObject
) return;
72 if ((PrimaryContext
) && (((PNP_CCB
)PrimaryContext
)->NodeType
== NPFS_NTC_CCB
))
75 if (NamedPipeEnd
== FILE_PIPE_SERVER_END
)
77 PrimaryContext
= (PVOID
) ((ULONG_PTR
) PrimaryContext
| 1);
85 FileObject
->FsContext
= PrimaryContext
;
86 FileObject
->FsContext2
= Ccb
;
87 FileObject
->PrivateCacheMap
= (PVOID
)1;
88 if (FileIsPipe
) FileObject
->Flags
|= FO_NAMED_PIPE
;