ReactOS  0.4.13-dev-52-g0efcfec
volume.c File Reference
#include "btrfs_drv.h"
#include <mountdev.h>
#include <ntddvol.h>
#include <ntddstor.h>
#include <ntdddisk.h>
#include <wdmguid.h>
Include dependency graph for volume.c:

Go to the source code of this file.

Classes

struct  vol_read_context
 

Macros

#define IOCTL_VOLUME_IS_DYNAMIC   CTL_CODE(IOCTL_VOLUME_BASE, 18, METHOD_BUFFERED, FILE_ANY_ACCESS)
 
#define IOCTL_VOLUME_POST_ONLINE   CTL_CODE(IOCTL_VOLUME_BASE, 25, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
 

Functions

NTSTATUS vol_create (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_close (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
 _Function_class_ (IO_COMPLETION_ROUTINE)
 
NTSTATUS vol_read (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_write (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_query_information (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_set_information (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_query_ea (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_set_ea (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_flush_buffers (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_query_volume_information (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_set_volume_information (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_cleanup (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_directory_control (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_file_system_control (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_lock_control (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS vol_query_device_name (volume_device_extension *vde, PIRP Irp)
 
static NTSTATUS vol_query_unique_id (volume_device_extension *vde, PIRP Irp)
 
static NTSTATUS vol_is_dynamic (PIRP Irp)
 
static NTSTATUS vol_check_verify (volume_device_extension *vde)
 
static NTSTATUS vol_get_disk_extents (volume_device_extension *vde, PIRP Irp)
 
static NTSTATUS vol_is_writable (volume_device_extension *vde)
 
static NTSTATUS vol_get_length (volume_device_extension *vde, PIRP Irp)
 
static NTSTATUS vol_get_drive_geometry (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
static NTSTATUS vol_get_gpt_attributes (PIRP Irp)
 
static NTSTATUS vol_get_device_number (volume_device_extension *vde, PIRP Irp)
 
static NTSTATUS vol_ioctl_passthrough (volume_device_extension *vde, PIRP Irp)
 
NTSTATUS vol_device_control (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_shutdown (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_query_security (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_set_security (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_power (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS mountmgr_add_drive_letter (PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath)
 
 _Function_class_ (DRIVER_NOTIFICATION_CALLBACK_ROUTINE)
 
static BOOL allow_degraded_mount (BTRFS_UUID *uuid)
 
void add_volume_device (superblock *sb, PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath, UINT64 length, ULONG disk_num, ULONG part_num)
 

Variables

PDRIVER_OBJECT drvobj
 
PDEVICE_OBJECT master_devobj
 
ERESOURCE pdo_list_lock
 
LIST_ENTRY pdo_list
 
UNICODE_STRING registry_path
 

Macro Definition Documentation

◆ IOCTL_VOLUME_IS_DYNAMIC

#define IOCTL_VOLUME_IS_DYNAMIC   CTL_CODE(IOCTL_VOLUME_BASE, 18, METHOD_BUFFERED, FILE_ANY_ACCESS)

Definition at line 25 of file volume.c.

◆ IOCTL_VOLUME_POST_ONLINE

Definition at line 26 of file volume.c.

Function Documentation

◆ _Function_class_() [1/2]

_Function_class_ ( IO_COMPLETION_ROUTINE  )

Definition at line 110 of file volume.c.

112  {
113 #else
114 static NTSTATUS vol_read_completion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID conptr) {
115 #endif
116  vol_read_context* context = conptr;
117 
119 
120  context->iosb = Irp->IoStatus;
121  KeSetEvent(&context->Event, 0, FALSE);
122 
124 }
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:63
Definition: http.c:6587
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define UNUSED(x)
Definition: btrfs_drv.h:81
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

◆ _Function_class_() [2/2]

_Function_class_ ( DRIVER_NOTIFICATION_CALLBACK_ROUTINE  )

Definition at line 907 of file volume.c.

909  {
910 #else
912 #endif
915 
916  if (RtlCompareMemory(&tdrn->Event, &GUID_TARGET_DEVICE_QUERY_REMOVE, sizeof(GUID)) == sizeof(GUID)) {
917  TRACE("GUID_TARGET_DEVICE_QUERY_REMOVE\n");
918 
919  if (pdode->vde && pdode->vde->mounted_device)
921  }
922 
923  return STATUS_SUCCESS;
924 }
_In_ PVOID NotificationStructure
Definition: iofuncs.h:1203
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PDEVICE_OBJECT mounted_device
Definition: btrfs_drv.h:830
volume_device_extension * vde
Definition: btrfs_drv.h:842
NTSTATUS pnp_query_remove_device(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: pnp.c:184
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465

◆ add_volume_device()

void add_volume_device ( superblock sb,
PDEVICE_OBJECT  mountmgr,
PUNICODE_STRING  devpath,
UINT64  length,
ULONG  disk_num,
ULONG  part_num 
)

Definition at line 1000 of file volume.c.

1000  {
1001  NTSTATUS Status;
1002  LIST_ENTRY* le;
1004  volume_child* vc;
1006  UNICODE_STRING devpath2;
1007  BOOL inserted = FALSE, new_pdo = FALSE;
1008  pdo_device_extension* pdode = NULL;
1009  PDEVICE_OBJECT pdo = NULL;
1010 
1011  if (devpath->Length == 0)
1012  return;
1013 
1015 
1016  le = pdo_list.Flink;
1017  while (le != &pdo_list) {
1019 
1020  if (RtlCompareMemory(&pdode2->uuid, &sb->uuid, sizeof(BTRFS_UUID)) == sizeof(BTRFS_UUID)) {
1021  pdode = pdode2;
1022  break;
1023  }
1024 
1025  le = le->Flink;
1026  }
1027 
1029  if (!NT_SUCCESS(Status)) {
1030  ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
1032  return;
1033  }
1034 
1035  if (!pdode) {
1036  if (no_pnp) {
1037  Status = IoReportDetectedDevice(drvobj, InterfaceTypeUndefined, 0xFFFFFFFF, 0xFFFFFFFF, NULL, NULL, 0, &pdo);
1038 
1039  if (!NT_SUCCESS(Status)) {
1040  ERR("IoReportDetectedDevice returned %08x\n", Status);
1042  return;
1043  }
1044 
1046 
1047  if (!pdode) {
1048  ERR("out of memory\n");
1050  return;
1051  }
1052  } else {
1055  if (!NT_SUCCESS(Status)) {
1056  ERR("IoCreateDevice returned %08x\n", Status);
1058  goto fail;
1059  }
1060 
1062 
1063  pdode = pdo->DeviceExtension;
1064  }
1065 
1066  RtlZeroMemory(pdode, sizeof(pdo_device_extension));
1067 
1068  pdode->type = VCB_TYPE_PDO;
1069  pdode->pdo = pdo;
1070  pdode->uuid = sb->uuid;
1071 
1073  InitializeListHead(&pdode->children);
1074  pdode->num_children = sb->num_devices;
1075  pdode->children_loaded = 0;
1076 
1077  pdo->Flags &= ~DO_DEVICE_INITIALIZING;
1078  pdo->SectorSize = (USHORT)sb->sector_size;
1079 
1081 
1082  new_pdo = TRUE;
1083  } else {
1086 
1087  le = pdode->children.Flink;
1088  while (le != &pdode->children) {
1090 
1091  if (RtlCompareMemory(&vc2->uuid, &sb->dev_item.device_uuid, sizeof(BTRFS_UUID)) == sizeof(BTRFS_UUID)) {
1092  // duplicate, ignore
1095  goto fail;
1096  }
1097 
1098  le = le->Flink;
1099  }
1100  }
1101 
1103  if (!vc) {
1104  ERR("out of memory\n");
1105 
1108 
1109  goto fail;
1110  }
1111 
1112  vc->uuid = sb->dev_item.device_uuid;
1113  vc->devid = sb->dev_item.dev_id;
1114  vc->generation = sb->generation;
1115  vc->notification_entry = NULL;
1116 
1118  drvobj, pnp_removal, pdode, &vc->notification_entry);
1119  if (!NT_SUCCESS(Status))
1120  WARN("IoRegisterPlugPlayNotification returned %08x\n", Status);
1121 
1122  vc->devobj = DeviceObject;
1123  vc->fileobj = FileObject;
1124 
1125  devpath2 = *devpath;
1126 
1127  // The PNP path sometimes begins \\?\ and sometimes \??\. We need to remove this prefix
1128  // so we can compare properly if the device is removed.
1129  if (devpath->Length > 4 * sizeof(WCHAR) && devpath->Buffer[0] == '\\' && (devpath->Buffer[1] == '\\' || devpath->Buffer[1] == '?') &&
1130  devpath->Buffer[2] == '?' && devpath->Buffer[3] == '\\') {
1131  devpath2.Buffer = &devpath2.Buffer[3];
1132  devpath2.Length -= 3 * sizeof(WCHAR);
1133  devpath2.MaximumLength -= 3 * sizeof(WCHAR);
1134  }
1135 
1136  vc->pnp_name.Length = vc->pnp_name.MaximumLength = devpath2.Length;
1138 
1139  if (vc->pnp_name.Buffer)
1140  RtlCopyMemory(vc->pnp_name.Buffer, devpath2.Buffer, devpath2.Length);
1141  else {
1142  ERR("out of memory\n");
1143  vc->pnp_name.Length = vc->pnp_name.MaximumLength = 0;
1144  }
1145 
1146  vc->size = length;
1148  vc->disk_num = disk_num;
1149  vc->part_num = part_num;
1150  vc->had_drive_letter = FALSE;
1151 
1152  le = pdode->children.Flink;
1153  while (le != &pdode->children) {
1155 
1156  if (vc2->generation < vc->generation) {
1157  if (le == pdode->children.Flink)
1158  pdode->num_children = sb->num_devices;
1159 
1161  inserted = TRUE;
1162  break;
1163  }
1164 
1165  le = le->Flink;
1166  }
1167 
1168  if (!inserted)
1169  InsertTailList(&pdode->children, &vc->list_entry);
1170 
1171  pdode->children_loaded++;
1172 
1173  if (pdode->vde && pdode->vde->mounted_device) {
1175 
1176  ExAcquireResourceExclusiveLite(&Vcb->tree_lock, TRUE);
1177 
1178  le = Vcb->devices.Flink;
1179  while (le != &Vcb->devices) {
1181 
1182  if (!dev->devobj && RtlCompareMemory(&dev->devitem.device_uuid, &sb->dev_item.device_uuid, sizeof(BTRFS_UUID)) == sizeof(BTRFS_UUID)) {
1183  dev->devobj = DeviceObject;
1184  dev->disk_num = disk_num;
1185  dev->part_num = part_num;
1186  init_device(Vcb, dev, FALSE);
1187  break;
1188  }
1189 
1190  le = le->Flink;
1191  }
1192 
1193  ExReleaseResourceLite(&Vcb->tree_lock);
1194  }
1195 
1196  if (DeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) {
1197  pdode->removable = TRUE;
1198 
1199  if (pdode->vde && pdode->vde->device)
1200  pdode->vde->device->Characteristics |= FILE_REMOVABLE_MEDIA;
1201  }
1202 
1203  if (pdode->num_children == pdode->children_loaded || (pdode->children_loaded == 1 && allow_degraded_mount(&sb->uuid))) {
1204  if (pdode->num_children == 1) {
1205  Status = remove_drive_letter(mountmgr, devpath);
1207  WARN("remove_drive_letter returned %08x\n", Status);
1208 
1210  } else {
1211  le = pdode->children.Flink;
1212 
1213  while (le != &pdode->children) {
1215 
1217 
1218  name.Length = name.MaximumLength = vc->pnp_name.Length + (3 * sizeof(WCHAR));
1219  name.Buffer = ExAllocatePoolWithTag(PagedPool, name.Length, ALLOC_TAG);
1220 
1221  if (!name.Buffer) {
1222  ERR("out of memory\n");
1223 
1226 
1227  goto fail;
1228  }
1229 
1230  RtlCopyMemory(name.Buffer, L"\\??", 3 * sizeof(WCHAR));
1231  RtlCopyMemory(&name.Buffer[3], vc->pnp_name.Buffer, vc->pnp_name.Length);
1232 
1233  Status = remove_drive_letter(mountmgr, &name);
1234 
1236  WARN("remove_drive_letter returned %08x\n", Status);
1237 
1238  ExFreePool(name.Buffer);
1239 
1241 
1242  le = le->Flink;
1243  }
1244  }
1245 
1246  if ((!new_pdo || !no_pnp) && pdode->vde) {
1248  if (!NT_SUCCESS(Status))
1249  WARN("IoSetDeviceInterfaceState returned %08x\n", Status);
1250  }
1251  }
1252 
1254 
1255  if (new_pdo) {
1257 
1258  InsertTailList(&pdo_list, &pdode->list_entry);
1259 
1260  if (!no_pnp)
1262  }
1263 
1265 
1266  if (new_pdo && no_pnp)
1267  AddDevice(drvobj, pdo);
1268 
1269  return;
1270 
1271 fail:
1273 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define VCB_TYPE_PDO
Definition: btrfs_drv.h:630
#define FILE_DEVICE_DISK
Definition: winioctl.h:112
UNICODE_STRING pnp_name
Definition: btrfs_drv.h:814
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
static BOOL allow_degraded_mount(BTRFS_UUID *uuid)
Definition: volume.c:926
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define BTRFS_SUPERBLOCK_FLAGS_SEEDING
Definition: btrfs.h:114
superblock * sb
Definition: btrfs.c:3876
UINT64 num_devices
Definition: btrfs.h:216
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
DRIVER_ADD_DEVICE AddDevice
Definition: parport.h:72
void init_device(_In_ device_extension *Vcb, _Inout_ device *dev, _In_ BOOL get_nums)
Definition: btrfs.c:3059
PDEVICE_OBJECT device
Definition: btrfs_drv.h:829
#define WARN(fmt,...)
Definition: debug.h:111
VOID NTAPI ExConvertExclusiveToSharedLite(IN PERESOURCE Resource)
Definition: resource.c:1402
LONG NTSTATUS
Definition: precomp.h:26
UINT32 no_pnp
Definition: btrfs.c:83
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1434
UINT64 dev_id
Definition: btrfs.h:157
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
ULONG part_num
Definition: btrfs_drv.h:820
#define InsertTailList(ListHead, Entry)
UINT64 generation
Definition: btrfs_drv.h:811
BTRFS_UUID uuid
Definition: btrfs_drv.h:809
BOOL had_drive_letter
Definition: btrfs_drv.h:817
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PDEVICE_OBJECT pdo
Definition: btrfs_drv.h:843
#define ALLOC_TAG
Definition: btrfs_drv.h:86
UNICODE_STRING bus_name
Definition: btrfs_drv.h:833
NTSTATUS NTAPI IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject, IN INTERFACE_TYPE LegacyBusType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PCM_RESOURCE_LIST ResourceList, IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL, IN BOOLEAN ResourceAssigned, IN OUT PDEVICE_OBJECT *DeviceObject OPTIONAL)
Definition: pnpreport.c:162
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define DO_BUS_ENUMERATED_DEVICE
UINT32 sector_size
Definition: btrfs.h:217
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:812
DEV_ITEM dev_item
Definition: btrfs.h:230
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
PDRIVER_OBJECT drvobj
Definition: btrfs.c:60
BTRFS_UUID device_uuid
Definition: btrfs.h:169
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define STATUS_NOT_FOUND
Definition: shellext.h:67
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define Vcb
Definition: cdprocs.h:1425
LIST_ENTRY list_entry
Definition: btrfs_drv.h:851
ERESOURCE child_lock
Definition: btrfs_drv.h:848
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
void * notification_entry
Definition: btrfs_drv.h:818
PDEVICE_OBJECT mounted_device
Definition: btrfs_drv.h:830
* PFILE_OBJECT
Definition: iotypes.h:1954
ULONG disk_num
Definition: btrfs_drv.h:819
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
PFILE_OBJECT fileobj
Definition: btrfs_drv.h:813
PDEVICE_OBJECT master_devobj
Definition: btrfs.c:61
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI IoRegisterPlugPlayNotification(IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, IN ULONG EventCategoryFlags, IN PVOID EventCategoryData OPTIONAL, IN PDRIVER_OBJECT DriverObject, IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, IN PVOID Context, OUT PVOID *NotificationEntry)
Definition: pnpnotify.c:250
Definition: typedefs.h:117
BOOL seeding
Definition: btrfs_drv.h:816
Status
Definition: gdiplustypes.h:24
UINT64 devid
Definition: btrfs_drv.h:810
#define ERR(fmt,...)
Definition: debug.h:109
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:5082
ERESOURCE pdo_list_lock
Definition: btrfs.c:93
LIST_ENTRY pdo_list
Definition: btrfs.c:94
unsigned short USHORT
Definition: pedump.c:61
BTRFS_UUID uuid
Definition: btrfs.h:204
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
UINT64 generation
Definition: btrfs.h:208
Definition: list.h:27
volume_device_extension * vde
Definition: btrfs_drv.h:842
Definition: name.c:36
LIST_ENTRY list_entry
Definition: btrfs_drv.h:821
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
NTSTATUS remove_drive_letter(PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath)
Definition: search.c:208
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
LIST_ENTRY children
Definition: btrfs_drv.h:849
UINT64 flags
Definition: btrfs.h:206
PDEVICE_OBJECT buspdo
Definition: btrfs_drv.h:803
UINT64 size
Definition: btrfs_drv.h:815
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by test_vol().

◆ allow_degraded_mount()

static BOOL allow_degraded_mount ( BTRFS_UUID uuid)
static

Definition at line 926 of file volume.c.

926  {
927  HANDLE h;
930  UNICODE_STRING path, adus;
931  UINT32 degraded = mount_allow_degraded;
932  ULONG i, j, kvfilen, retlen;
934 
935  path.Length = path.MaximumLength = registry_path.Length + (37 * sizeof(WCHAR));
937 
938  if (!path.Buffer) {
939  ERR("out of memory\n");
940  return FALSE;
941  }
942 
944  i = registry_path.Length / sizeof(WCHAR);
945 
946  path.Buffer[i] = '\\';
947  i++;
948 
949  for (j = 0; j < 16; j++) {
950  path.Buffer[i] = hex_digit((uuid->uuid[j] & 0xF0) >> 4);
951  path.Buffer[i+1] = hex_digit(uuid->uuid[j] & 0xF);
952 
953  i += 2;
954 
955  if (j == 3 || j == 5 || j == 7 || j == 9) {
956  path.Buffer[i] = '-';
957  i++;
958  }
959  }
960 
962 
963  kvfilen = (ULONG)offsetof(KEY_VALUE_FULL_INFORMATION, Name[0]) + (255 * sizeof(WCHAR));
964  kvfi = ExAllocatePoolWithTag(PagedPool, kvfilen, ALLOC_TAG);
965  if (!kvfi) {
966  ERR("out of memory\n");
967  ExFreePool(path.Buffer);
968  return FALSE;
969  }
970 
971  Status = ZwOpenKey(&h, KEY_QUERY_VALUE, &oa);
973  goto end;
974  else if (!NT_SUCCESS(Status)) {
975  ERR("ZwOpenKey returned %08x\n", Status);
976  goto end;
977  }
978 
979  adus.Buffer = L"AllowDegraded";
980  adus.Length = adus.MaximumLength = sizeof(adus.Buffer) - sizeof(WCHAR);
981 
982  if (NT_SUCCESS(ZwQueryValueKey(h, &adus, KeyValueFullInformation, kvfi, kvfilen, &retlen))) {
983  if (kvfi->Type == REG_DWORD && kvfi->DataLength >= sizeof(UINT32)) {
984  UINT32* val = (UINT32*)((UINT8*)kvfi + kvfi->DataOffset);
985 
986  degraded = *val;
987  }
988  }
989 
990  ZwClose(h);
991 
992 end:
993  ExFreePool(kvfi);
994 
995  ExFreePool(path.Buffer);
996 
997  return degraded;
998 }
#define hex_digit(c)
Definition: btrfs_drv.h:1686
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
USHORT MaximumLength
Definition: env_spec_w32.h:370
GLsizei const GLchar ** path
Definition: glext.h:7234
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
GLuint GLuint end
Definition: gl.h:1545
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define ALLOC_TAG
Definition: btrfs_drv.h:86
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT32
UINT32 mount_allow_degraded
Definition: btrfs.c:81
smooth NULL
Definition: ftsmooth.c:416
#define offsetof(TYPE, MEMBER)
GLuint GLfloat * val
Definition: glext.h:7180
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
Definition: services.c:325
UNICODE_STRING registry_path
Definition: btrfs.c:85
Definition: msctf.idl:510
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
unsigned char UINT8
#define REG_DWORD
Definition: sdbapi.c:596
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by add_volume_device().

◆ mountmgr_add_drive_letter()

NTSTATUS mountmgr_add_drive_letter ( PDEVICE_OBJECT  mountmgr,
PUNICODE_STRING  devpath 
)

Definition at line 877 of file volume.c.

877  {
879  ULONG mmdltsize;
882 
883  mmdltsize = (ULONG)offsetof(MOUNTMGR_DRIVE_LETTER_TARGET, DeviceName[0]) + devpath->Length;
884 
885  mmdlt = ExAllocatePoolWithTag(NonPagedPool, mmdltsize, ALLOC_TAG);
886  if (!mmdlt) {
887  ERR("out of memory\n");
889  }
890 
891  mmdlt->DeviceNameLength = devpath->Length;
892  RtlCopyMemory(&mmdlt->DeviceName, devpath->Buffer, devpath->Length);
893  TRACE("mmdlt = %.*S\n", mmdlt->DeviceNameLength / sizeof(WCHAR), mmdlt->DeviceName);
894 
895  Status = dev_ioctl(mountmgr, IOCTL_MOUNTMGR_NEXT_DRIVE_LETTER, mmdlt, mmdltsize, &mmdli, sizeof(MOUNTMGR_DRIVE_LETTER_INFORMATION), FALSE, NULL);
896 
897  if (!NT_SUCCESS(Status))
898  ERR("IOCTL_MOUNTMGR_NEXT_DRIVE_LETTER returned %08x\n", Status);
899  else
900  TRACE("DriveLetterWasAssigned = %u, CurrentDriveLetter = %c\n", mmdli.DriveLetterWasAssigned, mmdli.CurrentDriveLetter);
901 
902  ExFreePool(mmdlt);
903 
904  return Status;
905 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define ALLOC_TAG
Definition: btrfs_drv.h:86
NTSTATUS dev_ioctl(_In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG ControlCode, _In_reads_bytes_opt_(InputBufferSize) PVOID InputBuffer, _In_ ULONG InputBufferSize, _Out_writes_bytes_opt_(OutputBufferSize) PVOID OutputBuffer, _In_ ULONG OutputBufferSize, _In_ BOOLEAN Override, _Out_opt_ IO_STATUS_BLOCK *iosb)
Definition: btrfs.c:2603
#define IOCTL_MOUNTMGR_NEXT_DRIVE_LETTER
Definition: mountmgr.h:34
smooth NULL
Definition: ftsmooth.c:416
#define offsetof(TYPE, MEMBER)
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by finish_removing_device(), and remove_volume_child().

◆ vol_check_verify()

static NTSTATUS vol_check_verify ( volume_device_extension vde)
static

Definition at line 424 of file volume.c.

424  {
425  pdo_device_extension* pdode = vde->pdode;
427  LIST_ENTRY* le;
428 
430 
431  le = pdode->children.Flink;
432  while (le != &pdode->children) {
434 
436  if (!NT_SUCCESS(Status))
437  goto end;
438 
439  le = le->Flink;
440  }
441 
443 
444 end:
446 
447  return Status;
448 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
GLuint GLuint end
Definition: gl.h:1545
NTSTATUS dev_ioctl(_In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG ControlCode, _In_reads_bytes_opt_(InputBufferSize) PVOID InputBuffer, _In_ ULONG InputBufferSize, _Out_writes_bytes_opt_(OutputBufferSize) PVOID OutputBuffer, _In_ ULONG OutputBufferSize, _In_ BOOLEAN Override, _Out_opt_ IO_STATUS_BLOCK *iosb)
Definition: btrfs.c:2603
smooth NULL
Definition: ftsmooth.c:416
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:812
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:832
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define IOCTL_STORAGE_CHECK_VERIFY
Definition: ntddstor.h:87
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ERESOURCE child_lock
Definition: btrfs_drv.h:848
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
Definition: list.h:27
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
LIST_ENTRY children
Definition: btrfs_drv.h:849
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by vol_device_control().

◆ vol_cleanup()

NTSTATUS vol_cleanup ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 328 of file volume.c.

328  {
329  TRACE("(%p, %p)\n", DeviceObject, Irp);
330 
331  Irp->IoStatus.Information = 0;
332 
333  return STATUS_SUCCESS;
334 }
_In_ PIRP Irp
Definition: csq.h:116
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by _Dispatch_type_().

◆ vol_close()

NTSTATUS vol_close ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 48 of file volume.c.

48  {
50  pdo_device_extension* pdode = vde->pdode;
51 
52  TRACE("(%p, %p)\n", DeviceObject, Irp);
53 
54  Irp->IoStatus.Information = 0;
55 
57 
59 
60  if (InterlockedDecrement(&vde->open_count) == 0 && vde->removing) {
62  UNICODE_STRING mmdevpath;
63  PDEVICE_OBJECT mountmgr;
64  PFILE_OBJECT mountmgrfo;
65  PDEVICE_OBJECT pdo;
66 
68  Status = IoGetDeviceObjectPointer(&mmdevpath, FILE_READ_ATTRIBUTES, &mountmgrfo, &mountmgr);
69  if (!NT_SUCCESS(Status))
70  ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
71  else {
72  remove_drive_letter(mountmgr, &vde->name);
73 
74  ObDereferenceObject(mountmgrfo);
75  }
76 
77  if (vde->mounted_device) {
79 
80  Vcb->vde = NULL;
81  }
82 
83  if (vde->name.Buffer)
84  ExFreePool(vde->name.Buffer);
85 
88 
89  if (vde->pdo->AttachedDevice)
90  IoDetachDevice(vde->pdo);
91 
92  pdo = vde->pdo;
93  IoDeleteDevice(vde->device);
94 
95  if (!no_pnp)
96  IoDeleteDevice(pdo);
97  } else
99 
101 
102  return STATUS_SUCCESS;
103 }
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
PDEVICE_OBJECT device
Definition: btrfs_drv.h:829
LONG NTSTATUS
Definition: precomp.h:26
UINT32 no_pnp
Definition: btrfs.c:83
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
PDEVICE_OBJECT pdo
Definition: btrfs_drv.h:831
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1295
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1434
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define MOUNTMGR_DEVICE_NAME
Definition: imports.h:76
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
UNICODE_STRING name
Definition: btrfs_drv.h:828
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:832
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
ERESOURCE child_lock
Definition: btrfs_drv.h:848
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
PDEVICE_OBJECT mounted_device
Definition: btrfs_drv.h:830
* PFILE_OBJECT
Definition: iotypes.h:1954
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define InterlockedDecrement
Definition: armddk.h:52
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1250
ERESOURCE pdo_list_lock
Definition: btrfs.c:93
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS remove_drive_letter(PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath)
Definition: search.c:208
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by _Dispatch_type_().

◆ vol_create()

NTSTATUS vol_create ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 34 of file volume.c.

34  {
36 
37  TRACE("(%p, %p)\n", DeviceObject, Irp);
38 
39  if (vde->removing)
41 
42  Irp->IoStatus.Information = FILE_OPENED;
44 
45  return STATUS_SUCCESS;
46 }
_In_ PIRP Irp
Definition: csq.h:116
#define FILE_OPENED
Definition: nt_native.h:769
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define InterlockedIncrement
Definition: armddk.h:53
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:65

Referenced by _Dispatch_type_().

◆ vol_device_control()

NTSTATUS vol_device_control ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 777 of file volume.c.

777  {
780 
781  TRACE("(%p, %p)\n", DeviceObject, Irp);
782 
783  Irp->IoStatus.Information = 0;
784 
785  switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) {
787  return vol_query_device_name(vde, Irp);
788 
790  return vol_query_unique_id(vde, Irp);
791 
793  return vol_get_device_number(vde, Irp);
794 
796  TRACE("unhandled control code IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME\n");
797  break;
798 
800  TRACE("unhandled control code IOCTL_MOUNTDEV_QUERY_STABLE_GUID\n");
801  break;
802 
804  TRACE("unhandled control code IOCTL_MOUNTDEV_LINK_CREATED\n");
805  break;
806 
808  return vol_get_gpt_attributes(Irp);
809 
811  return vol_is_dynamic(Irp);
812 
813  case IOCTL_VOLUME_ONLINE:
814  TRACE("unhandled control code IOCTL_VOLUME_ONLINE\n");
815  break;
816 
818  TRACE("unhandled control code IOCTL_VOLUME_POST_ONLINE\n");
819  break;
820 
823 
825  return vol_is_writable(vde);
826 
828  return vol_get_length(vde, Irp);
829 
832  return vol_check_verify(vde);
833 
835  return vol_get_disk_extents(vde, Irp);
836 
837  default: // pass ioctl through if only one child device
838  return vol_ioctl_passthrough(vde, Irp);
839  }
840 
842 }
static NTSTATUS vol_get_length(volume_device_extension *vde, PIRP Irp)
Definition: volume.c:571
static NTSTATUS vol_query_device_name(volume_device_extension *vde, PIRP Irp)
Definition: volume.c:354
_In_ PIRP Irp
Definition: csq.h:116
#define IOCTL_DISK_CHECK_VERIFY
Definition: cdrw_usr.h:175
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define IOCTL_DISK_IS_WRITABLE
Definition: cdrw_usr.h:172
static NTSTATUS vol_get_disk_extents(volume_device_extension *vde, PIRP Irp)
Definition: volume.c:450
#define IOCTL_VOLUME_IS_DYNAMIC
Definition: volume.c:25
#define IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
Definition: imports.h:93
#define IOCTL_MOUNTDEV_QUERY_UNIQUE_ID
Definition: imports.h:80
PVOID DeviceExtension
Definition: env_spec_w32.h:418
static NTSTATUS vol_get_drive_geometry(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: volume.c:602
#define IOCTL_VOLUME_ONLINE
Definition: ntddvol.h:62
#define IOCTL_STORAGE_GET_DEVICE_NUMBER
Definition: ntddstor.h:132
#define IOCTL_DISK_GET_LENGTH_INFO
Definition: imports.h:192
#define IOCTL_MOUNTDEV_QUERY_STABLE_GUID
Definition: imports.h:255
#define IOCTL_STORAGE_CHECK_VERIFY
Definition: ntddstor.h:87
#define TRACE(s)
Definition: solgame.cpp:4
#define IOCTL_VOLUME_POST_ONLINE
Definition: volume.c:26
static NTSTATUS vol_is_dynamic(PIRP Irp)
Definition: volume.c:408
static NTSTATUS vol_ioctl_passthrough(volume_device_extension *vde, PIRP Irp)
Definition: volume.c:710
static NTSTATUS vol_get_device_number(volume_device_extension *vde, PIRP Irp)
Definition: volume.c:656
#define IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
Definition: ntddvol.h:41
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME
Definition: imports.h:99
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
static NTSTATUS vol_is_writable(volume_device_extension *vde)
Definition: volume.c:540
static NTSTATUS vol_check_verify(volume_device_extension *vde)
Definition: volume.c:424
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
static NTSTATUS vol_query_unique_id(volume_device_extension *vde, PIRP Irp)
Definition: volume.c:378
#define IOCTL_VOLUME_GET_GPT_ATTRIBUTES
Definition: ntddvol.h:56
static NTSTATUS vol_get_gpt_attributes(PIRP Irp)
Definition: volume.c:640
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
#define IOCTL_MOUNTDEV_LINK_CREATED
Definition: imports.h:106

Referenced by _Dispatch_type_().

◆ vol_directory_control()

NTSTATUS vol_directory_control ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 336 of file volume.c.

336  {
337  TRACE("(%p, %p)\n", DeviceObject, Irp);
338 
340 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_file_system_control()

NTSTATUS vol_file_system_control ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 342 of file volume.c.

342  {
343  TRACE("(%p, %p)\n", DeviceObject, Irp);
344 
346 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_flush_buffers()

NTSTATUS vol_flush_buffers ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 310 of file volume.c.

310  {
311  TRACE("(%p, %p)\n", DeviceObject, Irp);
312 
314 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_get_device_number()

static NTSTATUS vol_get_device_number ( volume_device_extension vde,
PIRP  Irp 
)
static

Definition at line 656 of file volume.c.

656  {
657  pdo_device_extension* pdode = vde->pdode;
659  volume_child* vc;
661 
662  // If only one device, return its disk number. This is needed for ejection to work.
663 
664  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(STORAGE_DEVICE_NUMBER))
666 
668 
669  if (IsListEmpty(&pdode->children) || pdode->num_children > 1) {
672  }
673 
675 
676  if (vc->disk_num == 0xffffffff) {
679  }
680 
681  sdn = (STORAGE_DEVICE_NUMBER*)Irp->AssociatedIrp.SystemBuffer;
682 
684  sdn->DeviceNumber = vc->disk_num;
685  sdn->PartitionNumber = vc->part_num;
686 
688 
689  Irp->IoStatus.Information = sizeof(STORAGE_DEVICE_NUMBER);
690 
691  return STATUS_SUCCESS;
692 }
DEVICE_TYPE DeviceType
Definition: ntddstor.h:232
#define FILE_DEVICE_DISK
Definition: winioctl.h:112
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
ULONG part_num
Definition: btrfs_drv.h:820
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:832
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
ERESOURCE child_lock
Definition: btrfs_drv.h:848
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ULONG disk_num
Definition: btrfs_drv.h:819
struct _STORAGE_DEVICE_NUMBER STORAGE_DEVICE_NUMBER
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
Definition: list.h:27
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
LIST_ENTRY children
Definition: btrfs_drv.h:849
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by vol_device_control().

◆ vol_get_disk_extents()

static NTSTATUS vol_get_disk_extents ( volume_device_extension vde,
PIRP  Irp 
)
static

Definition at line 450 of file volume.c.

450  {
451  pdo_device_extension* pdode = vde->pdode;
453  LIST_ENTRY* le;
454  ULONG num_extents = 0, i, max_extents = 1;
457 
458  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(VOLUME_DISK_EXTENTS))
460 
462 
463  le = pdode->children.Flink;
464  while (le != &pdode->children) {
467 
470  ERR("IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS returned %08x\n", Status);
471  goto end;
472  }
473 
474  num_extents += ext2.NumberOfDiskExtents;
475 
476  if (ext2.NumberOfDiskExtents > max_extents)
477  max_extents = ext2.NumberOfDiskExtents;
478 
479  le = le->Flink;
480  }
481 
482  ext = Irp->AssociatedIrp.SystemBuffer;
483 
484  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < offsetof(VOLUME_DISK_EXTENTS, Extents[0]) + (num_extents * sizeof(DISK_EXTENT))) {
485  Irp->IoStatus.Information = offsetof(VOLUME_DISK_EXTENTS, Extents[0]);
486  ext->NumberOfDiskExtents = num_extents;
488  goto end;
489  }
490 
491  ext3 = ExAllocatePoolWithTag(PagedPool, offsetof(VOLUME_DISK_EXTENTS, Extents[0]) + (max_extents * sizeof(DISK_EXTENT)), ALLOC_TAG);
492  if (!ext3) {
493  ERR("out of memory\n");
495  goto end;
496  }
497 
498  i = 0;
499  ext->NumberOfDiskExtents = 0;
500 
501  le = pdode->children.Flink;
502  while (le != &pdode->children) {
504 
506  (ULONG)offsetof(VOLUME_DISK_EXTENTS, Extents[0]) + (max_extents * sizeof(DISK_EXTENT)), FALSE, NULL);
507  if (!NT_SUCCESS(Status)) {
508  ERR("IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS returned %08x\n", Status);
509  ExFreePool(ext3);
510  goto end;
511  }
512 
513  if (i + ext3->NumberOfDiskExtents > num_extents) {
514  Irp->IoStatus.Information = offsetof(VOLUME_DISK_EXTENTS, Extents[0]);
515  ext->NumberOfDiskExtents = i + ext3->NumberOfDiskExtents;
517  ExFreePool(ext3);
518  goto end;
519  }
520 
521  RtlCopyMemory(&ext->Extents[i], ext3->Extents, sizeof(DISK_EXTENT) * ext3->NumberOfDiskExtents);
522  i += ext3->NumberOfDiskExtents;
523 
524  le = le->Flink;
525  }
526 
527  ExFreePool(ext3);
528 
530 
531  ext->NumberOfDiskExtents = i;
532  Irp->IoStatus.Information = offsetof(VOLUME_DISK_EXTENTS, Extents[0]) + (i * sizeof(DISK_EXTENT));
533 
534 end:
536 
537  return Status;
538 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
GLuint GLuint end
Definition: gl.h:1545
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define ALLOC_TAG
Definition: btrfs_drv.h:86
NTSTATUS dev_ioctl(_In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG ControlCode, _In_reads_bytes_opt_(InputBufferSize) PVOID InputBuffer, _In_ ULONG InputBufferSize, _Out_writes_bytes_opt_(OutputBufferSize) PVOID OutputBuffer, _In_ ULONG OutputBufferSize, _In_ BOOLEAN Override, _Out_opt_ IO_STATUS_BLOCK *iosb)
Definition: btrfs.c:2603
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define offsetof(TYPE, MEMBER)
char ext[3]
Definition: mkdosfs.c:358
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:812
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:832
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ERESOURCE child_lock
Definition: btrfs_drv.h:848
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const BYTE ext2[]
Definition: encode.c:2699
#define IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
Definition: ntddvol.h:41
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
Definition: list.h:27
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
unsigned int ULONG
Definition: retypes.h:1
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
LIST_ENTRY children
Definition: btrfs_drv.h:849
static const BYTE ext3[]
Definition: encode.c:2701
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
struct _DISK_EXTENT DISK_EXTENT

Referenced by vol_device_control().

◆ vol_get_drive_geometry()

static NTSTATUS vol_get_drive_geometry ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)
static

Definition at line 602 of file volume.c.

602  {
604  pdo_device_extension* pdode = vde->pdode;
606  DISK_GEOMETRY* geom;
607  UINT64 length;
608  LIST_ENTRY* le;
609 
610  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(DISK_GEOMETRY))
612 
613  length = 0;
614 
616 
617  le = pdode->children.Flink;
618  while (le != &pdode->children) {
620 
621  length += vc->size;
622 
623  le = le->Flink;
624  }
625 
627 
628  geom = (DISK_GEOMETRY*)Irp->AssociatedIrp.SystemBuffer;
629  geom->BytesPerSector = DeviceObject->SectorSize == 0 ? 0x200 : DeviceObject->SectorSize;
630  geom->SectorsPerTrack = 0x3f;
631  geom->TracksPerCylinder = 0xff;
634 
635  Irp->IoStatus.Information = sizeof(DISK_GEOMETRY);
636 
637  return STATUS_SUCCESS;
638 }
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
ULONG BytesPerSector
Definition: ntdddisk.h:376
ULONG TracksPerCylinder
Definition: ntdddisk.h:374
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
PVOID DeviceExtension
Definition: env_spec_w32.h:418
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:832
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
LARGE_INTEGER Cylinders
Definition: ntdddisk.h:372
ULONG SectorsPerTrack
Definition: ntdddisk.h:375
MEDIA_TYPE MediaType
Definition: ntdddisk.h:373
ERESOURCE child_lock
Definition: btrfs_drv.h:848
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
Definition: typedefs.h:117
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
struct _DISK_GEOMETRY DISK_GEOMETRY
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
Definition: list.h:27
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
unsigned long long UINT64
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
LIST_ENTRY children
Definition: btrfs_drv.h:849
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define UInt32x32To64(a, b)
Definition: intsafe.h:258
UINT64 size
Definition: btrfs_drv.h:815
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by vol_device_control().

◆ vol_get_gpt_attributes()

static NTSTATUS vol_get_gpt_attributes ( PIRP  Irp)
static

Definition at line 640 of file volume.c.

640  {
643 
644  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(VOLUME_GET_GPT_ATTRIBUTES_INFORMATION))
646 
647  vggai = (VOLUME_GET_GPT_ATTRIBUTES_INFORMATION*)Irp->AssociatedIrp.SystemBuffer;
648 
649  vggai->GptAttributes = 0;
650 
651  Irp->IoStatus.Information = sizeof(VOLUME_GET_GPT_ATTRIBUTES_INFORMATION);
652 
653  return STATUS_SUCCESS;
654 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by vol_device_control().

◆ vol_get_length()

static NTSTATUS vol_get_length ( volume_device_extension vde,
PIRP  Irp 
)
static

Definition at line 571 of file volume.c.

571  {
573  pdo_device_extension* pdode = vde->pdode;
575  LIST_ENTRY* le;
576 
577  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(GET_LENGTH_INFORMATION))
579 
580  gli = (GET_LENGTH_INFORMATION*)Irp->AssociatedIrp.SystemBuffer;
581 
582  gli->Length.QuadPart = 0;
583 
585 
586  le = pdode->children.Flink;
587  while (le != &pdode->children) {
589 
590  gli->Length.QuadPart += vc->size;
591 
592  le = le->Flink;
593  }
594 
596 
597  Irp->IoStatus.Information = sizeof(GET_LENGTH_INFORMATION);
598 
599  return STATUS_SUCCESS;
600 }
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
struct _GET_LENGTH_INFORMATION GET_LENGTH_INFORMATION
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:832
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
ERESOURCE child_lock
Definition: btrfs_drv.h:848
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
Definition: typedefs.h:117
LARGE_INTEGER Length
Definition: winioctl.h:423
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
Definition: list.h:27
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
LIST_ENTRY children
Definition: btrfs_drv.h:849
return STATUS_SUCCESS
Definition: btrfs.c:2725
UINT64 size
Definition: btrfs_drv.h:815
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by vol_device_control().

◆ vol_ioctl_passthrough()

static NTSTATUS vol_ioctl_passthrough ( volume_device_extension vde,
PIRP  Irp 
)
static

Definition at line 710 of file volume.c.

710  {
712  volume_child* vc;
713  PIRP Irp2;
714  PIO_STACK_LOCATION IrpSp, IrpSp2;
715  KEVENT Event;
716  pdo_device_extension* pdode = vde->pdode;
717 
718  TRACE("(%p, %p)\n", vde, Irp);
719 
721 
722  if (IsListEmpty(&pdode->children)) {
725  }
726 
728 
729  if (vc->list_entry.Flink != &pdode->children) { // more than one device
732  }
733 
734  Irp2 = IoAllocateIrp(vc->devobj->StackSize, FALSE);
735 
736  if (!Irp2) {
737  ERR("IoAllocateIrp failed\n");
740  }
741 
743  IrpSp2 = IoGetNextIrpStackLocation(Irp2);
744 
745  IrpSp2->MajorFunction = IrpSp->MajorFunction;
746  IrpSp2->MinorFunction = IrpSp->MinorFunction;
747 
748  IrpSp2->Parameters.DeviceIoControl.OutputBufferLength = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
749  IrpSp2->Parameters.DeviceIoControl.InputBufferLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
750  IrpSp2->Parameters.DeviceIoControl.IoControlCode = IrpSp->Parameters.DeviceIoControl.IoControlCode;
751  IrpSp2->Parameters.DeviceIoControl.Type3InputBuffer = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
752 
753  Irp2->AssociatedIrp.SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
754  Irp2->MdlAddress = Irp->MdlAddress;
755  Irp2->UserBuffer = Irp->UserBuffer;
756  Irp2->Flags = Irp->Flags;
757 
759 
760  IoSetCompletionRoutine(Irp2, vol_ioctl_completion, &Event, TRUE, TRUE, TRUE);
761 
762  Status = IoCallDriver(vc->devobj, Irp2);
763 
764  if (Status == STATUS_PENDING) {
766  Status = Irp2->IoStatus.Status;
767  }
768 
769  Irp->IoStatus.Status = Irp2->IoStatus.Status;
770  Irp->IoStatus.Information = Irp2->IoStatus.Information;
771 
773 
774  return Status;
775 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
smooth NULL
Definition: ftsmooth.c:416
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:812
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:832
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define TRACE(s)
Definition: solgame.cpp:4
#define STATUS_PENDING
Definition: ntstatus.h:82
ERESOURCE child_lock
Definition: btrfs_drv.h:848
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
Definition: list.h:27
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
LIST_ENTRY list_entry
Definition: btrfs_drv.h:821
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
LIST_ENTRY children
Definition: btrfs_drv.h:849

Referenced by vol_device_control().

◆ vol_is_dynamic()

static NTSTATUS vol_is_dynamic ( PIRP  Irp)
static

Definition at line 408 of file volume.c.

408  {
410  UINT8* buf;
411 
412  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength == 0 || !Irp->AssociatedIrp.SystemBuffer)
414 
415  buf = (UINT8*)Irp->AssociatedIrp.SystemBuffer;
416 
417  *buf = 1;
418 
419  Irp->IoStatus.Information = 1;
420 
421  return STATUS_SUCCESS;
422 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2725
unsigned char UINT8

Referenced by vol_device_control().

◆ vol_is_writable()

static NTSTATUS vol_is_writable ( volume_device_extension vde)
static

Definition at line 540 of file volume.c.

540  {
541  pdo_device_extension* pdode = vde->pdode;
543  LIST_ENTRY* le;
544  BOOL writable = FALSE;
545 
547 
548  le = pdode->children.Flink;
549  while (le != &pdode->children) {
551 
553 
554  if (NT_SUCCESS(Status)) {
555  writable = TRUE;
556  break;
557  } else if (Status != STATUS_MEDIA_WRITE_PROTECTED)
558  goto end;
559 
560  le = le->Flink;
561  }
562 
564 
565 end:
567 
568  return STATUS_SUCCESS;
569 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_DISK_IS_WRITABLE
Definition: cdrw_usr.h:172
GLuint GLuint end
Definition: gl.h:1545
NTSTATUS dev_ioctl(_In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG ControlCode, _In_reads_bytes_opt_(InputBufferSize) PVOID InputBuffer, _In_ ULONG InputBufferSize, _Out_writes_bytes_opt_(OutputBufferSize) PVOID OutputBuffer, _In_ ULONG OutputBufferSize, _In_ BOOLEAN Override, _Out_opt_ IO_STATUS_BLOCK *iosb)
Definition: btrfs.c:2603
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:812
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:832
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ERESOURCE child_lock
Definition: btrfs_drv.h:848
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
Definition: list.h:27
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
LIST_ENTRY children
Definition: btrfs_drv.h:849
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by vol_device_control().

◆ vol_lock_control()

NTSTATUS vol_lock_control ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 348 of file volume.c.

348  {
349  TRACE("(%p, %p)\n", DeviceObject, Irp);
350 
352 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_power()

NTSTATUS vol_power ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 862 of file volume.c.

862  {
865 
866  TRACE("(%p, %p)\n", DeviceObject, Irp);
867 
869  Irp->IoStatus.Status = STATUS_SUCCESS;
870 
871  Status = Irp->IoStatus.Status;
873 
874  return Status;
875 }
#define IRP_MN_QUERY_POWER
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define TRACE(s)
Definition: solgame.cpp:4
#define IRP_MN_SET_POWER
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:626
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by _Dispatch_type_().

◆ vol_query_device_name()

static NTSTATUS vol_query_device_name ( volume_device_extension vde,
PIRP  Irp 
)
static

Definition at line 354 of file volume.c.

354  {
357 
358  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(MOUNTDEV_NAME)) {
359  Irp->IoStatus.Information = sizeof(MOUNTDEV_NAME);
361  }
362 
363  name = Irp->AssociatedIrp.SystemBuffer;
364  name->NameLength = vde->name.Length;
365 
366  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < offsetof(MOUNTDEV_NAME, Name[0]) + name->NameLength) {
367  Irp->IoStatus.Information = sizeof(MOUNTDEV_NAME);
368  return STATUS_BUFFER_OVERFLOW;
369  }
370 
371  RtlCopyMemory(name->Name, vde->name.Buffer, vde->name.Length);
372 
373  Irp->IoStatus.Information = offsetof(MOUNTDEV_NAME, Name[0]) + name->NameLength;
374 
375  return STATUS_SUCCESS;
376 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
UNICODE_STRING name
Definition: btrfs_drv.h:828
struct _MOUNTDEV_NAME MOUNTDEV_NAME
#define offsetof(TYPE, MEMBER)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
Definition: name.c:36
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2725
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by vol_device_control().

◆ vol_query_ea()

NTSTATUS vol_query_ea ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 298 of file volume.c.

298  {
299  TRACE("(%p, %p)\n", DeviceObject, Irp);
300 
302 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_query_information()

NTSTATUS vol_query_information ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 286 of file volume.c.

286  {
287  TRACE("(%p, %p)\n", DeviceObject, Irp);
288 
290 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_query_security()

NTSTATUS vol_query_security ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 850 of file volume.c.

850  {
851  TRACE("(%p, %p)\n", DeviceObject, Irp);
852 
854 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_query_unique_id()

static NTSTATUS vol_query_unique_id ( volume_device_extension vde,
PIRP  Irp 
)
static

Definition at line 378 of file volume.c.

378  {
380  MOUNTDEV_UNIQUE_ID* mduid;
381  pdo_device_extension* pdode;
382 
383  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(MOUNTDEV_UNIQUE_ID)) {
384  Irp->IoStatus.Information = sizeof(MOUNTDEV_UNIQUE_ID);
386  }
387 
388  mduid = Irp->AssociatedIrp.SystemBuffer;
389  mduid->UniqueIdLength = sizeof(BTRFS_UUID);
390 
391  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < offsetof(MOUNTDEV_UNIQUE_ID, UniqueId[0]) + mduid->UniqueIdLength) {
392  Irp->IoStatus.Information = sizeof(MOUNTDEV_UNIQUE_ID);
393  return STATUS_BUFFER_OVERFLOW;
394  }
395 
396  if (!vde->pdo)
398 
399  pdode = vde->pdode;
400 
401  RtlCopyMemory(mduid->UniqueId, &pdode->uuid, sizeof(BTRFS_UUID));
402 
403  Irp->IoStatus.Information = offsetof(MOUNTDEV_UNIQUE_ID, UniqueId[0]) + mduid->UniqueIdLength;
404 
405  return STATUS_SUCCESS;
406 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
USHORT UniqueIdLength
Definition: imports.h:138
PDEVICE_OBJECT pdo
Definition: btrfs_drv.h:831
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define offsetof(TYPE, MEMBER)
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:832
struct _MOUNTDEV_UNIQUE_ID MOUNTDEV_UNIQUE_ID
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2725
UCHAR UniqueId[1]
Definition: imports.h:139

Referenced by vol_device_control().

◆ vol_query_volume_information()

NTSTATUS vol_query_volume_information ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 316 of file volume.c.

316  {
317  TRACE("(%p, %p)\n", DeviceObject, Irp);
318 
320 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_read()

NTSTATUS vol_read ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 126 of file volume.c.

126  {
128  pdo_device_extension* pdode = vde->pdode;
129  volume_child* vc;
131  PIRP Irp2;
133  PIO_STACK_LOCATION IrpSp, IrpSp2;
134 
135  TRACE("(%p, %p)\n", DeviceObject, Irp);
136 
138 
139  if (IsListEmpty(&pdode->children)) {
142  goto end;
143  }
144 
146 
147  // We can't use IoSkipCurrentIrpStackLocation as the device isn't in our stack
148 
149  Irp2 = IoAllocateIrp(vc->devobj->StackSize, FALSE);
150 
151  if (!Irp2) {
152  ERR("IoAllocateIrp failed\n");
155  goto end;
156  }
157 
159  IrpSp2 = IoGetNextIrpStackLocation(Irp2);
160 
161  IrpSp2->MajorFunction = IRP_MJ_READ;
162 
163  if (vc->devobj->Flags & DO_BUFFERED_IO) {
164  Irp2->AssociatedIrp.SystemBuffer = ExAllocatePoolWithTag(NonPagedPool, IrpSp->Parameters.Read.Length, ALLOC_TAG);
165  if (!Irp2->AssociatedIrp.SystemBuffer) {
166  ERR("out of memory\n");
169  goto end;
170  }
171 
173 
174  Irp2->UserBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
175  } else if (vc->devobj->Flags & DO_DIRECT_IO)
176  Irp2->MdlAddress = Irp->MdlAddress;
177  else
178  Irp2->UserBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
179 
180  IrpSp2->Parameters.Read.Length = IrpSp->Parameters.Read.Length;
181  IrpSp2->Parameters.Read.ByteOffset.QuadPart = IrpSp->Parameters.Read.ByteOffset.QuadPart;
182 
184  Irp2->UserIosb = &context.iosb;
185 
186  IoSetCompletionRoutine(Irp2, vol_read_completion, &context, TRUE, TRUE, TRUE);
187 
188  Status = IoCallDriver(vc->devobj, Irp2);
189 
190  if (Status == STATUS_PENDING) {
192  Status = context.iosb.Status;
193  }
194 
196 
197  Irp->IoStatus.Information = context.iosb.Information;
198 
199 end:
200  Irp->IoStatus.Status = Status;
202 
203  return Status;
204 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Definition: http.c:6587
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
GLuint GLuint end
Definition: gl.h:1545
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
#define ALLOC_TAG
Definition: btrfs_drv.h:86
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:812
#define IoCompleteRequest
Definition: irp.c:1240
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:832
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define TRACE(s)
Definition: solgame.cpp:4
#define STATUS_PENDING
Definition: ntstatus.h:82
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
ERESOURCE child_lock
Definition: btrfs_drv.h:848
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define IRP_INPUT_OPERATION
#define IRP_BUFFERED_IO
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
Definition: list.h:27
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_DEALLOCATE_BUFFER
#define IO_NO_INCREMENT
Definition: iotypes.h:565
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
LIST_ENTRY children
Definition: btrfs_drv.h:849

Referenced by _Dispatch_type_().

◆ vol_set_ea()

NTSTATUS vol_set_ea ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 304 of file volume.c.

304  {
305  TRACE("(%p, %p)\n", DeviceObject, Irp);
306 
308 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_set_information()

NTSTATUS vol_set_information ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 292 of file volume.c.

292  {
293  TRACE("(%p, %p)\n", DeviceObject, Irp);
294 
296 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_set_security()

NTSTATUS vol_set_security ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 856 of file volume.c.

856  {
857  TRACE("(%p, %p)\n", DeviceObject, Irp);
858 
860 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_set_volume_information()

NTSTATUS vol_set_volume_information ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 322 of file volume.c.

322  {
323  TRACE("(%p, %p)\n", DeviceObject, Irp);
324 
326 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_shutdown()

NTSTATUS vol_shutdown ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 844 of file volume.c.

844  {
845  TRACE("(%p, %p)\n", DeviceObject, Irp);
846 
848 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define TRACE(s)
Definition: solgame.cpp:4
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by _Dispatch_type_().

◆ vol_write()

NTSTATUS vol_write ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 206 of file volume.c.

206  {
208  pdo_device_extension* pdode = vde->pdode;
209  volume_child* vc;
211  PIRP Irp2;
213  PIO_STACK_LOCATION IrpSp, IrpSp2;
214 
215  TRACE("(%p, %p)\n", DeviceObject, Irp);
216 
218 
219  if (IsListEmpty(&pdode->children)) {
222  goto end;
223  }
224 
226 
227  if (vc->list_entry.Flink != &pdode->children) { // more than once device
230  goto end;
231  }
232 
233  // We can't use IoSkipCurrentIrpStackLocation as the device isn't in our stack
234 
235  Irp2 = IoAllocateIrp(vc->devobj->StackSize, FALSE);
236 
237  if (!Irp2) {
238  ERR("IoAllocateIrp failed\n");
241  goto end;
242  }
243 
245  IrpSp2 = IoGetNextIrpStackLocation(Irp2);
246 
247  IrpSp2->MajorFunction = IRP_MJ_WRITE;
248 
249  if (vc->devobj->Flags & DO_BUFFERED_IO) {
250  Irp2->AssociatedIrp.SystemBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
251 
252  Irp2->Flags |= IRP_BUFFERED_IO;
253 
254  Irp2->UserBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
255  } else if (vc->devobj->Flags & DO_DIRECT_IO)
256  Irp2->MdlAddress = Irp->MdlAddress;
257  else
258  Irp2->UserBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
259 
260  IrpSp2->Parameters.Write.Length = IrpSp->Parameters.Write.Length;
261  IrpSp2->Parameters.Write.ByteOffset.QuadPart = IrpSp->Parameters.Write.ByteOffset.QuadPart;
262 
264  Irp2->UserIosb = &context.iosb;
265 
266  IoSetCompletionRoutine(Irp2, vol_read_completion, &context, TRUE, TRUE, TRUE);
267 
268  Status = IoCallDriver(vc->devobj, Irp2);
269 
270  if (Status == STATUS_PENDING) {
272  Status = context.iosb.Status;
273  }
274 
276 
277  Irp->IoStatus.Information = context.iosb.Information;
278 
279 end:
280  Irp->IoStatus.Status = Status;
282 
283  return Status;
284 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Definition: http.c:6587
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
GLuint GLuint end
Definition: gl.h:1545
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:812
#define IoCompleteRequest
Definition: irp.c:1240
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:832
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define TRACE(s)
Definition: solgame.cpp:4
#define STATUS_PENDING
Definition: ntstatus.h:82
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
ERESOURCE child_lock
Definition: btrfs_drv.h:848
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define IRP_BUFFERED_IO
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
Definition: list.h:27
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
LIST_ENTRY list_entry
Definition: btrfs_drv.h:821
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
LIST_ENTRY children
Definition: btrfs_drv.h:849

Referenced by _Dispatch_type_().

Variable Documentation

◆ drvobj

Definition at line 60 of file btrfs.c.

Referenced by _Function_class_(), add_volume_device(), AddDevice(), and mount_vol().

◆ master_devobj

PDEVICE_OBJECT master_devobj

Definition at line 61 of file btrfs.c.

Referenced by _Dispatch_type_(), _Function_class_(), add_volume_device(), and mount_vol().

◆ pdo_list

LIST_ENTRY pdo_list

Definition at line 94 of file btrfs.c.

Referenced by _Function_class_(), add_volume_device(), AddDevice(), and mount_vol().

◆ pdo_list_lock

ERESOURCE pdo_list_lock

Definition at line 93 of file btrfs.c.

Referenced by _Function_class_(), add_volume_device(), AddDevice(), mount_vol(), and vol_close().

◆ registry_path

UNICODE_STRING registry_path

Definition at line 85 of file btrfs.c.

Referenced by _Function_class_(), and allow_degraded_mount().