EldoS | Feel safer!

Software components for data protection, secure storage and transfer

CbFsFileInfo to fuse_file_info

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#19763
Posted: 04/13/2012 05:47:39
by szagriichuk  (Basic support level)
Joined: 03/28/2012
Posts: 51

Quote
Vladimir Cherniga wrote:
You may cast FileHandleContext to fuse_file_info_wrapper, then access to the fuse_file_info. Or rewrite fuse_file_info_wrapper in to the class, then implement fuse_file_info as a class member. Use GCHandle::Alloc(), GCHandle::FromIntPtr(), GCHandle::ToIntPtr to cast pointers and class instances to each others (look at the cbfs dotNet sample code)


Thanks for answer and what about Java API ?
#19765
Posted: 04/13/2012 06:07:53
by Vladimir Cherniga (EldoS Corp.)

CallbackFS has JNI interface with byteArrayRef class that allow safe conversion from/to any data type.
#19773
Posted: 04/13/2012 06:41:13
by szagriichuk  (Basic support level)
Joined: 03/28/2012
Posts: 51

Quote
Vladimir Cherniga wrote:
CallbackFS has JNI interface with byteArrayRef class that allow safe conversion from/to any data type.

Yes, I know It, but
Code
fuse_file_info
has a lot of fields for example
Code
flags , writepage, direct_io
and so on, what operations (and/or or xor) should I apply to byte array to set up these fileds in
Code
fuse_file_info
structure, and what flag should I use for it ? Thanks.
#19774
Posted: 04/13/2012 07:07:55
by Vladimir Cherniga (EldoS Corp.)

You may cast whole structure to byte array and back, or use a wrapper for fuse_file_info to store additional parameters like reference count and others from fuse_file_info_wrapper and make the same transformation using byteArrayRef class. It is the same steps described for dotNet sample, but using another api.
#19779
Posted: 04/13/2012 09:14:10
by szagriichuk  (Basic support level)
Joined: 03/28/2012
Posts: 51

Quote
Vladimir Cherniga wrote:
You may cast whole structure to byte array and back, or use a wrapper for fuse_file_info to store additional parameters like reference count and others from fuse_file_info_wrapper and make the same transformation using byteArrayRef class. It is the same steps described for dotNet sample, but using another api.


Ok, Thank you, I've found wrapper structure in C++ code, but did not find in dotNet sample, any reference to the wrapper structure.

From the first my post I want to know how to do it (I mean cast atray of bytes to the class like this)


Code
public class FuseFileInfo {
   public long flags;
   public long fh_old;
   public long writepage;
   public long direct_io;
   public long keep_cache;
   public long flush;
   public long padding;
   public long fh;
   public long lock_owner;
}
,
I cannot to do it using usual casting because will be ClassCast exeption, so, I should read some data form byte array and assing to some field in this structure. And how to do it I did not receive answer :(
#19781
Posted: 04/13/2012 09:49:55
by Vladimir Cherniga (EldoS Corp.)

Quote
Ok, Thank you, I've found wrapper structure in C++ code, but did not find in dotNet sample, any reference to the wrapper structure.

We've implemented FUSE interface in c++ wrapper only. Any dotNet samples doesn't exists, you should port it to java or c# by yourself.
Quote
I cannot to do it using usual casting because will be ClassCast exeption, so, I should read some data form byte array and assing to some field in this structure. And how to do it I did not receive answer :(


Java sample:

Code
    private Object toObject(byte[] bytes) {
       Object object = null;
       
       try {
          object = new ObjectInputStream(new ByteArrayInputStream(bytes)).readObject();
       } catch(IOException ioe) {
          ioe.printStackTrace();
       } catch(ClassNotFoundException cnfe) {
          cnfe.printStackTrace();
       }
       
       return object;
    }


    private byte[] toBytes(Object object) {
       ByteArrayOutputStream baos = new ByteArrayOutputStream();

       try {
           ObjectOutputStream oos = new ObjectOutputStream(baos);          
         oos.writeObject(object);
      } catch (IOException e) {
         e.printStackTrace();
      }
       
      return baos.toByteArray();
   }

                      ......
//Usage
byteArrayRef fileHandleContext;
fileHandleContext.setValue(toBytes(your_wrapper_class));
your_wrapper_class file_info = (your_wrapper_class)toObject(fileHandleContext.getValue());
#19782
Posted: 04/13/2012 10:10:23
by szagriichuk  (Basic support level)
Joined: 03/28/2012
Posts: 51

Quote
Vladimir Cherniga wrote:

                      ......
//Usage
byteArrayRef fileHandleContext;
fileHandleContext.setValue(toBytes(your_wrapper_class));
your_wrapper_class file_info = (your_wrapper_class)toObject(fileHandleContext.getValue());


Thanks, did not think about usage like this, will try, Have a nice holidays!!!
#19783
Posted: 04/13/2012 10:35:59
by Vladimir Cherniga (EldoS Corp.)

In attachment you will find umount sample project, that is a replacement of umount command (rename the attached file to .zip). It is absent from distributive of cbfs by mistake.
Quote
Thanks, did not think about usage like this, will try, Have a nice holidays!!!

Thank you ! Good luck!


[ Download ]
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.

Reply

Statistics

Topic viewed 2738 times

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




|

Back to top

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

Got it!