ReactOS  0.4.14-dev-49-gfb4591c
NpfsVolumeInfo.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS kernel-mode tests
3  * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory
4  * PURPOSE: Kernel-Mode Test Suite NPFS volume information test
5  * PROGRAMMER: Pierre Schweitzer <pierre@reactos.org>
6  */
7 
8 #include <kmt_test.h>
9 #include "npfs.h"
10 
11 #define MAX_INSTANCES 1
12 #define IN_QUOTA 4096
13 #define OUT_QUOTA 4096
14 
15 static
16 VOID
18  IN HANDLE ServerHandle)
19 {
22  FILE_FS_SIZE_INFORMATION FileFsSizeInfo;
23  FILE_FS_DEVICE_INFORMATION FileFsDeviceInfo;
24  FILE_FS_FULL_SIZE_INFORMATION FileFsFullSizeInfo;
25 
26  struct {
28  WCHAR PartialName[10];
29  } VolumeInfo;
30 
31  struct {
33  WCHAR PartialName[6];
34  } AttributeInfo;
35 
36  RtlFillMemory(&VolumeInfo, sizeof(VolumeInfo), 0xFF);
37  Status = ZwQueryVolumeInformationFile(ServerHandle,
39  &VolumeInfo,
40  sizeof(VolumeInfo),
44  ok_eq_long(VolumeInfo.VolumeCreationTime.LowPart, 0);
45  ok_eq_long(VolumeInfo.VolumeCreationTime.HighPart, 0);
46  ok_eq_ulong(VolumeInfo.VolumeSerialNumber, 0);
47  ok_bool_false(VolumeInfo.SupportsObjects, "VolumeInfo.SupportsObjects");
48  ok_eq_ulong(VolumeInfo.VolumeLabelLength, 18);
49  ok_eq_size(RtlCompareMemory(VolumeInfo.VolumeLabel, L"NamedPipe", 18), 18);
50  ok_eq_wchar(VolumeInfo.VolumeLabel[9], 0xFFFF);
52 
53  RtlFillMemory(&VolumeInfo, sizeof(VolumeInfo), 0xFF);
54  Status = ZwQueryVolumeInformationFile(ServerHandle,
56  &VolumeInfo,
57  sizeof(FILE_FS_VOLUME_INFORMATION) + 2 * sizeof(WCHAR),
61  ok_eq_long(VolumeInfo.VolumeCreationTime.LowPart, 0);
62  ok_eq_long(VolumeInfo.VolumeCreationTime.HighPart, 0);
63  ok_eq_ulong(VolumeInfo.VolumeSerialNumber, 0);
64  ok_bool_false(VolumeInfo.SupportsObjects, "VolumeInfo.SupportsObjects");
65  ok_eq_ulong(VolumeInfo.VolumeLabelLength, 18);
66  ok_eq_size(RtlCompareMemory(VolumeInfo.VolumeLabel, L"NamedP", 10), 10);
67  ok_eq_wchar(VolumeInfo.VolumeLabel[5], 0xFFFF);
69 
70  RtlFillMemory(&FileFsSizeInfo, sizeof(FileFsSizeInfo), 0xFF);
71  Status = ZwQueryVolumeInformationFile(ServerHandle,
73  &FileFsSizeInfo,
74  sizeof(FileFsSizeInfo),
78  ok_eq_longlong(FileFsSizeInfo.TotalAllocationUnits.QuadPart, 0);
80  ok_eq_ulong(FileFsSizeInfo.SectorsPerAllocationUnit, 1);
81  ok_eq_ulong(FileFsSizeInfo.BytesPerSector, 1);
82  ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsSizeInfo));
83 
84  RtlFillMemory(&FileFsDeviceInfo, sizeof(FileFsDeviceInfo), 0xFF);
85  Status = ZwQueryVolumeInformationFile(ServerHandle,
87  &FileFsDeviceInfo,
88  sizeof(FileFsDeviceInfo),
92  ok_eq_ulong(FileFsDeviceInfo.Characteristics, 0);
94  ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsDeviceInfo));
95 
96  RtlFillMemory(&AttributeInfo, sizeof(AttributeInfo), 0xFF);
97  Status = ZwQueryVolumeInformationFile(ServerHandle,
99  &AttributeInfo,
100  sizeof(AttributeInfo),
104  ok_eq_ulong(AttributeInfo.FileSystemAttributes, FILE_CASE_PRESERVED_NAMES);
105  ok_eq_long(AttributeInfo.MaximumComponentNameLength, 0xFFFFFFFF);
106  ok_eq_ulong(AttributeInfo.FileSystemNameLength, 8);
107  ok_eq_size(RtlCompareMemory(AttributeInfo.FileSystemName, L"NPFS", 8), 8);
108  ok_eq_wchar(AttributeInfo.FileSystemName[4], 0xFFFF);
110 
111  RtlFillMemory(&AttributeInfo, sizeof(AttributeInfo), 0xFF);
112  Status = ZwQueryVolumeInformationFile(ServerHandle,
113  &IoStatusBlock,
114  &AttributeInfo,
115  sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 2 * sizeof(WCHAR),
119  ok_eq_ulong(AttributeInfo.FileSystemAttributes, FILE_CASE_PRESERVED_NAMES);
120  ok_eq_long(AttributeInfo.MaximumComponentNameLength, 0xFFFFFFFF);
121  ok_eq_ulong(AttributeInfo.FileSystemNameLength, 8);
122  ok_eq_size(RtlCompareMemory(AttributeInfo.FileSystemName, L"NPFS", 8), 8);
123  ok_eq_wchar(AttributeInfo.FileSystemName[4], 0xFFFF);
125 
126  RtlFillMemory(&FileFsFullSizeInfo, sizeof(FileFsFullSizeInfo), 0xFF);
127  Status = ZwQueryVolumeInformationFile(ServerHandle,
128  &IoStatusBlock,
129  &FileFsFullSizeInfo,
130  sizeof(FileFsFullSizeInfo),
134  ok_eq_longlong(FileFsFullSizeInfo.TotalAllocationUnits.QuadPart, 0);
137  ok_eq_ulong(FileFsFullSizeInfo.SectorsPerAllocationUnit, 0);
138  ok_eq_ulong(FileFsFullSizeInfo.BytesPerSector, 0);
139  ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsFullSizeInfo));
140 }
141 
142 static KSTART_ROUTINE RunTest;
143 static
144 VOID
145 NTAPI
147  IN PVOID Context)
148 {
150  HANDLE ServerHandle;
151 
153 
154  ServerHandle = INVALID_HANDLE_VALUE;
155  Status = NpCreatePipe(&ServerHandle,
156  DEVICE_NAMED_PIPE L"\\KmtestNpfsVolumeInfoTestPipe",
159  IN_QUOTA,
160  OUT_QUOTA);
162  ok(ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "ServerHandle = %p\n", ServerHandle);
163  if (!skip(NT_SUCCESS(Status) && ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "No pipe\n"))
164  {
165  TestVolumeInfo(ServerHandle);
166  ObCloseHandle(ServerHandle, KernelMode);
167  }
168 }
169 
170 START_TEST(NpfsVolumeInfo)
171 {
173 
176 }
NTSTATUS NpCreatePipe(OUT PHANDLE ServerHandle, IN PCWSTR PipePath, IN ULONG ReadMode, IN ULONG CompletionMode, IN ULONG NamedPipeType, IN ULONG NamedPipeConfiguration, IN ULONG MaximumInstances, IN ULONG InboundQuota, IN ULONG OutboundQuota)
#define MAX_INSTANCES
LARGE_INTEGER TotalAllocationUnits
Definition: from_kernel.h:263
#define ok_eq_ulong(value, expected)
#define IN
Definition: typedefs.h:38
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
#define ok_eq_longlong(value, expected)
Definition: kmt_test.h:242
#define ok_eq_size(value, expected)
Definition: kmt_test.h:247
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
static VOID TestVolumeInfo(IN HANDLE ServerHandle)
#define FILE_DEVICE_NAMED_PIPE
Definition: winioctl.h:122
#define FileFsFullSizeInformation
Definition: ntifs_ex.h:389
LONG NTSTATUS
Definition: precomp.h:26
#define DEVICE_NAMED_PIPE
Definition: npfs.h:11
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
struct _FILE_FS_ATTRIBUTE_INFORMATION FILE_FS_ATTRIBUTE_INFORMATION
static KSTART_ROUTINE RunTest
#define ok_bool_false(value, desc)
Definition: kmt_test.h:257
LARGE_INTEGER ActualAvailableAllocationUnits
Definition: from_kernel.h:272
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
LARGE_INTEGER AvailableAllocationUnits
Definition: from_kernel.h:264
smooth NULL
Definition: ftsmooth.c:416
#define IN_QUOTA
#define ok_eq_wchar(value, expected)
Definition: kmt_test.h:245
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define DUPLEX
Definition: npfs.h:21
NTSYSAPI NTSTATUS NTAPI ZwQueryVolumeInformationFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock, OUT PVOID FsInformation, IN ULONG Length, IN FS_INFORMATION_CLASS FsInformationClass)
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
static const WCHAR L[]
Definition: oid.c:1250
#define FILE_CASE_PRESERVED_NAMES
Definition: from_kernel.h:234
#define BYTE_STREAM
Definition: npfs.h:13
VOID KmtFinishThread(IN PKTHREAD Thread OPTIONAL, IN PKEVENT Event OPTIONAL)
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define ok(value,...)
Definition: atltest.h:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define QUEUE
Definition: npfs.h:17
#define skip(...)
Definition: atltest.h:64
struct _FILE_FS_VOLUME_INFORMATION FILE_FS_VOLUME_INFORMATION
#define OUT_QUOTA
START_TEST(NpfsVolumeInfo)
#define ok_eq_hex(value, expected)
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
#define ok_eq_long(value, expected)
Definition: kmt_test.h:240
LARGE_INTEGER CallerAvailableAllocationUnits
Definition: from_kernel.h:271
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
LARGE_INTEGER TotalAllocationUnits
Definition: from_kernel.h:270
LONGLONG QuadPart
Definition: typedefs.h:112