1 /* 2 * PROJECT: ReactOS Named Pipe FileSystem 3 * LICENSE: BSD - See COPYING.ARM in the top level directory 4 * FILE: drivers/filesystems/npfs/volinfo.c 5 * PURPOSE: Named Pipe FileSystem Volume Information 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_VOLINFO) 15 16 /* FUNCTIONS ******************************************************************/ 17 18 NTSTATUS 19 NTAPI 20 NpQueryFsVolumeInfo(IN PVOID Buffer, 21 IN OUT PULONG Length) 22 { 23 PFILE_FS_VOLUME_INFORMATION InfoBuffer = Buffer; 24 NTSTATUS Status; 25 USHORT NameLength; 26 TRACE("Entered\n"); 27 28 *Length -= FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel); 29 30 InfoBuffer->SupportsObjects = 0; 31 32 NameLength = 18; 33 InfoBuffer->VolumeLabelLength = 18; 34 35 if (*Length < 18) 36 { 37 NameLength = (USHORT)*Length; 38 Status = STATUS_BUFFER_OVERFLOW; 39 } 40 else 41 { 42 Status = STATUS_SUCCESS; 43 } 44 45 RtlCopyMemory(InfoBuffer->VolumeLabel, L"NamedPipe", NameLength); 46 *Length -= NameLength; 47 48 TRACE("Leaving, Status = %lx\n", Status); 49 return Status; 50 } 51 52 NTSTATUS 53 NTAPI 54 NpQueryFsSizeInfo(IN PVOID Buffer, 55 IN OUT PULONG Length) 56 { 57 PFILE_FS_SIZE_INFORMATION InfoBuffer = Buffer; 58 TRACE("Entered\n"); 59 60 *Length -= sizeof(*InfoBuffer); 61 62 InfoBuffer->SectorsPerAllocationUnit = 1; 63 InfoBuffer->BytesPerSector = 1; 64 65 TRACE("Leaving, Status = STATUS_SUCCESS\n"); 66 return STATUS_SUCCESS; 67 } 68 69 NTSTATUS 70 NTAPI 71 NpQueryFsDeviceInfo(IN PVOID Buffer, 72 IN OUT PULONG Length) 73 { 74 PFILE_FS_DEVICE_INFORMATION InfoBuffer = Buffer; 75 TRACE("Entered\n"); 76 77 InfoBuffer->DeviceType = FILE_DEVICE_NAMED_PIPE; 78 *Length -= sizeof(*InfoBuffer); 79 80 TRACE("Leaving, Status = STATUS_SUCCESS\n"); 81 return STATUS_SUCCESS; 82 } 83 84 NTSTATUS 85 NTAPI 86 NpQueryFsAttributeInfo(IN PVOID Buffer, 87 IN OUT PULONG Length) 88 { 89 PFILE_FS_ATTRIBUTE_INFORMATION InfoBuffer = Buffer; 90 NTSTATUS Status; 91 USHORT NameLength; 92 TRACE("Entered\n"); 93 94 NameLength = (USHORT)(*Length - 12); 95 if (NameLength < 8) 96 { 97 *Length = 0; 98 Status = STATUS_BUFFER_OVERFLOW; 99 } 100 else 101 { 102 *Length -= 20; 103 NameLength = 8; 104 Status = STATUS_SUCCESS; 105 } 106 107 InfoBuffer->MaximumComponentNameLength = 0xFFFFFFFF; 108 InfoBuffer->FileSystemNameLength = 8; 109 InfoBuffer->FileSystemAttributes = FILE_CASE_PRESERVED_NAMES; 110 RtlCopyMemory(InfoBuffer->FileSystemName, L"NPFS", NameLength); 111 112 TRACE("Leaving, Status = %lx\n", Status); 113 return Status; 114 } 115 116 NTSTATUS 117 NTAPI 118 NpQueryFsFullSizeInfo(IN PVOID Buffer, 119 IN OUT PULONG Length) 120 { 121 PFILE_FS_FULL_SIZE_INFORMATION InfoBuffer = Buffer; 122 TRACE("Entered\n"); 123 124 *Length -= sizeof(*InfoBuffer); 125 126 RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer)); 127 128 TRACE("Leaving, Status = STATUS_SUCCESS\n"); 129 return STATUS_SUCCESS; 130 } 131 132 NTSTATUS 133 NTAPI 134 NpCommonQueryVolumeInformation(IN PDEVICE_OBJECT DeviceObject, 135 IN PIRP Irp) 136 { 137 PIO_STACK_LOCATION IoStack; 138 FS_INFORMATION_CLASS InfoClass; 139 ULONG Length; 140 PVOID Buffer; 141 NTSTATUS Status; 142 PAGED_CODE(); 143 TRACE("Entered\n"); 144 145 IoStack = IoGetCurrentIrpStackLocation(Irp); 146 Buffer = Irp->AssociatedIrp.SystemBuffer; 147 Length = IoStack->Parameters.QueryVolume.Length; 148 InfoClass = IoStack->Parameters.QueryVolume.FsInformationClass; 149 150 RtlZeroMemory(Buffer, Length); 151 152 switch (InfoClass) 153 { 154 case FileFsVolumeInformation: 155 Status = NpQueryFsVolumeInfo(Buffer, &Length); 156 break; 157 case FileFsSizeInformation: 158 Status = NpQueryFsSizeInfo(Buffer, &Length); 159 break; 160 case FileFsDeviceInformation: 161 Status = NpQueryFsDeviceInfo(Buffer, &Length); 162 break; 163 case FileFsAttributeInformation: 164 Status = NpQueryFsAttributeInfo(Buffer, &Length); 165 break; 166 case FileFsFullSizeInformation: 167 Status = NpQueryFsFullSizeInfo(Buffer, &Length); 168 break; 169 default: 170 Status = STATUS_NOT_SUPPORTED; 171 break; 172 } 173 174 Irp->IoStatus.Information = IoStack->Parameters.QueryVolume.Length - Length; 175 TRACE("Leaving, Status = %lx\n", Status); 176 return Status; 177 } 178 179 NTSTATUS 180 NTAPI 181 NpFsdQueryVolumeInformation(IN PDEVICE_OBJECT DeviceObject, 182 IN PIRP Irp) 183 { 184 NTSTATUS Status; 185 PAGED_CODE(); 186 TRACE("Entered\n"); 187 188 FsRtlEnterFileSystem(); 189 NpAcquireSharedVcb(); 190 191 Status = NpCommonQueryVolumeInformation(DeviceObject, Irp); 192 193 NpReleaseVcb(); 194 FsRtlExitFileSystem(); 195 196 if (Status != STATUS_PENDING) 197 { 198 Irp->IoStatus.Status = Status; 199 IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT); 200 } 201 202 TRACE("Leaving, Status = %lx\n", Status); 203 return Status; 204 } 205 206 /* EOF */ 207