EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Implementing OnGetFileNameByFileId

Posted: 10/14/2013 04:55:35
by Volodymyr Zinin (Team)

As a variant you can add in your context associated with TCbFsFilInfo a boolean field, something like IsDirectory, and initialize it during the file/folder opening (in the OnCreate/OnOpen callback).
In any case your implementation of the CallbackFS callbacks should know information about the "backend" files/directories. For example at any time the OnGetFileInfo callback can come to request information about any file or folder.
Posted: 10/15/2013 05:34:00
by david atkins (Basic support level)
Joined: 06/12/2013
Posts: 13

Ok I am now trying to run your mapper sample and have dropped the vcl files into a project in Builder XE and am receiving an Unresolved External linker error for 'NtOpenFile' do you know how I would go about correcting this?
Posted: 10/15/2013 05:51:04
by Vladimir Cherniga (Team)

It must have been linked statically with a next declaration in Main.pas:
function NtOpenFile(FileHandle: PHandle; DesiredAccess: ACCESS_MASK;
  ObjectAttributes: POBJECT_ATTRIBUTES; IoStatusBlock: PIO_STATUS_BLOCK;
  ShareAccess: ULONG; OpenOptions: ULONG): Integer; stdcall; external 'ntdll.dll';

If this is a problem, try to load this library dynamically. There is a code in CbFsGetFileNameByFileId callback handler that is demonstrate this technique.
Posted: 10/15/2013 08:01:44
by david atkins (Basic support level)
Joined: 06/12/2013
Posts: 13

Also when I uncomment the section that is labelled "uncomment in order to support NFS sharing" I receive a System Error Code 50 "request is not supported" when the line FCbFs.CreateStorage; is executed.

I believe it is caused by:
FCbFs.StorageCharacteristics := [TCbFsStorageCharacteristic(0)];

If I comment this line out then it runs fine but the characteristic are no set correctly.

I have managed to fix the problem by replacing this line:

FCbFs.StorageCharacteristics := [TCbFsStorageCharacteristic(0)];

with this one:

FCbFs.StorageCharacteristics := [];
Posted: 10/15/2013 11:11:48
by Vladimir Cherniga (Team)

We will fix the sample, thank you for your comments.
Posted: 10/16/2013 07:48:58
by david atkins (Basic support level)
Joined: 06/12/2013
Posts: 13

I am running the Mapper sample and I am able to mount a drive pointing at C:\1 but when I open the mounted drive in windows explorer I instantly get an exception thrown in the GetFileSecurity callback thrown as shown using the code in below:

  if Not GetFileSecurityW(PWideChar(FRootPath + FileInfo.FileName),
    SecurityInformation, SecurityDescriptor, Length, LengthNeeded) then begin
   Error := GetLastError;
   raise ECBFSError.Create(Error);
Posted: 10/16/2013 07:57:39
by Volodymyr Zinin (Team)

Please specify the content of the Error variable?
Posted: 10/16/2013 08:00:48
by david atkins (Basic support level)
Joined: 06/12/2013
Posts: 13

It contains 122 which according to MSDN is:

The data area passed to a system call is too small.
Posted: 10/16/2013 08:17:01
by Volodymyr Zinin (Team)

This is correct situation. The system GetFileSecurity API call returns such error in the case the buffer for security descriptor is not big enough and the LengthNeeded parameter is set to required size. So on the next call (with the bigger buffer) the function completes successfully. At least it should be so.
Posted: 10/16/2013 08:19:13
by david atkins (Basic support level)
Joined: 06/12/2013
Posts: 13

So why does your code throw an exception when this happens if it is correct?



Topic viewed 6867 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!