Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
non admin FlushFileBuffers for a volume
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jack Anderson  
View profile  
 More options Jul 18 2006, 4:35 am
Newsgroups: microsoft.public.win32.programmer.kernel, microsoft.public.platformsdk.base, microsoft.public.vc.language, microsoft.public.vc.mfc
From: Jack Anderson <s...@spam.org>
Date: Tue, 18 Jul 2006 11:35:12 +0300
Local: Tues, Jul 18 2006 4:35 am
Subject: non admin FlushFileBuffers for a volume
Hi All,

In our software we need to flush all the data on a removable device(disk
on key). The problem is that when user is non admin we can't obtain
handle to the volume using CreateFile cause of the insufficient
privileges. I'm looking for a work around to cause file/cache manager to
flush all the data.

Btw eject is not an option for us as after flushing we are doing some
operation via disk on keys firmware that cause it to show "private"
folders, if we do this without flush the data is lost on Win2k machines
where Performance check box is by default turned on on disk on keys.

Thanks in advance


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vladimir Scherbina  
View profile  
 More options Jul 18 2006, 7:53 am
Newsgroups: microsoft.public.win32.programmer.kernel, microsoft.public.platformsdk.base, microsoft.public.vc.language, microsoft.public.vc.mfc
From: "Vladimir Scherbina" <vladimir.scherbina@on_gmail_com>
Date: Tue, 18 Jul 2006 14:53:14 +0300
Local: Tues, Jul 18 2006 7:53 am
Subject: Re: non admin FlushFileBuffers for a volume
Hi Jack!

You can get a handle to volume by running under administration privileges
only. It means that you can use impersonation for performing your task.

--
Vladimir (Windows SDK MVP)

"Jack Anderson" <s...@spam.org> wrote in message

news:usaksUkqGHA.4760@TK2MSFTNGP03.phx.gbl...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jack Anderson  
View profile  
 More options Jul 18 2006, 8:07 am
Newsgroups: microsoft.public.win32.programmer.kernel, microsoft.public.platformsdk.base, microsoft.public.vc.language, microsoft.public.vc.mfc
From: Jack Anderson <s...@spam.org>
Date: Tue, 18 Jul 2006 15:07:11 +0300
Local: Tues, Jul 18 2006 8:07 am
Subject: Re: non admin FlushFileBuffers for a volume

Vladimir Scherbina wrote:
> Hi Jack!

> You can get a handle to volume by running under administration
> privileges only. It means that you can use impersonation for performing
> your task.

Thanks for your answer Vladimir,

Unfortunetly impersonation is not possible for us, its a simple client
software...

We found a "hack" which seems to be working for us, and it does flush I
would like you to give me your opinion and maybe to explain why it seems
to work, what we do is call CreateFile on a root director e.g. "C:\"
with FILE_FLAG_BACKUP_SEMANTICS flag and then call FlushFileBuffers,
this seems to go over all the "children" directories/files that were
just created and flush.

Any ideas why this works or if it might not work in certain circumstances ?

Thanks in advance


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vladimir Scherbina  
View profile  
 More options Jul 18 2006, 2:21 pm
Newsgroups: microsoft.public.win32.programmer.kernel, microsoft.public.platformsdk.base, microsoft.public.vc.language, microsoft.public.vc.mfc
From: "Vladimir Scherbina" <vladimir.scherbina@on_gmail_com>
Date: Tue, 18 Jul 2006 21:21:17 +0300
Local: Tues, Jul 18 2006 2:21 pm
Subject: Re: non admin FlushFileBuffers for a volume
"Jack Anderson" <s...@spam.org> wrote in message

news:uAFQKLmqGHA.3820@TK2MSFTNGP05.phx.gbl...

[..]

> We found a "hack" which seems to be working for us, and it does flush I
> would like you to give me your opinion and maybe to explain why it seems
> to work, what we do is call CreateFile on a root director e.g. "C:\" with
> FILE_FLAG_BACKUP_SEMANTICS flag and then call FlushFileBuffers, this seems
> to go over all the "children" directories/files that were just created and
> flush.

[..]

> Any ideas why this works ...

FILE_FLAG_BACKUP_SEMANTICS flag does all magic. From
MSDN(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/file...

"There are situations when a backup application must be able to change the
access control settings of a file or directory. An example is when the
access control settings of the disk-resident copy of a file or directory is
different from the backup copy. This would happen if these settings were
changed after the file or directory was backed up, or if it was corrupted.

The FILE_FLAG_BACKUP_SEMANTICS flag specified in the call to CreateFile
gives the backup application process permission to read the access-control
settings of the file or directory. With this permission, the backup
application process can then call GetKernelObjectSecurity and
SetKernelObjectSecurity to read and than reset the access-control settings."

Seems like mentioned above documentation applies to volumes (not only the
files). This makes contradiction with documentation written for
CreateFile(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/file...
You can use the CreateFile function to open a physical disk drive or a
volume. The function returns a handle that can be used with the
DeviceIoControl function. This enables you to access the disk partition
table. However, it is potentially dangerous to do so, because an incorrect
write to a disk could make its contents inaccessible. The following
requirements must be met for such a call to succeed:

  a.. *The caller must have administrative privileges. For more information,
see Running with Special Privileges.*
  b.. The dwCreationDisposition parameter must have the OPEN_EXISTING flag.
  c.. When opening a volume or floppy disk, the dwShareMode parameter must
have the FILE_SHARE_WRITE flag.

> ... or if it might not work in certain circumstances ?

IMO MS has two possible variants: change the documentation or change the
implementation of CreateFile...

--
Vladimir (Windows SDK MVP)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Slava M. Usov  
View profile  
 More options Jul 18 2006, 6:04 pm
Newsgroups: microsoft.public.win32.programmer.kernel, microsoft.public.platformsdk.base, microsoft.public.vc.language, microsoft.public.vc.mfc
From: "Slava M. Usov" <stripit.slo...@gmx.net>
Date: Wed, 19 Jul 2006 00:04:27 +0200
Local: Tues, Jul 18 2006 6:04 pm
Subject: Re: non admin FlushFileBuffers for a volume
"Jack Anderson" <s...@spam.org> wrote in message

news:uAFQKLmqGHA.3820@TK2MSFTNGP05.phx.gbl...

[...]

> We found a "hack" which seems to be working for us, and it does flush I
> would like you to give me your opinion and maybe to explain why it seems
> to work, what we do is call CreateFile on a root director e.g. "C:\" with
> FILE_FLAG_BACKUP_SEMANTICS flag and then call FlushFileBuffers, this seems
> to go over all the "children" directories/files that were just created and
> flush.

> Any ideas why this works or if it might not work in certain circumstances
> ?

You can open the root directory because either the file system is FAT or the
security descriptor of the root directory is liberal enough. One of these
two conditions will probably apply to the majority of removable media.

This does not explain why flushing the root directory flushes all the other
directories and files. This behaviour happens to be undocumented. However,
the FAT file system driver does indeed flush the entire volume when the root
directory is flushed.

Bottom line, if your device is formatted with FAT, your technique will
always work. If it is NTFS, not necessarily.

S


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google