Correct method to lock a volume before format operation

Before calling into my file system to initiate a logical format operation
I lock the volume exclusive with the call:

CreateFile(vol,GENERIC_WRITE|GENERIC_READ|DELETE, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);

I noticed that a “Limited User” on Windows XP will not have sufficient
rights to complete this request, hence the format request will fail.

Is this the correct locking method or are there better (less restrictive)
parameters? (Also, I noticed that a “Limited User” cannot format a hard
drive but can format a floppy drive.)

Thanks.

The correct way to prepare a volume for format is to send down
FSCTL_LOCK_VOLUME followed by FSCTL_DISMOUNT_VOLUME. See the MSDN page
on FSCTL_DISMOUNT_VOLUME.

Fred Walters wrote:

Before calling into my file system to initiate a logical format operation
I lock the volume exclusive with the call:

CreateFile(vol,GENERIC_WRITE|GENERIC_READ|DELETE, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);

I noticed that a “Limited User” on Windows XP will not have sufficient
rights to complete this request, hence the format request will fail.

Is this the correct locking method or are there better (less restrictive)
parameters? (Also, I noticed that a “Limited User” cannot format a hard
drive but can format a floppy drive.)

Thanks.


You are currently subscribed to ntfsd as: xxxxx@nryan.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

  • Nick Ryan (MVP for DDK)

Yes, I do issue an FSCTL_LOCK_VOLUME after I call CreateFile(). The
CreateFile() is required to get a handle to issue the FSCTL_LOCK_VOLUME.

My problem is the CreateFile() function fails with status
ERROR_ACCESS_DENIED (5). The Ioctl never enters my file system. The OS
seems to think that a ‘limited user’ does not have right to open a volume.
This works okay for users with Administrator rights.

Any ideas? Thanks!

Umm, that’s correct. Only administrators are allowed to open volume
handles. This is a good thing.

Fred Walters wrote:

Yes, I do issue an FSCTL_LOCK_VOLUME after I call CreateFile(). The
CreateFile() is required to get a handle to issue the FSCTL_LOCK_VOLUME.

My problem is the CreateFile() function fails with status
ERROR_ACCESS_DENIED (5). The Ioctl never enters my file system. The OS
seems to think that a ‘limited user’ does not have right to open a volume.
This works okay for users with Administrator rights.

Any ideas? Thanks!


You are currently subscribed to ntfsd as: xxxxx@nryan.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

  • Nick Ryan (MVP for DDK)

But, a ‘limited user’ can format a floppy disc. hmmm.

I assume that I can programmatically give a ‘limited user’ the rights to
open a volume handle via the function AdjustTokenPrivileges() but I
haven’t found any documentation for those specific rights.

Does anybody use this function to support their format?

Thanks!

You really don’t want to use a privilege for this that allows the user
process to format any volume in the system. Seems to me that you might
need an ioctl that takes the lock using kernel privilege.

-----Original Message-----
From: Fred Walters [mailto:xxxxx@charter.net]
Sent: Thursday, July 24, 2003 1:12 PM
To: File Systems Developers
Subject: [ntfsd] Re: Correct method to lock a volume before format
operation

But, a ‘limited user’ can format a floppy disc. hmmm.

I assume that I can programmatically give a ‘limited user’ the rights to
open a volume handle via the function AdjustTokenPrivileges() but I
haven’t found any documentation for those specific rights.

Does anybody use this function to support their format?

Thanks!


You are currently subscribed to ntfsd as: xxxxx@basistech.com To
unsubscribe send a blank email to xxxxx@lists.osr.com