Disk Driver with Partitioning Support

Hi,

I have a RAM disk driver that is visible from Disk Manager.
I have registered the PDO(Physical Device Object) of my
device with the DiskClassGuid.

The Device works fine when I convert it into a Dynamic Disk but I
am facing problems while creating partitions on it as a Basic Disk.

When I try to create partitions on my RAM Disk the system
gives me the following error :- ‘Partition/volume not enabled. Please reboot
the machine to enable partition/volume.’

While attempting to create a new partition I am handling the
IOCTL_DISK_SET_DRIVE_LAYOUT during which I created a new
Device Object for the Partition with the name DP(X)Y-Z+K where:
X is the partition Number
Y is starting offset of the partition
Z is partition Length
K is a seqence number which I increament each time a new partition is
created

After creating the Partition Device Object I tried to register it
with PartitionClassGuid but received an error STATUS_INVALID_DEVICE_REQUEST.

Is my approach correct or am I missing something?
Also, is there some other way to make the system recognize the
partitions on my disk?

Any help on this is highly appreciated.

Edi.

Hi,
The first parameter for IoRegisterDeviceInterface must be PDO.

“maverick bapar” wrote in message news:xxxxx@ntdev…
Hi,

I have a RAM disk driver that is visible from Disk Manager.
I have registered the PDO(Physical Device Object) of my
device with the DiskClassGuid.

The Device works fine when I convert it into a Dynamic Disk but I
am facing problems while creating partitions on it as a Basic Disk.

When I try to create partitions on my RAM Disk the system
gives me the following error :- ‘Partition/volume not enabled. Please reboot the machine to enable partition/volume.’

While attempting to create a new partition I am handling the
IOCTL_DISK_SET_DRIVE_LAYOUT during which I created a new
Device Object for the Partition with the name DP(X)Y-Z+K where:
X is the partition Number
Y is starting offset of the partition
Z is partition Length
K is a seqence number which I increament each time a new partition is created

After creating the Partition Device Object I tried to register it
with PartitionClassGuid but received an error STATUS_INVALID_DEVICE_REQUEST.

Is my approach correct or am I missing something?
Also, is there some other way to make the system recognize the
partitions on my disk?

Any help on this is highly appreciated.

Edi.

Is your driver a PNP bus driver? Unless you report the partitions to
PNP as PDOs you can’t assign them device interfaces.

If you’re going to need to become a bus driver, you should consider
switching your driver over to use KMDF. It will make that much, much
simpler.

-p

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of maverick bapar
Sent: Wednesday, June 07, 2006 12:22 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Disk Driver with Partitioning Support

Hi,

I have a RAM disk driver that is visible from Disk Manager.
I have registered the PDO(Physical Device Object) of my
device with the DiskClassGuid.

The Device works fine when I convert it into a Dynamic Disk but I
am facing problems while creating partitions on it as a Basic Disk.

When I try to create partitions on my RAM Disk the system
gives me the following error :- ‘Partition/volume not enabled. Please
reboot the machine to enable partition/volume.’

While attempting to create a new partition I am handling the
IOCTL_DISK_SET_DRIVE_LAYOUT during which I created a new
Device Object for the Partition with the name DP(X)Y-Z+K where:
X is the partition Number
Y is starting offset of the partition
Z is partition Length
K is a seqence number which I increament each time a new partition is
created

After creating the Partition Device Object I tried to register it
with PartitionClassGuid but received an error
STATUS_INVALID_DEVICE_REQUEST.

Is my approach correct or am I missing something?
Also, is there some other way to make the system recognize the
partitions on my disk?

Any help on this is highly appreciated.

Edi.
— Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the
List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

>>Is my approach correct or am I missing something?

IMHO this approach is absolutely wrong. I doubt you should receive
IOCTL_DISK_SET_DRIVE_LAYOUT at all, as this is handled by disk.sys, see
disk.sys!DiskIoctlSetDriveLayout.

You should not create device objects for partitions either. This is all done
above your driver, assuming the latter is really PnP one with a PDO.

A virtual disk driver is the simplest to write if you do it right. All you
need to handle is raw sector read/write plus several simple IOCTLs.


http://www.cristalink.com

“maverick bapar” wrote in message news:xxxxx@ntdev…
Hi,

I have a RAM disk driver that is visible from Disk Manager.
I have registered the PDO(Physical Device Object) of my
device with the DiskClassGuid.

The Device works fine when I convert it into a Dynamic Disk but I
am facing problems while creating partitions on it as a Basic Disk.

When I try to create partitions on my RAM Disk the system
gives me the following error :- ‘Partition/volume not enabled. Please reboot
the machine to enable partition/volume.’

While attempting to create a new partition I am handling the
IOCTL_DISK_SET_DRIVE_LAYOUT during which I created a new
Device Object for the Partition with the name DP(X)Y-Z+K where:
X is the partition Number
Y is starting offset of the partition
Z is partition Length
K is a seqence number which I increament each time a new partition is
created

After creating the Partition Device Object I tried to register it
with PartitionClassGuid but received an error STATUS_INVALID_DEVICE_REQUEST.

Is my approach correct or am I missing something?
Also, is there some other way to make the system recognize the
partitions on my disk?

Any help on this is highly appreciated.

Edi.

Hi,

I want to emulate what disk.sys does. I want my RAM Disk to be visible from
disk Manager and have the system treat it as an Actual Disk.

Ok so I need a PDO to register with the partition interface.

How do make my partition objects PDO’s?

Is there a way to make a PDO in my driver code without shifting to the KMDF
model.

Edi.

You can make a PDO in your device driver. It involves making your
driver a PNP bus driver. From some of your description I’m guessing
that right now you might not even have a PNP driver.

If you want to go down this route then KMDF is the easiest way to
provide the support.

-p

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of maverick bapar
Sent: Thursday, June 08, 2006 12:44 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Disk Driver with Partitioning Support

Hi,

I want to emulate what disk.sys does. I want my RAM Disk to be visible
from
disk Manager and have the system treat it as an Actual Disk.

Ok so I need a PDO to register with the partition interface.

How do make my partition objects PDO’s?

Is there a way to make a PDO in my driver code without shifting to the
KMDF model.

Edi.

— Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the
List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Try to write the storage port itself, which will accept the SRBs on top of
it. Since you already have the PDOs and thus have a bus driver, this will not
be too complex.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “maverick bapar”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, June 07, 2006 11:21 AM
Subject: [ntdev] Disk Driver with Partitioning Support

> Hi,
>
> I have a RAM disk driver that is visible from Disk Manager.
> I have registered the PDO(Physical Device Object) of my
> device with the DiskClassGuid.
>
> The Device works fine when I convert it into a Dynamic Disk but I
> am facing problems while creating partitions on it as a Basic Disk.
>
> When I try to create partitions on my RAM Disk the system
> gives me the following error :- ‘Partition/volume not enabled. Please reboot
> the machine to enable partition/volume.’
>
> While attempting to create a new partition I am handling the
> IOCTL_DISK_SET_DRIVE_LAYOUT during which I created a new
> Device Object for the Partition with the name DP(X)Y-Z+K where:
> X is the partition Number
> Y is starting offset of the partition
> Z is partition Length
> K is a seqence number which I increament each time a new partition is
> created
>
> After creating the Partition Device Object I tried to register it
> with PartitionClassGuid but received an error STATUS_INVALID_DEVICE_REQUEST.
>
> Is my approach correct or am I missing something?
> Also, is there some other way to make the system recognize the
> partitions on my disk?
>
> Any help on this is highly appreciated.
>
> Edi.
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> You should not create device objects for partitions either. This is all done

above your driver, assuming the latter is really PnP one with a PDO.

No, this is the responsibility of the disk class driver. Usually it is
Disk.sys, but the guy seems to create his own disk class driver.

A virtual disk driver is the simplest to write if you do it right. All you
need to handle is raw sector read/write plus several simple IOCTLs.

Correct, it must be a bus driver, must create a PDO which will report “GenDisk”
as its hardware ID, and must be able to execute IOCTL_SCSI_xxx and also
IRP_MJ_SCSI - the SRBs.

You can look at Disk sample for a list of SCSI commands which the PDO must
support (sent by Disk).

Such a PDO driver is called “the storage port”.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Ok, I will write a storage port driver instead of a disk class driver.

Thanks,

Edi.

Hi,

As suggested I’ve changed my approach and tried writing a miniport driver
that
links with the scsi port driver.

I have supported PnP in the miniport driver and have added the PnPInterface
type in
the Registry Entry of the Driver’s Service.
The AdapterInterfaceType is PCIBus(5). I have also added the
“*HwScsiAdapterControl”
*routine
in my driver code to support PnP.

Since I am trying to create a virtual RamDisk I created a Devnode from a
setup program using
the API ‘SetupDiCreateDeviceInfo’. The Device is created under ‘Scsi and
Raid Controllers’ branch
and is visible from Device Manager.

After installing the Device the system gives the following error:
“This device cannot start. (Code 10)”.
Also, I think that my miniport driver is not initialized as the DebugPrint
messages from the Driver Entry routine
are not visible from Windbg.

What is the reason for above mentioned error?
Is there something that I’ve missed?

The code has been tested on windows 2000 SP4.

Thanks in advance,

Edi.