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.
 int contentID
          Index References.
 Data data
          Data reference.
 int deepfsID
          Index References.
 int dirID
          Index References.
 int fileID
          Index References.
 int modeID
          Index References.
 int mountpointID
          Index mount point.
 int mtimeID
          Index References.
 int nameID
          Index References.
 int sizeID
          Index References.
 int suffixID
          Index References.
 int unknownID
          Index References.
 
Fields inherited from interface org.basex.data.DataText
ATT, ATT1, ATT2, BACKINGSTORE, COM1, COM2, COMM, CONTENT, COUNT, DATAATV, DATAFTX, DATAINFO, DATATBL, DATATMP, DATATXT, DBATTS, DBATVIDX, DBBCK, DBCHOP, DBENC, DBENTITY, DBFNAME, DBFSIZE, DBFTCS, DBFTDC, DBFTST, DBFTXIDX, DBFZIDX, DBHGHT, DBLID, DBMNT, DBNDOCS, DBNS, DBPATH, DBPTHIDX, DBSIZE, DBSTR, DBTAGS, DBTIME, DBTXTIDX, DBUTD, DEEPFS, DIR, DOC, E_AMP, E_CR, E_GT, E_LT, E_NL, E_QU, E_TAB, ELEM1, ELEM2, ELEM3, ELEM4, FILE, IDBSTR, ISTORAGE, KIND, MODE, MOUNTPOINT, MTIME, NAME, NOBACKING, NODE, NOTMOUNTED, OFFSET, PATH, PI, PI1, PI2, RESULT, RESULTS, S_MTIME, S_NAME, S_SIZE, S_SUFFIX, SIZE, STORAGE, SUFFIX, TABLEATS, TABLEDIST, TABLEKIND, TABLEKINDS, TABLENS, TABLEPRE, TABLEPREF, TABLESIZE, TABLEURI, TEXT, TEXT_CONTENT, UNKNOWN, XML_CONTENT
 
Constructor Summary
DeepFS(Context ctx, java.lang.String name)
          Constructor for DeepShell and java only test cases (no mount).
DeepFS(Data d)
          Constructor.
 
Method Summary
 int access(java.lang.String path, int mode)
          Checks file access permissions.
 int bmap(java.lang.String path, long blocksize, long idx)
          Maps block index within file to block index within device.
 int chmod(java.lang.String path, int mode)
          Changes the permission bits of a file.
 int chown(java.lang.String path, int uid, int gid)
          Changes the owner and group of a file.
 void close()
          Closes the fuse instance.
 int create(java.lang.String path, int mode)
          Creates a new regular file.
 void delete(int pre)
          Deletes a non-empty directory.
 int destroy()
          Cleans up filesystem.
 int fgetattr(java.lang.String path)
          Gets attributes from an open file.
 int flush(java.lang.String path)
          Possibly flushes cached data.
 int fsync(java.lang.String path)
          Synchronizes file contents.
 int fsyncdir(java.lang.String path)
          Synchronizes directory contents.
 int ftruncate(java.lang.String path, long off)
          Changes 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)
          Gets 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)
          Creates a hard link to a file.
 int listxattr(java.lang.String path)
          Lists extended attributes.
 int lock(java.lang.String path, int cmd)
          Performs 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)
          Creates 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 the database 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)
          Opens directory.
 byte[] path(int pre, boolean backing)
          Returns the absolute file path.
 byte[] read(java.lang.String path, int length, int offset)
          Reads data from an open file.
 java.lang.String readdir(java.lang.String path, int offset)
          Reads directory.
 java.lang.String readlink(java.lang.String path)
          Reads the target of a symbolic link.
 int release(java.lang.String path)
          Releases an open file.
 int releasedir(java.lang.String path)
          Releases directory.
 int removexattr(java.lang.String path)
          Removes extended attributes.
 int rename(java.lang.String from, java.lang.String to)
          Renames a file.
 int rmdir(java.lang.String path)
          Removes a directory file.
 int setxattr(java.lang.String path)
          Sets extended attributes.
 byte[] size(int pre)
          Returns the size of a file.
 int statfs(java.lang.String path)
          Gets file system statistics.
 int symlink(java.lang.String from, java.lang.String to)
          Makes symbolic link to a file.
 int truncate(java.lang.String path, long off)
          Changes the size of a file.
 int unlink(java.lang.String path)
          Removes a file.
 int utimens(java.lang.String path)
          Changes the access and modification times of a file with nanosecond resolution.
 int write(java.lang.String path, int length, int offset, byte[] mydata)
          Writes data to an open file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

public Data data
Data reference.


deepfsID

public int deepfsID
Index References.


fileID

public int fileID
Index References.


dirID

public int dirID
Index References.


suffixID

public int suffixID
Index References.


mtimeID

public int mtimeID
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.


sizeID

public int sizeID
Index References.


nameID

public int nameID
Index References.


contentID

public int contentID
Index References.

Constructor Detail

DeepFS

public DeepFS(Data d)
Constructor.

Parameters:
d - data reference

DeepFS

public DeepFS(Context ctx,
              java.lang.String name)
Constructor for DeepShell and java only test cases (no mount).

Parameters:
name - name of initially empty database.
ctx - database context
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 the database will shutdown.


close

public void close()
           throws java.io.IOException
Closes the fuse instance.

Throws:
java.io.IOException - I/O exception

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,
                   boolean backing)
Returns the absolute file path.

Parameters:
pre - pre value
backing - whether to return backing path or mountpath
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

delete

public void delete(int pre)
Deletes a non-empty directory.

Parameters:
pre - pre value

destroy

public int destroy()
Description copied from class: DeepFuse
Cleans 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
Removes 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
Opens 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
Removes 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
Reads 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
Renames 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
Checks 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
Maps 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
Changes 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
Changes 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
Gets 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 flushes 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
Synchronizes 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
Synchronizes 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
Changes 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
Gets 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
Creates 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
Lists 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
Performs 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
Creates 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
Reads 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
Reads 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
Releases 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
Releases 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
Removes 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
Sets 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
Gets 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
Makes 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
Changes 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
Changes 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
Writes 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