org.basex.fuse
Class DeepFS

java.lang.Object
  extended by org.basex.fuse.DeepFuse
      extended by org.basex.fuse.DeepFS
All Implemented Interfaces:
DataText

public final class DeepFS
extends DeepFuse
implements DataText

DeepFS: The XQuery Filesystem Database-side implementation of DeepFS.

Author:
Workgroup DBIS, University of Konstanz 2005-09, ISC License, Alexander Holupirek, alex@holupirek.de, Christian Gruen, Hannes Schwarz

Field Summary
 int backingstoreID
          Index backing store.
 Data data
          Data reference.
 int dirID
          Index References.
 int fileID
          Index References.
 GUI gui
          Data reference.
 int modeID
          Index References.
 int mountpointID
          Index mount point.
 int suffID
          Index References.
 int timeID
          Index References.
 int unknownID
          Index References.
 
Fields inherited from interface org.basex.data.DataText
ATT, ATT1, ATT2, BACKING, BACKINGSTORE, COM1, COM2, COMM, CONTENT, DATAATV, DATAFTX, DATAINFO, DATATBL, DATATMP, DATATXT, DBATVINDEX, DBCHOPPED, DBENCODING, DBENTITY, DBFNAME, DBFSIZE, DBFTCS, DBFTDC, DBFTSTEM, DBFTXINDEX, DBFZINDEX, DBHEIGHT, DBLASTID, DBNDOCS, DBSIZE, DBSTORAGE, DBTIME, DBTXTINDEX, DBUPTODATE, DBWRDINDEX, DEEPFS, DIR, E_AMP, E_CR, E_GT, E_LT, E_NL, E_QU, E_TAB, ELEM1, ELEM2, ELEM3, ELEM4, FILE, IDBSTORAGE, ISTORAGE, MODE, MOUNT, MOUNTPOINT, MTIME, NAME, NOBACKING, NOTMOUNTED, PI, PI1, PI2, RESULT, RESULTS, S_DEEPFS, S_MTIME, S_NAME, S_SIZE, S_SUFFIX, SIZE, STORAGE, SUFFIX, TABLEATS, TABLEDIST, TABLEKIND, TABLEKINDS, TABLENS, TABLEPRE, TABLEPREF, TABLESIZE, TABLEURI, TEXT, UNKNOWN
 
Constructor Summary
DeepFS(Data d)
          Constructor.
DeepFS(java.lang.String dbname, boolean fuse)
          Constructor for DeepShell and java only test cases (no mount).
 
Method Summary
 int access(java.lang.String path, int mode)
          Check file access permissions.
 int bmap(java.lang.String path, long blocksize, long idx)
          Map block index within file to block index within device.
 int chmod(java.lang.String path, int mode)
          Change the permission bits of a file.
 int chown(java.lang.String path, int uid, int gid)
          Change the owner and group of a file.
 int create(java.lang.String path, int mode)
          Creates a new regular file.
 int destroy()
          Clean up filesystem.
 int fgetattr(java.lang.String path)
          Get attributes from an open file.
 int flush(java.lang.String path)
          Possibly flush cached data.
 int fsync(java.lang.String path)
          Synchronize file contents.
 int fsyncdir(java.lang.String path)
          Synchronize directory contents.
 int ftruncate(java.lang.String path, long off)
          Change the size of an open file.
 int getattr(java.lang.String path)
          Resolves path and returns id. id serves as index into stat array in native fuse implementation.
 int getxattr(java.lang.String path)
          Get extended attributes.
 boolean isDir(int pre)
          Checks if the specified node is a directory.
 boolean isFile(int pre)
          Checks if the specified node is a file.
 void launch(int pre)
          Opens the file which is defined by the specified pre value.
 int link(java.lang.String name1, java.lang.String name2)
          Create a hard link to a file.
 int listxattr(java.lang.String path)
          List extended attributes.
 int lock(java.lang.String path, int cmd)
          Perform POSIX file locking operation.
 int mkdir(java.lang.String path, int mode)
          Creates a new directory.
 int mknod(java.lang.String path, int mode, int dev)
          Create a file node.
 byte[] name(int pre)
          Returns the name of a file.
 int nativeMount(java.lang.String mp, java.lang.String bs)
          Mount database as FUSE.
 void nativeShutDown()
          Tell DeepFS that BaseX will shutdown.
 int nativeUnlink(java.lang.String pathname)
          Unlink file in backing store.
 int open(java.lang.String path)
          File open operation.
 int opendir(java.lang.String path)
          Open directory.
 byte[] path(int pre)
          Returns the absolute file path.
 byte[] read(java.lang.String path, int length, int offset)
          Read data from an open file.
 java.lang.String readdir(java.lang.String path, int offset)
          Read directory.
 java.lang.String readlink(java.lang.String path)
          Read the target of a symbolic link.
 int release(java.lang.String path)
          Release an open file.
 int releasedir(java.lang.String path)
          Release directory.
 int removexattr(java.lang.String path)
          Remove extended attributes.
 int rename(java.lang.String from, java.lang.String to)
          Rename a file.
 int rmdir(java.lang.String path)
          Remove a directory file.
 int setxattr(java.lang.String path)
          Set extended attributes.
 byte[] size(int pre)
          Returns the size of a file.
 int statfs(java.lang.String path)
          Get file system statistics.
 int symlink(java.lang.String from, java.lang.String to)
          Make symbolic link to a file.
 int truncate(java.lang.String path, long off)
          Change the size of a file.
 int unlink(java.lang.String path)
          Remove a file.
 int utimens(java.lang.String path)
          Change the access and modification times of a file with nanosecond resolution.
 int write(java.lang.String path, int length, int offset, byte[] mydata)
          Write data to an open file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gui

public GUI gui
Data reference.


data

public Data data
Data reference.


fileID

public int fileID
Index References.


dirID

public int dirID
Index References.


suffID

public int suffID
Index References.


timeID

public int timeID
Index References.


modeID

public int modeID
Index References.


unknownID

public int unknownID
Index References.


mountpointID

public int mountpointID
Index mount point.


backingstoreID

public int backingstoreID
Index backing store.

Constructor Detail

DeepFS

public DeepFS(Data d)
Constructor.

Parameters:
d - data reference

DeepFS

public DeepFS(java.lang.String dbname,
              boolean fuse)
Constructor for DeepShell and java only test cases (no mount).

Parameters:
dbname - name of initially empty database.
fuse - property value to be set for Prop.fuse
Method Detail

nativeMount

public int nativeMount(java.lang.String mp,
                       java.lang.String bs)
Mount database as FUSE.

Parameters:
mp - path where to mount BaseX.
bs - path to backing storage root of this instance.
Returns:
0 on success, errno in case of failure.

nativeUnlink

public int nativeUnlink(java.lang.String pathname)
Unlink file in backing store.

Parameters:
pathname - to file to delete
Returns:
0 on success, errno in case of failure.

nativeShutDown

public void nativeShutDown()
Tell DeepFS that BaseX will shutdown.


isFile

public boolean isFile(int pre)
Checks if the specified node is a file.

Parameters:
pre - pre value
Returns:
result of comparison

isDir

public boolean isDir(int pre)
Checks if the specified node is a directory.

Parameters:
pre - pre value
Returns:
result of comparison

path

public byte[] path(int pre)
Returns the absolute file path.

Parameters:
pre - pre value
Returns:
file path.

name

public byte[] name(int pre)
Returns the name of a file.

Parameters:
pre - pre value
Returns:
file name.

size

public byte[] size(int pre)
Returns the size of a file.

Parameters:
pre - pre value
Returns:
file size

launch

public void launch(int pre)
Opens the file which is defined by the specified pre value.

Parameters:
pre - pre value

destroy

public int destroy()
Description copied from class: DeepFuse
Clean up filesystem. Called on filesystem exit.

Specified by:
destroy in class DeepFuse
Returns:
zero on success, or -1 if an error occurred

mkdir

public int mkdir(java.lang.String path,
                 int mode)
Creates a new directory.

Specified by:
mkdir in class DeepFuse
Parameters:
path - to directory to be created
mode - of directory
Returns:
id of the newly created directory or -1 on failure

create

public int create(java.lang.String path,
                  int mode)
Creates a new regular file.

Specified by:
create in class DeepFuse
Parameters:
path - to the file to be created
mode - of regular file
Returns:
id of the newly created file or -1 on failure

getattr

public int getattr(java.lang.String path)
Resolves path and returns id. id serves as index into stat array in native fuse implementation.

Specified by:
getattr in class DeepFuse
Parameters:
path - to be resolved
Returns:
id of node or -1 if not found

unlink

public int unlink(java.lang.String path)
Description copied from class: DeepFuse
Remove a file.

Specified by:
unlink in class DeepFuse
Parameters:
path - to file to be removed
Returns:
zero on success, or -1 if an error occurred (in which case, errno is set appropriately).

opendir

public int opendir(java.lang.String path)
Description copied from class: DeepFuse
Open directory.

Specified by:
opendir in class DeepFuse
Parameters:
path - name of the file
Returns:
the number of directories or -1 if an error occurred

rmdir

public int rmdir(java.lang.String path)
Description copied from class: DeepFuse
Remove a directory file.

Specified by:
rmdir in class DeepFuse
Parameters:
path - to file to be removed
Returns:
zero on success, or -1 if an error occurred (in which case, errno is set appropriately).

readdir

public java.lang.String readdir(java.lang.String path,
                                int offset)
Description copied from class: DeepFuse
Read directory.

Specified by:
readdir in class DeepFuse
Parameters:
path - name of the directory to read
offset - of directory entry requested
Returns:
name of directory entry or null on failure

rename

public int rename(java.lang.String from,
                  java.lang.String to)
Description copied from class: DeepFuse
Rename a file.

Specified by:
rename in class DeepFuse
Parameters:
from - path to file to be renamed
to - new name
Returns:
zero on success, or -1 if an error occurred (in which case, errno is set appropriately).

access

public int access(java.lang.String path,
                  int mode)
Description copied from class: DeepFuse
Check file access permissions.

Specified by:
access in class DeepFuse
Parameters:
path - name of the file
mode - permission to check
Returns:
zero on success, or -1 if an error occurred

bmap

public int bmap(java.lang.String path,
                long blocksize,
                long idx)
Description copied from class: DeepFuse
Map block index within file to block index within device.

Specified by:
bmap in class DeepFuse
Parameters:
path - name of the file
blocksize - block size
idx - block index
Returns:
zero on success, or -1 if an error occurred

chmod

public int chmod(java.lang.String path,
                 int mode)
Description copied from class: DeepFuse
Change the permission bits of a file.

Specified by:
chmod in class DeepFuse
Parameters:
path - name of the file
mode - permissions to be set
Returns:
zero on success, or -1 if an error occurred

chown

public int chown(java.lang.String path,
                 int uid,
                 int gid)
Description copied from class: DeepFuse
Change the owner and group of a file.

Specified by:
chown in class DeepFuse
Parameters:
path - name of the file
uid - owner
gid - group
Returns:
zero on success, or -1 if an error occurred

fgetattr

public int fgetattr(java.lang.String path)
Description copied from class: DeepFuse
Get attributes from an open file. This method is called instead of the getattr() method if the file information is available.

Specified by:
fgetattr in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

flush

public int flush(java.lang.String path)
Description copied from class: DeepFuse
Possibly flush cached data. BIG NOTE: This is not equivalent to fsync(). It's not a request to sync dirty data.

Specified by:
flush in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

fsync

public int fsync(java.lang.String path)
Description copied from class: DeepFuse
Synchronize file contents.

Specified by:
fsync in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

fsyncdir

public int fsyncdir(java.lang.String path)
Description copied from class: DeepFuse
Synchronize directory contents.

Specified by:
fsyncdir in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

ftruncate

public int ftruncate(java.lang.String path,
                     long off)
Description copied from class: DeepFuse
Change the size of an open file.

Specified by:
ftruncate in class DeepFuse
Parameters:
path - name of the file
off - new file size
Returns:
zero on success, or -1 if an error occurred

getxattr

public int getxattr(java.lang.String path)
Description copied from class: DeepFuse
Get extended attributes.

Specified by:
getxattr in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

link

public int link(java.lang.String name1,
                java.lang.String name2)
Description copied from class: DeepFuse
Create a hard link to a file.

Specified by:
link in class DeepFuse
Parameters:
name1 - link source
name2 - link target
Returns:
zero on success, or -1 if an error occurred (in which case, errno is set appropriately).

listxattr

public int listxattr(java.lang.String path)
Description copied from class: DeepFuse
List extended attributes.

Specified by:
listxattr in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

lock

public int lock(java.lang.String path,
                int cmd)
Description copied from class: DeepFuse
Perform POSIX file locking operation.

Specified by:
lock in class DeepFuse
Parameters:
path - name of the file
cmd - locking command id
Returns:
zero on success, or -1 if an error occurred

mknod

public int mknod(java.lang.String path,
                 int mode,
                 int dev)
Description copied from class: DeepFuse
Create a file node. This is called for creation of all non-directory, non-symlink nodes. If the filesystem defines a create() method, then for regular files that will be called instead.

Specified by:
mknod in class DeepFuse
Parameters:
path - name of the file to be created.
mode - specifies both the permissions to use and the type of node to be created.
dev - If the file type is S_IFCHR or S_IFBLK then dev specifies the major and minor numbers of the newly created device special file; otherwise it is ignored.
Returns:
zero on success, or -1 if an error occurred (in which case, errno is set appropriately).

open

public int open(java.lang.String path)
Description copied from class: DeepFuse
File open operation.

Specified by:
open in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

read

public byte[] read(java.lang.String path,
                   int length,
                   int offset)
Description copied from class: DeepFuse
Read data from an open file.

Specified by:
read in class DeepFuse
Parameters:
path - name of the file
length - number of bytes to read
offset - from which to read
Returns:
zero on success, or -1 if an error occurred

readlink

public java.lang.String readlink(java.lang.String path)
Description copied from class: DeepFuse
Read the target of a symbolic link.

Specified by:
readlink in class DeepFuse
Parameters:
path - to the link
Returns:
String link target

release

public int release(java.lang.String path)
Description copied from class: DeepFuse
Release an open file.

Specified by:
release in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

releasedir

public int releasedir(java.lang.String path)
Description copied from class: DeepFuse
Release directory.

Specified by:
releasedir in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

removexattr

public int removexattr(java.lang.String path)
Description copied from class: DeepFuse
Remove extended attributes.

Specified by:
removexattr in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

setxattr

public int setxattr(java.lang.String path)
Description copied from class: DeepFuse
Set extended attributes.

Specified by:
setxattr in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

statfs

public int statfs(java.lang.String path)
Description copied from class: DeepFuse
Get file system statistics.

Specified by:
statfs in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

symlink

public int symlink(java.lang.String from,
                   java.lang.String to)
Description copied from class: DeepFuse
Make symbolic link to a file.

Specified by:
symlink in class DeepFuse
Parameters:
from - link source
to - link target
Returns:
zero on success, or -1 if an error occurred (in which case, errno is set appropriately).

truncate

public int truncate(java.lang.String path,
                    long off)
Description copied from class: DeepFuse
Change the size of a file.

Specified by:
truncate in class DeepFuse
Parameters:
path - name of the file
off - size to be set
Returns:
zero on success, or -1 if an error occurred

utimens

public int utimens(java.lang.String path)
Description copied from class: DeepFuse
Change the access and modification times of a file with nanosecond resolution.

Specified by:
utimens in class DeepFuse
Parameters:
path - name of the file
Returns:
zero on success, or -1 if an error occurred

write

public int write(java.lang.String path,
                 int length,
                 int offset,
                 byte[] mydata)
Description copied from class: DeepFuse
Write data to an open file.

Specified by:
write in class DeepFuse
Parameters:
path - name of the file
length - number of bytes to write
offset - from which to write
mydata - buffer from which to write
Returns:
zero on success, or -1 if an error occurred