Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-04

FileGetAttr fails on TrueCrypt partition

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

reynolight

g: is the XP system volume. x: is the truecrypted NTFS partition. No problem to set / get / show file attributes with Win32 GUI on both volumes. Same with attrib.exe on console.

sysutils.FileGetAttr(g:\*) is fine, as well, but FileGetAttr(x:\*) returns -1 as an error.

After copying a file from x: to g:, its attributes are - surprise - ok again. Even bigger surprise: After re-copying from g: to x:, FileGetAttr(x:\...) delivers the same correct result as on g:

Any idea?

Wolfram

Reply by email

Michael Van Canneyt
to reynolight
reynolight wrote 10 lines
g: is the XP system volume. x: is the truecrypted NTFS partition. No problem to set / get / show file attributes with Win32 GUI on both volumes. Same with attrib.exe on console. sysutils.FileGetAttr(g:\*) is fine, as well, but FileGetAttr(x:\*) returns -1 as an error. After copying a file from x: to g:, its attributes are - surprise - ok again. Even bigger surprise: After re-copying from g: to x:, FileGetAttr(x:\...) delivers the same correct result as on g:

FileGetAttr is not supposed to accept wildcards.

Michael.

Reply by email

reynolight
to Michael Van Canneyt
Michael Van Canneyt wrote 18 lines
On Wed, 20 Apr 2011, reynolight wrote: > g: is the XP system volume. x: is the truecrypted NTFS partition. No > problem to set / get / show file attributes with Win32 GUI on both > volumes. Same with attrib.exe on console. > > sysutils.FileGetAttr(g:\*) is fine, as well, but FileGetAttr(x:\*) > returns -1 as an error. > > After copying a file from x: to g:, its attributes are - surprise - ok > again. Even bigger surprise: After re-copying from g: to x:, > FileGetAttr(x:\...) delivers the same correct result as on g: FileGetAttr is not supposed to accept wildcards. Michael.

Sorry. Just looks like wildcards here in my post. Of course, FileGetAttr('*') doesn't be exact with my issue, assume a specific file x:\any.any, where x: is a mounted, truecrypted NTFS volume.

FileGetAttr('x:\any.any') returns -1, i.e. error.

After copying x:\any.any to g:\any.any, FileGetAttr('g:\any.any') returns 32, i.e. faArchive.

After copying g:\any.any back to x:\any.any, overwriting the previous version, FileGetAttr('x:\any.any') now returns 32, i.e. faArchive as well, as it should have been always, since we never modified the attributes.

Trying the same on XP GUI or with attrib.exe on console, I don't see any similar issues.

Wolfram

Reply by email

Michael Van Canneyt
to reynolight
reynolight wrote 35 lines
Am 20.04.2011 13:47, schrieb Michael Van Canneyt: > > > On Wed, 20 Apr 2011, reynolight wrote: > >> g: is the XP system volume. x: is the truecrypted NTFS partition. No >> problem to set / get / show file attributes with Win32 GUI on both >> volumes. Same with attrib.exe on console. >> >> sysutils.FileGetAttr(g:\*) is fine, as well, but FileGetAttr(x:\*) >> returns -1 as an error. >> >> After copying a file from x: to g:, its attributes are - surprise - ok >> again. Even bigger surprise: After re-copying from g: to x:, >> FileGetAttr(x:\...) delivers the same correct result as on g: > > FileGetAttr is not supposed to accept wildcards. > > Michael. Sorry. Just looks like wildcards here in my post. Of course, FileGetAttr('*') doesn't be exact with my issue, assume a specific file x:\any.any, where x: is a mounted, truecrypted NTFS volume. FileGetAttr('x:\any.any') returns -1, i.e. error. After copying x:\any.any to g:\any.any, FileGetAttr('g:\any.any') returns 32, i.e. faArchive. After copying g:\any.any back to x:\any.any, overwriting the previous version, FileGetAttr('x:\any.any') now returns 32, i.e. faArchive as well, as it should have been always, since we never modified the attributes. Trying the same on XP GUI or with attrib.exe on console, I don't see any similar issues.

Well,

This is the implementation of FileGetAttr:

Function FileGetAttr (Const FileName : String) : Longint;
begin
   Result:=GetFileAttributes(PChar(FileName));
end;

As you can see, the function returns the result of the GetFileAttributes Win32 API call. Why this call returns -1 is something that we cannot speculate on. Most likely seems an error in the filesystem driver.

Michael.

Reply by email

reynolight
to Michael Van Canneyt
Michael Van Canneyt wrote 16 lines
Well, This is the implementation of FileGetAttr: Function FileGetAttr (Const FileName : String) : Longint; begin Result:=GetFileAttributes(PChar(FileName)); end; As you can see, the function returns the result of the GetFileAttributes Win32 API call. Why this call returns -1 is something that we cannot speculate on. Most likely seems an error in the filesystem driver. Michael.

Thanks, Michael. Came to the same result.

Obscure enough, I have no problems using TSearchRec attributes via FindFirst / FindNext. Maybe I still need some additional, lonesome research and the issue is sitting in front of my monitors.

Wolfram

Reply by email

Jonas Maebe
to reynolight
reynolight wrote 8 lines
Am 20.04.2011 16:58, schrieb Michael Van Canneyt: > > As you can see, the function returns the result of the > GetFileAttributes Win32 API call. > Why this call returns -1 is something that we cannot speculate on. > Most likely seems an error in the filesystem driver. Thanks, Michael. Came to the same result.

You can try calling getlastoserror to see whether it gives a more informative reason for the failure.

Jonas

Reply by email