How to convert a JLAN filesystem

From FileSys.Org Wiki

JFileServer is a fork of the JLAN code with many changes to bring the code up to date and continue development of the virtual filesystem file server.

In this article we will convert the sample filesystem driver that comes with JLAN over to the new JFileServer code. That is the JavaFileDiskDriver, JavaFileSearchContext and JavaNetworkFile classes in the org.alfresco.jlan.smb.server.disk package.

The JLAN code uses Java packages starting with org.alfresco.jlan whereas JFileServer has repackaged the code into the org.filesys packages. In the three source files replace org.alfresco.jlan with org.filesys in the imports sections. In the file the imports section should now look like this :-


import org.filesys.server.filesys.AccessMode;
import org.filesys.server.filesys.DiskFullException;
import org.filesys.server.filesys.NetworkFile;
import org.filesys.smb.SeekType;

In JLAN the main DiskInterface filesystem interface has the method int fileExists(SrvSession sess, TreeConnection tree, String name), in JFileServer this has changed to use an enum class for the return value - FileStatus fileExists(SrvSession sess, TreeConnection tree, String name).

In the file change the method signature for the fileExists(...) method to return a FileStatus enum value.

In JFileServer the NetworkFile class now uses enum classes for the access type and flags values, via the NetworkFile.Access and NetworkFile.Flags enum inner classes.

We need to modify the createFile() and openFile() methods to use the new NetworkFile.Access enum class. In the createFile() method change the call to setGrantedAccess() to :-


In the openFile() method change the calls to setGrantedAccess() to :-

if( params.isReadOnlyAccess())
    netFile.setGrantedAccess( NetworkFile.Access.READ_ONLY);
    netFile.setGrantedAccess( NetworkFile.Access.READ_WRITE);

In the module openFile() method we need to change the call to create the RandomAccessFile to :-

m_io = new RandomAccessFile( m_file, getGrantedAccess() == NetworkFile.Access.READ_WRITE ? "rw" : "r");

The JLAN filesystem driver should now compile against the JFileServer classes. Converting a JLAN filesystem to the new JFileServer code is fairly straighforward.