I had tried to set FILE_READ_ONLY_DEVICE when calling IoCreateDevice in my
bus driver, however, it did not work. How can I do that? Anything
additional need to be performed in miniport or bus driver?
Any advice will be great appreciated.
Is your PC infected? Get a FREE online computer virus scan from McAfee®
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
Hi Paul,
Look at SCSIOP_MODE_SENSE opcode handler.
Setting the bit MODE_DSP_WRITE_PROTECT in DeviceSpecificParameter field of
MODE_PARAMETER_HEADER structure usually does what you need.
This approach works fine in WinXP+ and also in Win2000 for all FS types but
NTFS.
If there is any other way I’d like to hear about it to…
Best regards,
Valeriy Glushkov
Îò: “paul chen”
Êîìó: “Windows System Software Devs Interest List”
Îòïðàâëåíî: 23 ôåâðàëÿ 2005 ã. 11:52
Òåìà: [ntdev] How can I set virtual scsi disk read-only?
> I had tried to set FILE_READ_ONLY_DEVICE when calling IoCreateDevice in
my
> bus driver, however, it did not work. How can I do that? Anything
> additional need to be performed in miniport or bus driver?
> Any advice will be great appreciated.
You must return the removable flag set in the INQUIRY data. The OS disk
drivers will handle the rest.
Jamey
----- Original Message -----
From: “paul chen”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, February 23, 2005 1:52 AM
Subject: [ntdev] How can I set virtual scsi disk read-only?
>I had tried to set FILE_READ_ONLY_DEVICE when calling IoCreateDevice in my
>bus driver, however, it did not work. How can I do that? Anything
>additional need to be performed in miniport or bus driver?
> Any advice will be great appreciated.
>
> _________________________________________________________________
> Is your PC infected? Get a FREE online computer virus scan from McAfee®
> Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@tfb.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
I did not mean to say removable; I do not know where my head was for a
second… I mis-read the post.
You need to the proper MODE_SENSE requests. I recommend reading the SCSI
specification. I do not remember the page right off hand.
Jamey
----- Original Message -----
From: “paul chen”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, February 23, 2005 1:52 AM
Subject: [ntdev] How can I set virtual scsi disk read-only?
>I had tried to set FILE_READ_ONLY_DEVICE when calling IoCreateDevice in my
>bus driver, however, it did not work. How can I do that? Anything
>additional need to be performed in miniport or bus driver?
> Any advice will be great appreciated.
>
> _________________________________________________________________
> Is your PC infected? Get a FREE online computer virus scan from McAfee®
> Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@tfb.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
One more thing.
It is also a good idea to catch your SCSIOP_WRITE commands and fail them
with a write protect error too.
Jamey
----- Original Message -----
From: “Jamey Kirby”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, February 23, 2005 9:26 AM
Subject: Re: [ntdev] How can I set virtual scsi disk read-only?
> You must return the removable flag set in the INQUIRY data. The OS disk
> drivers will handle the rest.
>
> Jamey
>
> ----- Original Message -----
> From: “paul chen”
> To: “Windows System Software Devs Interest List”
> Sent: Wednesday, February 23, 2005 1:52 AM
> Subject: [ntdev] How can I set virtual scsi disk read-only?
>
>
>>I had tried to set FILE_READ_ONLY_DEVICE when calling IoCreateDevice in
>>my bus driver, however, it did not work. How can I do that? Anything
>>additional need to be performed in miniport or bus driver?
>> Any advice will be great appreciated.
>>
>> _________________________________________________________________
>> Is your PC infected? Get a FREE online computer virus scan from McAfee®
>> Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>>
>>
>> —
>> Questions? First check the Kernel Driver FAQ at
>> http://www.osronline.com/article.cfm?id=256
>>
>> You are currently subscribed to ntdev as: xxxxx@tfb.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@tfb.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
I set the bit MODE_DSP_WRITE_PROTECT in DeviceSpecificParameter field of
MODE_PARAMETER_HEADER structure, as the result, the virtual disk is
readonly now, however, it can not be mounted since scsi failed to send one
write request when mounting. Why it needs to write before the disk is
mounted? Does it necessary, if not, how can I bypass it?
Thanks.
Paul
Express yourself instantly with MSN Messenger! Download today - it’s FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
Paul,
Have you changed the bit in both SCSIOP_MODE_SENSE and SCSIOP_MODE_SENSE10
opcode handlers?
What is your test OS by the way?
Best regards,
Valeriy Glushkov
I set the bit MODE_DSP_WRITE_PROTECT in DeviceSpecificParameter field of
MODE_PARAMETER_HEADER structure, as the result, the virtual disk is
readonly now, however, it can not be mounted since scsi failed to send one
write request when mounting. Why it needs to write before the disk is
mounted? Does it necessary, if not, how can I bypass it?
Thanks.
Paul
hi, Valeriy
I have changed the bit in both SCSIOP_MODE_SENSE and SCSIOP_MODE_SENSE10
opcode handlers. It works anyway. The problem is system sent one write
request before user writes something. Because of the changed bit, the write
request failed and I cannot open the disk, system shows a dialog, it read
“Write protected.” Hope I have said it clear. Thank you anyway.
The test os is win2k.
Paul
Express yourself instantly with MSN Messenger! Download today - it’s FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
Hi Paul,
I suspect there is a NTFS volume on the disk?
As I said before the approach doesn’t work for NTFS partitions under Win2k
because the NTFS implementation in xxxxx@K doesn’t support read-only devices.
The simplest but a bit ugly work around for the case is to check if the disk
partition is NTFS and
the OS is Win2k and don’t set MODE_DSP_WRITE_PROTECT but instead reply to
all the WRITE requests with a success code without any real command
execution.
Of cause, if the user try to save something to the partition a system error
message appears that the disk is corrupted, etc.
The other way is to use a ‘bit bucket’ and save all written data to it and
return the changed blocks to the caller if it requests them back.
Best regards,
Valeriy Glushkov
hi, Valeriy
I have changed the bit in both SCSIOP_MODE_SENSE and SCSIOP_MODE_SENSE10
opcode handlers. It works anyway. The problem is system sent one write
request before user writes something. Because of the changed bit, the
write
request failed and I cannot open the disk, system shows a dialog, it read
“Write protected.” Hope I have said it clear. Thank you anyway.
The test os is win2k.
Paul
I think the only reliable way of solving your problem is having some
background write cache. So you’ll have constant write disabled disk storage
and you’ll allow writes to your “read-only” disk, but you’d keep then in
memory or in a separate container file and discard them on volume unmount.
With reasonable disk sizes this approach would work with any file system and
any OS (if you have device emulation code embedded not to system-dependent
storage driver but into f.e. iSCSI target code). Mocking SCSI sense
responses would fail at least 2000 NTFS (as was already pointed by Valery).
Regards,
Anton Kolomyeytsev
CEO, Rocket Division Software
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of paul chen
Sent: Thursday, February 24, 2005 11:12 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] How can I set virtual scsi disk read-only?
I set the bit MODE_DSP_WRITE_PROTECT in DeviceSpecificParameter field of
MODE_PARAMETER_HEADER structure, as the result, the virtual disk is
readonly now, however, it can not be mounted since scsi failed to send one
write request when mounting. Why it needs to write before the disk is
mounted? Does it necessary, if not, how can I bypass it?
Thanks.
Paul
Express yourself instantly with MSN Messenger! Download today - it’s FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@cooldev.com To unsubscribe
send a blank email to xxxxx@lists.osr.com
hi, Valeriy
You are right. It is NTFS and Win2k. When I reformatted it into FAT32, it
works. As you said, how can I check if the partition is NTFS and the OS is
Win2k? Under such condition, I just return true without executing anything.
" if the user try to save something to the partition a system error
message appears that the disk is corrupted, etc." Where can I do that?
Write10 Handler?
Thanks a lot.
paul
Don’t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
hi, Anton
What is the difference between keeping them in memory or in a separate
container file then discard them on volume unmount and return true without
executing anything?
Thanks.
Paul
Express yourself instantly with MSN Messenger! Download today - it’s FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
Set the MODE_DSP_WRITE_PROTECT (0x80) bit in Device Specific Parameters in
your response to MODE SENSE.
You must also fail all writes to your device with proper sense info of
“write protected”.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “paul chen”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, February 23, 2005 12:52 PM
Subject: [ntdev] How can I set virtual scsi disk read-only?
> I had tried to set FILE_READ_ONLY_DEVICE when calling IoCreateDevice in my
> bus driver, however, it did not work. How can I do that? Anything
> additional need to be performed in miniport or bus driver?
> Any advice will be great appreciated.
>
> _________________________________________________________________
> Is your PC infected? Get a FREE online computer virus scan from McAfee®
> Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
Yes, “removable media” flag is really in INQUIRY data, while “write
protect” flag is in mode sense info.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “Jamey Kirby”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, February 23, 2005 8:30 PM
Subject: Re: [ntdev] How can I set virtual scsi disk read-only?
> I did not mean to say removable; I do not know where my head was for a
> second… I mis-read the post.
>
> You need to the proper MODE_SENSE requests. I recommend reading the SCSI
> specification. I do not remember the page right off hand.
>
> Jamey
>
>
>
>
> ----- Original Message -----
> From: “paul chen”
> To: “Windows System Software Devs Interest List”
> Sent: Wednesday, February 23, 2005 1:52 AM
> Subject: [ntdev] How can I set virtual scsi disk read-only?
>
>
> >I had tried to set FILE_READ_ONLY_DEVICE when calling IoCreateDevice in my
> >bus driver, however, it did not work. How can I do that? Anything
> >additional need to be performed in miniport or bus driver?
> > Any advice will be great appreciated.
> >
> > _________________________________________________________________
> > Is your PC infected? Get a FREE online computer virus scan from McAfee®
> > Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@tfb.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
In some Windows versions - I think all pre-XP ones - NTFS cannot mount on
read-only disk.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “paul chen”
To: “Windows System Software Devs Interest List”
Sent: Thursday, February 24, 2005 12:12 PM
Subject: Re:[ntdev] How can I set virtual scsi disk read-only?
> I set the bit MODE_DSP_WRITE_PROTECT in DeviceSpecificParameter field of
> MODE_PARAMETER_HEADER structure, as the result, the virtual disk is
> readonly now, however, it can not be mounted since scsi failed to send one
> write request when mounting. Why it needs to write before the disk is
> mounted? Does it necessary, if not, how can I bypass it?
>
> Thanks.
>
>
> Paul
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today - it’s FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
Maxim is quite correct but a bit limited. I believe - but I am not certain
- that no non-removable media can be made write protected in pre-XP Windows.
What we do in our product is *tell* the user not to attempt to write to the
mounted disk. We then cache all writes to the disk. After the cache is
exhausted we start failing the writes to the disk.
This is the best (bad) solution we have come up with.
Ralph Shnelvar
On Fri, 25 Feb 2005 23:07:39 +0300, you wrote:
In some Windows versions - I think all pre-XP ones - NTFS cannot mount on
read-only disk.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “paul chen”
>To: “Windows System Software Devs Interest List”
>Sent: Thursday, February 24, 2005 12:12 PM
>Subject: Re:[ntdev] How can I set virtual scsi disk read-only?
>
>
>> I set the bit MODE_DSP_WRITE_PROTECT in DeviceSpecificParameter field of
>> MODE_PARAMETER_HEADER structure, as the result, the virtual disk is
>> readonly now, however, it can not be mounted since scsi failed to send one
>> write request when mounting. Why it needs to write before the disk is
>> mounted? Does it necessary, if not, how can I bypass it?
>>
>> Thanks.
>>
>>
>> Paul
>>
>> _________________________________________________________________
>> Express yourself instantly with MSN Messenger! Download today - it’s FREE!
>> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>>
>>
>> —
>> Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
>>
>> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>—
>Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@dos32.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com