Giter VIP home page Giter VIP logo

Comments (7)

lundman avatar lundman commented on September 2, 2024

So I was looking at Windows Sample code disk.sys to help with

  • Reading GPT/EFI partitions, and creating \Volume\X entries for each partition
  • Fixing mount codes virtual \Volume\X which are currently not-right
  • Fixing ZVOL virtual \Volume\ which are not-right

I was under the impression that disk.sys would be fed (probed? scanned?) \PhysicalDriveX DeviceObjects, attempt to read partitions, and create valid \Volume\X devices as needed.

Compiling disk.sys into ZFS, the only callback called is ClassAddDevice = DiskAddDevice; which I guess is called when it's time for driver to add devices or something? The DeviceObject passed is not a PhysicalDriveX though. I am unsure then what processes \PhysicalDriveX devices, but it does look like disk.sys does read the partition table to create \Volumes.

Ignoring DiskAddDevice, I instead try to call disk.sys's DiskCreateFdo() to make my own virtual \Volume, but alas, this dies very early on in the call to IoAttachDeviceToDeviceStack() with c0000001.

I'm unsure if this is a reasonable path to take, or if I'm going the wrong way.

from zfsin.

lundman avatar lundman commented on September 2, 2024

disk.sys has not been that useful so far, but it is interesting to note that ramdisk example is also adding the disk to the registry, I wonder if I have to as well.

from zfsin.

lundman avatar lundman commented on September 2, 2024

Not entirely sure what version of the Dokan sources I was looking at, but the guys here dokan-dev/dokany#50 list the same issues that we have now, and seem to have moved beyond them. Wonder how approachable those devs are, but in the meantime, I should check their much improved sources.

from zfsin.

lundman avatar lundman commented on September 2, 2024

So I have been looking at the latest-dokany sources, and I think it is supposed to work like;

  • register as fs with IoRegisterFileSystem()
  • receive IRP_MN_MOUNT_VOLUME for any mountable device

Most of which we ignore by returning STATUS_UNRECOGNIZED_VOLUME - but if we find one of ours, we reply with STATUS_FS_DRIVER_REQUIRED to then receive IRP_MN_LOAD_FILE_SYSTEM.

When we want to mount a ZFS dataset

  • IoCreateDeviceSecure(FILE_DEVICE_DISK)

Which will cause all filesystems to be called with IRP_MN_MOUNT_VOLUME -
and since we detect it is ZFS (DeviceExtension is ours) to start the mounting process.

But the bugger does not work. It creates and sets everything up as expected:

SPL: beginning spl_free_thread() loop, spl_free == 0
hdr_recl called
hdr_recl called
hdr_recl called
ZFS: created kernel device node: FFFFCE8964968300: name ZFS: created kernel device node: 
FFFFCE8964968300: name DiskFileSystemDevice: 0x0  \FileSystem\ZFS created
ZFS: created userland device symlink
Filesystem FFFFCE89641E9D20: '\Device\Mup'
Filesystem FFFFCE89641E9D20: '\Device\Mup'
Filesystem FFFFCE89629BEE30: '\FileSystem\UdfsCdRomRecognizer'
Filesystem FFFFCE89641ED9D0: '\FileSystem\FatCdRomRecognizer'
Filesystem FFFFCE89629BEC00: '\FileSystem\CdfsRecognizer'
Filesystem FFFFCE8964055E40: '\Ntfs'
Filesystem FFFFCE89641E6060: '\FileSystem\FatDiskRecognizer'
Filesystem FFFFCE89641E66A0: '\FileSystem\ExFatRecognizer'
Filesystem FFFFCE89641E6470: '\FileSystem\ReFSRecognizer'
Filesystem FFFFCE89641EDE30: '\FileSystem\ReFSv1Recognizer'
Filesystem FFFFCE89641EDC00: '\FileSystem\UdfsDiskRecognizer'
Filesystem FFFFCE89633651B0: '\FileSystem\ZFS'
ZFS: Loaded module v1.6.0-1, ZFS pool version 5000, ZFS filesystem version 5
ZFS filesystem version: 5

Device names:

ZFS_DEV_KERNEL	L"\\Device\\ZFSCTL"   # The FILE_DEVICE_UNKNOWN
ZFS_GLOBAL_FS_DISK_DEVICE_NAME L"\\FileSystem\\ZFS"  # FILE_DEVICE_DISK_FILE_SYSTEM
ZFS_DEV_DOS		L"\\DosDevices\\Global\\ZFS"

But no IRP_MN_MOUNT_VOLUME at all received. It is especially annoying since it worked twice (I wasn't paying attention, but in the scroll back of the debugger immediate window:)

ZFS filesystem version: 5
dispatcher: enter: major 13: minor 1: IRP_MJ_FILE_SYSTEM_CONTROL(IRP_MN_MOUNT_VOLUME)
  ioctlDispatcher: enter: major 13: minor 1: IRP_MJ_FILE_SYSTEM_CONTROL(IRP_MN_MOUNT_VOLUME) ioctlDeviceObject
IRP_MN_MOUNT_VOLUME ioctl
*** mount request for FFFFCE8964339040
mount strlen 46
mount about '\Device\HarddiskVolume3'
dispatcher: exit: 0xc000014f <*****> Information 0x0

For all devices mountable. Dang, I wonder what I did to make that work.

The init code is all here;

ntStatus = IoCreateDeviceSecure(

modeled after dokany - but I have tried many variants of course.

from zfsin.

lundman avatar lundman commented on September 2, 2024

Minor success with 79fcef1 so its a step forward.

from zfsin.

lundman avatar lundman commented on September 2, 2024

3f06852

This handles most of the mounts, in C: or separate drive, and mounts inside ZFS which was a whole other thing. Includes a few IFSTEST passing as well, so the occasional function is correct.

from zfsin.

lundman avatar lundman commented on September 2, 2024

ZVOLs are now working, I ended up using miniport/storport, which was definitely the right thing to do.

from zfsin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.