ReactOS 0.4.15-dev-8109-gd7be748
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
15static
16VOID
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);
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);
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);
73 &FileFsSizeInfo,
74 sizeof(FileFsSizeInfo),
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);
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);
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);
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);
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
142static KSTART_ROUTINE RunTest;
143static
144VOID
145NTAPI
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
170START_TEST(NpfsVolumeInfo)
171{
173
176}
#define OUT_QUOTA
static VOID TestVolumeInfo(IN HANDLE ServerHandle)
static KSTART_ROUTINE RunTest
#define IN_QUOTA
#define MAX_INSTANCES
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
#define ok_eq_longlong(value, expected)
Definition: apitest.h:64
#define ok_eq_long(value, expected)
Definition: apitest.h:62
#define ok_bool_false(value, desc)
Definition: apitest.h:79
#define ok_eq_size(value, expected)
Definition: apitest.h:69
#define ok_eq_wchar(value, expected)
Definition: apitest.h:67
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
struct _FILE_FS_ATTRIBUTE_INFORMATION FILE_FS_ATTRIBUTE_INFORMATION
@ FileFsDeviceInformation
Definition: from_kernel.h:222
@ FileFsAttributeInformation
Definition: from_kernel.h:223
@ FileFsVolumeInformation
Definition: from_kernel.h:219
@ FileFsSizeInformation
Definition: from_kernel.h:221
#define FILE_CASE_PRESERVED_NAMES
Definition: from_kernel.h:234
Status
Definition: gdiplustypes.h:25
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
VOID KmtFinishThread(IN PKTHREAD Thread OPTIONAL, IN PKEVENT Event OPTIONAL)
#define BYTE_STREAM
Definition: npfs.h:13
#define DUPLEX
Definition: npfs.h:21
#define DEVICE_NAMED_PIPE
Definition: npfs.h:11
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 QUEUE
Definition: npfs.h:17
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define KernelMode
Definition: asm.h:34
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define FileFsFullSizeInformation
Definition: ntifs_ex.h:389
NTSYSAPI NTSTATUS NTAPI ZwQueryVolumeInformationFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock, OUT PVOID FsInformation, IN ULONG Length, IN FS_INFORMATION_CLASS FsInformationClass)
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
#define FILE_DEVICE_NAMED_PIPE
Definition: winioctl.h:123
struct _FILE_FS_VOLUME_INFORMATION FILE_FS_VOLUME_INFORMATION
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
LARGE_INTEGER ActualAvailableAllocationUnits
Definition: from_kernel.h:272
LARGE_INTEGER CallerAvailableAllocationUnits
Definition: from_kernel.h:271
LARGE_INTEGER TotalAllocationUnits
Definition: from_kernel.h:270
LARGE_INTEGER TotalAllocationUnits
Definition: from_kernel.h:263
LARGE_INTEGER AvailableAllocationUnits
Definition: from_kernel.h:264
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
LONGLONG QuadPart
Definition: typedefs.h:114
__wchar_t WCHAR
Definition: xmlstorage.h:180