Cancel Defrag

Hello all,

I am making a filter driver in Win2k .
I have dispatch routines of CREATE, WRITE, SET_INFORMATION and
DIRECTORY_CONTROL .

I want to stop the user to Defrag the system . I do not want to crash
the system , but some thing like cancel the request with no harm done to
any one.

Can some body help me - give Ideas as what to trap and what to cancel ?

regards
Anurag

As usual in this forum, it’s a question of “Why would you want to do this”
or “What are you tryng to achieve by doing this”…

There may be ways to stop this, but the risk is that you also affect other
applications which have much better reasons for existance than DeFrag (such
as disk repair software, or backup software).


Mats

xxxxx@lists.osr.com wrote on 10/13/2004 04:53:08 PM:

Hello all,

I am making a filter driver in Win2k .
I have dispatch routines of CREATE, WRITE, SET_INFORMATION and
DIRECTORY_CONTROL .

I want to stop the user to Defrag the system . I do not want to crash
the system , but some thing like cancel the request with no harm done to
any one.

Can some body help me - give Ideas as what to trap and what to cancel ?

regards
Anurag


Questions? First check the Kernel Driver FAQ at http://www.
osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

ForwardSourceID:NT000054FA

This might work for you:

When you get IRP_MJ_FILE_SYSTEM_CONTROL /
FSCTL_LOCK_VOLUME, complete with a
STATUS_ACCESS_DENIED.

Of course, other things that need to lock the volume
won’t work either…

— Anurag Sarin wrote:

>
> Hello all,
>
> I am making a filter driver in Win2k .
> I have dispatch routines of CREATE, WRITE,
> SET_INFORMATION and
> DIRECTORY_CONTROL .
>
> I want to stop the user to Defrag the system . I do
> not want to crash
> the system , but some thing like cancel the request
> with no harm done to
> any one.
>
> Can some body help me - give Ideas as what to trap
> and what to cancel ?
>
> regards
> Anurag
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown
> lmsubst tag argument: ‘’
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>

_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

For example, you’ll never be able to cleanly dismount a file system if
you do this (since most code that dismounts locks the file system then
does the dismount).

You also probably won’t stop defrag, since a defragger can use the
fsctls to get and set the on-disk extents of a file without locking the
volume.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Randy Cook
Sent: Wednesday, October 13, 2004 9:04 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Cancel Defrag

This might work for you:

When you get IRP_MJ_FILE_SYSTEM_CONTROL / FSCTL_LOCK_VOLUME,
complete with a STATUS_ACCESS_DENIED.

Of course, other things that need to lock the volume won’t
work either…

— Anurag Sarin wrote:
>
> >
> > Hello all,
> >
> > I am making a filter driver in Win2k .
> > I have dispatch routines of CREATE, WRITE, SET_INFORMATION and
> > DIRECTORY_CONTROL .
> >
> > I want to stop the user to Defrag the system . I do not
> want to crash
> > the system , but some thing like cancel the request with no
> harm done
> > to any one.
> >
> > Can some body help me - give Ideas as what to trap and what
> to cancel
> > ?
> >
> > regards
> > Anurag
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: unknown lmsubst tag
> > argument: ‘’
> > To unsubscribe send a blank email to
> > xxxxx@lists.osr.com
> >
>
>
>
>
> _______________________________
> Do you Yahoo!?
> Declare Yourself - Register online to vote today!
> http://vote.yahoo.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@windows.microsoft.com To unsubscribe send a blank
> email to xxxxx@lists.osr.com
>

The ‘defragging apis’ are documented in the SDK. Just trace through their
execution and figure out which FSCTL operations are unique to defragging and
reject them. Then reflect on the other responders who are wondering why you
are doing this and what adverse effects this will have.

=====================
Mark Roddy

-----Original Message-----
From: Randy Cook [mailto:xxxxx@yahoo.com]
Sent: Wednesday, October 13, 2004 12:04 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Cancel Defrag

This might work for you:

When you get IRP_MJ_FILE_SYSTEM_CONTROL / FSCTL_LOCK_VOLUME, complete with a
STATUS_ACCESS_DENIED.

Of course, other things that need to lock the volume won’t work either…

— Anurag Sarin wrote:

>
> Hello all,
>
> I am making a filter driver in Win2k .
> I have dispatch routines of CREATE, WRITE, SET_INFORMATION and
> DIRECTORY_CONTROL .
>
> I want to stop the user to Defrag the system . I do not want to crash
> the system , but some thing like cancel the request with no harm done
> to any one.
>
> Can some body help me - give Ideas as what to trap and what to cancel
> ?
>
> regards
> Anurag
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
> argument: ‘’
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>

_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.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@stratus.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

“Why would you want to do this” or “What are you tryng to achieve by
doing this”…

Well doing this leads to more security flaws which I don’t want to go
deep into . But want a solution to be harmless but stops the user from
defrag or looks like defrag is going on but nothing actually happens is
even better :slight_smile:

anurag
-----Original Message-----
From: Mats PETERSSON [mailto:xxxxx@3dlabs.com]
Sent: Wednesday, October 13, 2004 9:29 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Cancel Defrag

As usual in this forum, it’s a question of “Why would you want to do
this” or “What are you tryng to achieve by doing this”…

There may be ways to stop this, but the risk is that you also affect
other applications which have much better reasons for existance than
DeFrag (such as disk repair software, or backup software).


Mats

xxxxx@lists.osr.com wrote on 10/13/2004 04:53:08 PM:

Hello all,

I am making a filter driver in Win2k .
I have dispatch routines of CREATE, WRITE, SET_INFORMATION and
DIRECTORY_CONTROL .

I want to stop the user to Defrag the system . I do not want to crash
the system , but some thing like cancel the request with no harm done
to any one.

Can some body help me - give Ideas as what to trap and what to cancel
?

regards
Anurag


Questions? First check the Kernel Driver FAQ at http://www.
osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

ForwardSourceID:NT000054FA


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

How about you setup your security properly so that normal users can’t
run defrag?

-Jeff

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Anurag Sarin
Sent: Wednesday, October 13, 2004 12:30 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Cancel Defrag

“Why would you want to do this” or “What are you tryng to achieve by
doing this”…

Well doing this leads to more security flaws which I don’t want to go
deep into . But want a solution to be harmless but stops the user from
defrag or looks like defrag is going on but nothing actually happens is
even better :slight_smile:

anurag
-----Original Message-----
From: Mats PETERSSON [mailto:xxxxx@3dlabs.com]
Sent: Wednesday, October 13, 2004 9:29 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Cancel Defrag

As usual in this forum, it’s a question of “Why would you want to do
this” or “What are you tryng to achieve by doing this”…

There may be ways to stop this, but the risk is that you also affect
other applications which have much better reasons for existance than
DeFrag (such as disk repair software, or backup software).


Mats

xxxxx@lists.osr.com wrote on 10/13/2004 04:53:08 PM:

Hello all,

I am making a filter driver in Win2k .
I have dispatch routines of CREATE, WRITE, SET_INFORMATION and
DIRECTORY_CONTROL .

I want to stop the user to Defrag the system . I do not want to crash
the system , but some thing like cancel the request with no harm done
to any one.

Can some body help me - give Ideas as what to trap and what to cancel
?

regards
Anurag


Questions? First check the Kernel Driver FAQ at http://www.
osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

ForwardSourceID:NT000054FA


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@divassoftware.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: unknown lmsubst tag argument:
‘’ To unsubscribe send a blank email to xxxxx@lists.osr.com

***********************************************************************************
This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secured or error-free as information could be intercepted, corrupted, lost, destroyed, received late or incomplete, or could contain viruses. The sender therefore does not accept liability for any error or omission in the contents of this message, which arises as a result of e-mail transmission. If verification is required, please request a hard-copy version from the sender.
***********************************************************************************

Catch and fail FSCTL_MOVE_FILE.

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

----- Original Message -----
From: “Anurag Sarin”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, October 13, 2004 7:53 PM
Subject: [ntdev] Cancel Defrag

>
> Hello all,
>
> I am making a filter driver in Win2k .
> I have dispatch routines of CREATE, WRITE, SET_INFORMATION and
> DIRECTORY_CONTROL .
>
> I want to stop the user to Defrag the system . I do not want to crash
> the system , but some thing like cancel the request with no harm done to
> any one.
>
> Can some body help me - give Ideas as what to trap and what to cancel ?
>
> regards
> Anurag
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

We have a snapshot driver that we need to prevent defragmenting the real
disk while a snapshot is active. Although it does work with a snapshot
active, it uses lots of system resources to manage the copied blocks and the
indexes when huge amounts of data are being moved around on the disk.

Just one example of why one might want to disable the defrag APIs.

I will check our code to see how we do it; unless Max has already answered
:slight_smile:

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mats PETERSSON
Sent: Wednesday, October 13, 2004 8:59 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Cancel Defrag

As usual in this forum, it’s a question of “Why would you want to do this”
or “What are you tryng to achieve by doing this”…

There may be ways to stop this, but the risk is that you also affect other
applications which have much better reasons for existance than DeFrag (such
as disk repair software, or backup software).


Mats

xxxxx@lists.osr.com wrote on 10/13/2004 04:53:08 PM:

Hello all,

I am making a filter driver in Win2k .
I have dispatch routines of CREATE, WRITE, SET_INFORMATION and
DIRECTORY_CONTROL .

I want to stop the user to Defrag the system . I do not want to crash
the system , but some thing like cancel the request with no harm done to
any one.

Can some body help me - give Ideas as what to trap and what to cancel ?

regards
Anurag


Questions? First check the Kernel Driver FAQ at http://www.
osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

ForwardSourceID:NT000054FA


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

__________ NOD32 1.860 (20040903) Information __________

This message was checked by NOD32 antivirus system.
http://www.nod32.com

:slight_smile:

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Wednesday, October 13, 2004 10:37 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Cancel Defrag

Catch and fail FSCTL_MOVE_FILE.

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

----- Original Message -----
From: “Anurag Sarin”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, October 13, 2004 7:53 PM
Subject: [ntdev] Cancel Defrag

>
> Hello all,
>
> I am making a filter driver in Win2k .
> I have dispatch routines of CREATE, WRITE, SET_INFORMATION and
> DIRECTORY_CONTROL .
>
> I want to stop the user to Defrag the system . I do not want to crash
> the system , but some thing like cancel the request with no harm done to
> any one.
>
> Can some body help me - give Ideas as what to trap and what to cancel ?
>
> regards
> Anurag
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
> 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

NOD32 1.860 (20040903) Information

This message was checked by NOD32 antivirus system.
http://www.nod32.com

I’m no way familiar with file system drivers but… if defrag locks the
drive to get exclusive access to it, then why isn’t it sufficient for an
application or driver that wants to take a snapshot to lock the drive in the
same fashion, thus preventing anyone else (including defrag) to perform a
lock? This might be completely stupid but I’m curious.

Mat

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jamey Kirby
Sent: Wednesday, October 13, 2004 8:55 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Cancel Defrag

We have a snapshot driver that we need to prevent defragmenting the real
disk while a snapshot is active. Although it does work with a snapshot
active, it uses lots of system resources to manage the copied blocks and the
indexes when huge amounts of data are being moved around on the disk.

Just one example of why one might want to disable the defrag APIs.

I will check our code to see how we do it; unless Max has already answered
:slight_smile:

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mats PETERSSON
Sent: Wednesday, October 13, 2004 8:59 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Cancel Defrag

As usual in this forum, it’s a question of “Why would you want to do this”
or “What are you tryng to achieve by doing this”…

There may be ways to stop this, but the risk is that you also affect other
applications which have much better reasons for existance than DeFrag (such
as disk repair software, or backup software).


Mats

xxxxx@lists.osr.com wrote on 10/13/2004 04:53:08 PM:

Hello all,

I am making a filter driver in Win2k .
I have dispatch routines of CREATE, WRITE, SET_INFORMATION and
DIRECTORY_CONTROL .

I want to stop the user to Defrag the system . I do not want to crash
the system , but some thing like cancel the request with no harm done to
any one.

Can some body help me - give Ideas as what to trap and what to cancel ?

regards
Anurag


Questions? First check the Kernel Driver FAQ at http://www.
osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

ForwardSourceID:NT000054FA


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

__________ NOD32 1.860 (20040903) Information __________

This message was checked by NOD32 antivirus system.
http://www.nod32.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@encentrus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Lock will fail if there are open files.
And the whole purpose of snapshotting is to be appliable to a volume with
open files.

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

----- Original Message -----
From: “Mathieu Routhier”
To: “Windows System Software Devs Interest List”
Sent: Thursday, October 14, 2004 5:36 PM
Subject: RE: [ntdev] Cancel Defrag

> I’m no way familiar with file system drivers but… if defrag locks the
> drive to get exclusive access to it, then why isn’t it sufficient for an
> application or driver that wants to take a snapshot to lock the drive in the
> same fashion, thus preventing anyone else (including defrag) to perform a
> lock? This might be completely stupid but I’m curious.
>
> Mat
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Jamey Kirby
> Sent: Wednesday, October 13, 2004 8:55 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] Cancel Defrag
>
> We have a snapshot driver that we need to prevent defragmenting the real
> disk while a snapshot is active. Although it does work with a snapshot
> active, it uses lots of system resources to manage the copied blocks and the
> indexes when huge amounts of data are being moved around on the disk.
>
> Just one example of why one might want to disable the defrag APIs.
>
> I will check our code to see how we do it; unless Max has already answered
> :slight_smile:
>
> Jamey
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Mats PETERSSON
> Sent: Wednesday, October 13, 2004 8:59 AM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] Cancel Defrag
>
>
>
>
>
>
> As usual in this forum, it’s a question of “Why would you want to do this”
> or “What are you tryng to achieve by doing this”…
>
> There may be ways to stop this, but the risk is that you also affect other
> applications which have much better reasons for existance than DeFrag (such
> as disk repair software, or backup software).
>
> –
> Mats
>
> xxxxx@lists.osr.com wrote on 10/13/2004 04:53:08 PM:
>
> >
> > Hello all,
> >
> > I am making a filter driver in Win2k .
> > I have dispatch routines of CREATE, WRITE, SET_INFORMATION and
> > DIRECTORY_CONTROL .
> >
> > I want to stop the user to Defrag the system . I do not want to crash
> > the system , but some thing like cancel the request with no harm done to
> > any one.
> >
> > Can some body help me - give Ideas as what to trap and what to cancel ?
> >
> > regards
> > Anurag
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at http://www.
> > osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: unknown lmsubst tag argument:
> ‘’
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> > ForwardSourceID:NT000054FA
>
>
>
> —
> 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
>
> NOD32 1.860 (20040903) Information
>
> This message was checked by NOD32 antivirus system.
> http://www.nod32.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@encentrus.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

Also Mat, I understand that with the defragging API these days it’s not
necessary to lock a volume while it is being defragmented. In fact,
even files opened for writing may be defragmented!

Chuck

----- Original Message -----
From: “Maxim S. Shatskih”
To: “Windows System Software Devs Interest List”
Sent: Friday, October 15, 2004 4:28 AM
Subject: Re: [ntdev] Cancel Defrag

> Lock will fail if there are open files.
> And the whole purpose of snapshotting is to be appliable to a
> volume with
> open files.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> ----- Original Message -----
> From: “Mathieu Routhier”
> To: “Windows System Software Devs Interest List”
> Sent: Thursday, October 14, 2004 5:36 PM
> Subject: RE: [ntdev] Cancel Defrag
>
>
>> I’m no way familiar with file system drivers but… if defrag locks
>> the
>> drive to get exclusive access to it, then why isn’t it sufficient for
>> an
>> application or driver that wants to take a snapshot to lock the drive
>> in the
>> same fashion, thus preventing anyone else (including defrag) to
>> perform a
>> lock? This might be completely stupid but I’m curious.
>>
>> Mat

Yes. Fail FSCTL_MOVE_FILE to fail defrag.

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

----- Original Message -----
From: “Chuck Batson”
To: “Windows System Software Devs Interest List”
Sent: Friday, October 15, 2004 9:07 AM
Subject: Re: [ntdev] Cancel Defrag

> Also Mat, I understand that with the defragging API these days it’s not
> necessary to lock a volume while it is being defragmented. In fact,
> even files opened for writing may be defragmented!
>
> Chuck
>
> ----- Original Message -----
> From: “Maxim S. Shatskih”
> To: “Windows System Software Devs Interest List”
> Sent: Friday, October 15, 2004 4:28 AM
> Subject: Re: [ntdev] Cancel Defrag
>
>
> > Lock will fail if there are open files.
> > And the whole purpose of snapshotting is to be appliable to a
> > volume with
> > open files.
> >
> > Maxim Shatskih, Windows DDK MVP
> > StorageCraft Corporation
> > xxxxx@storagecraft.com
> > http://www.storagecraft.com
> >
> > ----- Original Message -----
> > From: “Mathieu Routhier”
> > To: “Windows System Software Devs Interest List”
> > Sent: Thursday, October 14, 2004 5:36 PM
> > Subject: RE: [ntdev] Cancel Defrag
> >
> >
> >> I’m no way familiar with file system drivers but… if defrag locks
> >> the
> >> drive to get exclusive access to it, then why isn’t it sufficient for
> >> an
> >> application or driver that wants to take a snapshot to lock the drive
> >> in the
> >> same fashion, thus preventing anyone else (including defrag) to
> >> perform a
> >> lock? This might be completely stupid but I’m curious.
> >>
> >> Mat
>
>
>
> —
> 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

Hey Maxim,

Sorry for my naitive question.
How do I fail it best?? - status STATUS_ACCESS_DENIED??? .
Is following code OK??? .
I am not able to see the difference doing this.

switch (pIrpSp->MinorFunction)
{

case IRP_MN_USER_FS_REQUEST:
{
switch (pIrpSp->Parameters.FileSystemControl.FsControlCode)
{
case FSCTL_MOVE_FILE:
{
DbgPrint(“\nFC:FSCTL_MOVE_FILE Trapped”);
Irp->IoStatus.Status = STATUS_ACCESS_DENIED;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_ACCESS_DENIED;
}
break;
}
}

}

anurag

-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Thursday, October 21, 2004 12:12 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Cancel Defrag

Yes. Fail FSCTL_MOVE_FILE to fail defrag.

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

----- Original Message -----
From: “Chuck Batson”
To: “Windows System Software Devs Interest List”
Sent: Friday, October 15, 2004 9:07 AM
Subject: Re: [ntdev] Cancel Defrag

> Also Mat, I understand that with the defragging API these days it’s
> not necessary to lock a volume while it is being defragmented. In
> fact, even files opened for writing may be defragmented!
>
> Chuck
>
> ----- Original Message -----
> From: “Maxim S. Shatskih”
> To: “Windows System Software Devs Interest List”
> Sent: Friday, October 15, 2004 4:28 AM
> Subject: Re: [ntdev] Cancel Defrag
>
>
> > Lock will fail if there are open files.
> > And the whole purpose of snapshotting is to be appliable to a
> > volume with open files.
> >
> > Maxim Shatskih, Windows DDK MVP
> > StorageCraft Corporation
> > xxxxx@storagecraft.com
> > http://www.storagecraft.com
> >
> > ----- Original Message -----
> > From: “Mathieu Routhier”
> > To: “Windows System Software Devs Interest List”

> > Sent: Thursday, October 14, 2004 5:36 PM
> > Subject: RE: [ntdev] Cancel Defrag
> >
> >
> >> I’m no way familiar with file system drivers but… if defrag
> >> locks the drive to get exclusive access to it, then why isn’t it
> >> sufficient for an
> >> application or driver that wants to take a snapshot to lock the
drive
> >> in the
> >> same fashion, thus preventing anyone else (including defrag) to
> >> perform a
> >> lock? This might be completely stupid but I’m curious.
> >>
> >> Mat
>
>
>
> —
> 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@divassoftware.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

This is the way we do it and it seems to work perfectly:

case FSCTL_MOVE_FILE:
// Disable defragger if the disk is snapped
if( !somecondition )
{
// Fail the operation
KdPrint(("Failing defrag of the
“volume\r\n”));
Irp->IoStatus.Status = Status = STATUS_INVALID_DEVICE_STATE;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Anurag Sarin
Sent: Monday, October 25, 2004 5:31 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Cancel Defrag

Hey Maxim,

Sorry for my naitive question.
How do I fail it best?? - status STATUS_ACCESS_DENIED??? .
Is following code OK??? .
I am not able to see the difference doing this.

switch (pIrpSp->MinorFunction)
{

case IRP_MN_USER_FS_REQUEST:
{
switch (pIrpSp->Parameters.FileSystemControl.FsControlCode)
{
case FSCTL_MOVE_FILE:
{
DbgPrint(“\nFC:FSCTL_MOVE_FILE Trapped”);
Irp->IoStatus.Status = STATUS_ACCESS_DENIED;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_ACCESS_DENIED;
}
break;
}
}

}

anurag

-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Thursday, October 21, 2004 12:12 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Cancel Defrag

Yes. Fail FSCTL_MOVE_FILE to fail defrag.

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

----- Original Message -----
From: “Chuck Batson”
To: “Windows System Software Devs Interest List”
Sent: Friday, October 15, 2004 9:07 AM
Subject: Re: [ntdev] Cancel Defrag

> Also Mat, I understand that with the defragging API these days it’s
> not necessary to lock a volume while it is being defragmented. In
> fact, even files opened for writing may be defragmented!
>
> Chuck
>
> ----- Original Message -----
> From: “Maxim S. Shatskih”
> To: “Windows System Software Devs Interest List”
> Sent: Friday, October 15, 2004 4:28 AM
> Subject: Re: [ntdev] Cancel Defrag
>
>
> > Lock will fail if there are open files.
> > And the whole purpose of snapshotting is to be appliable to a
> > volume with open files.
> >
> > Maxim Shatskih, Windows DDK MVP
> > StorageCraft Corporation
> > xxxxx@storagecraft.com
> > http://www.storagecraft.com
> >
> > ----- Original Message -----
> > From: “Mathieu Routhier”
> > To: “Windows System Software Devs Interest List”

> > Sent: Thursday, October 14, 2004 5:36 PM
> > Subject: RE: [ntdev] Cancel Defrag
> >
> >
> >> I’m no way familiar with file system drivers but… if defrag
> >> locks the drive to get exclusive access to it, then why isn’t it
> >> sufficient for an
> >> application or driver that wants to take a snapshot to lock the
drive
> >> in the
> >> same fashion, thus preventing anyone else (including defrag) to
> >> perform a
> >> lock? This might be completely stupid but I’m curious.
> >>
> >> Mat
>
>
>
> —
> 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@divassoftware.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: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Why not? This worked for me.

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

----- Original Message -----
From: “Anurag Sarin”
To: “Windows System Software Devs Interest List”
Sent: Monday, October 25, 2004 4:30 PM
Subject: RE: [ntdev] Cancel Defrag

> Hey Maxim,
>
> Sorry for my naitive question.
> How do I fail it best?? - status STATUS_ACCESS_DENIED??? .
> Is following code OK??? .
> I am not able to see the difference doing this.
>
>
> switch (pIrpSp->MinorFunction)
> {
>
> case IRP_MN_USER_FS_REQUEST:
> {
> switch (pIrpSp->Parameters.FileSystemControl.FsControlCode)
> {
> case FSCTL_MOVE_FILE:
> {
> DbgPrint(“\nFC:FSCTL_MOVE_FILE Trapped”);
> Irp->IoStatus.Status = STATUS_ACCESS_DENIED;
> Irp->IoStatus.Information = 0;
> IoCompleteRequest(Irp, IO_NO_INCREMENT);
> return STATUS_ACCESS_DENIED;
> }
> break;
> }
> }
>
> }
>
> anurag
>
>
>
>
> -----Original Message-----
> From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
> Sent: Thursday, October 21, 2004 12:12 AM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] Cancel Defrag
>
>
> Yes. Fail FSCTL_MOVE_FILE to fail defrag.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> ----- Original Message -----
> From: “Chuck Batson”
> To: “Windows System Software Devs Interest List”
> Sent: Friday, October 15, 2004 9:07 AM
> Subject: Re: [ntdev] Cancel Defrag
>
>
> > Also Mat, I understand that with the defragging API these days it’s
> > not necessary to lock a volume while it is being defragmented. In
> > fact, even files opened for writing may be defragmented!
> >
> > Chuck
> >
> > ----- Original Message -----
> > From: “Maxim S. Shatskih”
> > To: “Windows System Software Devs Interest List”
> > Sent: Friday, October 15, 2004 4:28 AM
> > Subject: Re: [ntdev] Cancel Defrag
> >
> >
> > > Lock will fail if there are open files.
> > > And the whole purpose of snapshotting is to be appliable to a
> > > volume with open files.
> > >
> > > Maxim Shatskih, Windows DDK MVP
> > > StorageCraft Corporation
> > > xxxxx@storagecraft.com
> > > http://www.storagecraft.com
> > >
> > > ----- Original Message -----
> > > From: “Mathieu Routhier”
> > > To: “Windows System Software Devs Interest List”
>
> > > Sent: Thursday, October 14, 2004 5:36 PM
> > > Subject: RE: [ntdev] Cancel Defrag
> > >
> > >
> > >> I’m no way familiar with file system drivers but… if defrag
> > >> locks the drive to get exclusive access to it, then why isn’t it
> > >> sufficient for an
> > >> application or driver that wants to take a snapshot to lock the
> drive
> > >> in the
> > >> same fashion, thus preventing anyone else (including defrag) to
> > >> perform a
> > >> lock? This might be completely stupid but I’m curious.
> > >>
> > >> Mat
> >
> >
> >
> > —
> > 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@divassoftware.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: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>