ReactOS  0.4.14-dev-49-gfb4591c
misc.c
Go to the documentation of this file.
1 /*
2  * FFS File System Driver for Windows
3  *
4  * misc.c
5  *
6  * 2004.5.6 ~
7  *
8  * Lee Jae-Hong, http://www.pyrasis.com
9  *
10  * See License.txt
11  *
12  */
13 
14 #include "ntifs.h"
15 #include "ffsdrv.h"
16 
17 /* Globals */
18 
19 extern PFFS_GLOBAL FFSGlobal;
20 
21 
22 /* Definitions */
23 
24 #ifdef ALLOC_PRAGMA
25 #pragma alloc_text(PAGE, FFSLog2)
26 #pragma alloc_text(PAGE, FFSSysTime)
27 #pragma alloc_text(PAGE, FFSInodeTime)
28 #pragma alloc_text(PAGE, FFSOEMToUnicode)
29 #pragma alloc_text(PAGE, FFSUnicodeToOEM)
30 #endif
31 
32 ULONG
34  ULONG Value)
35 {
36  ULONG Order = 0;
37 
38  PAGED_CODE();
39 
40  ASSERT(Value > 0);
41 
42  while (Value)
43  {
44  Order++;
45  Value >>= 1;
46  }
47 
48  return (Order - 1);
49 }
50 
51 
54  IN ULONG i_time)
55 {
56  LARGE_INTEGER SysTime;
57 
58  PAGED_CODE();
59 
60  RtlSecondsSince1970ToTime(i_time, &SysTime);
61 
62  return SysTime;
63 }
64 
65 ULONG
67  IN LARGE_INTEGER SysTime)
68 {
69  ULONG FFSTime;
70 
71  PAGED_CODE();
72 
73  RtlTimeToSecondsSince1970(&SysTime, &FFSTime);
74 
75  return FFSTime;
76 }
77 
78 
81  IN OUT PUNICODE_STRING Unicode,
82  IN POEM_STRING Oem)
83 {
85 
86  PAGED_CODE();
87 
89  Unicode,
90  Oem,
91  FALSE);
92 
93  if (!NT_SUCCESS(Status))
94  {
95  FFSBreakPoint();
96  goto errorout;
97  }
98 
99 errorout:
100 
101  return Status;
102 }
103 
104 
105 NTSTATUS
107  IN OUT POEM_STRING Oem,
108  IN PUNICODE_STRING Unicode)
109 {
111 
112  PAGED_CODE();
113 
115  Oem,
116  Unicode,
117  FALSE);
118 
119  if (!NT_SUCCESS(Status))
120  {
121  FFSBreakPoint();
122  goto errorout;
123  }
124 
125 errorout:
126 
127  return Status;
128 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define IN
Definition: typedefs.h:38
BOOLEAN NTAPI RtlTimeToSecondsSince1970(PLARGE_INTEGER Time, PULONG ElapsedSeconds)
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
#define FFSBreakPoint()
Definition: ffsdrv.h:43
ULONG FFSInodeTime(IN LARGE_INTEGER SysTime)
Definition: misc.c:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString, PCUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
ULONG FFSLog2(ULONG Value)
Definition: misc.c:33
NTSYSAPI NTSTATUS NTAPI RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString, PCOEM_STRING SourceString, BOOLEAN AllocateDestinationString)
LARGE_INTEGER FFSSysTime(IN ULONG i_time)
Definition: misc.c:53
Status
Definition: gdiplustypes.h:24
#define OUT
Definition: typedefs.h:39
NTSTATUS FFSUnicodeToOEM(IN OUT POEM_STRING Oem, IN PUNICODE_STRING Unicode)
Definition: misc.c:106
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS FFSOEMToUnicode(IN OUT PUNICODE_STRING Unicode, IN POEM_STRING Oem)
Definition: misc.c:80