Class: FuseFS::FuseDir
- Inherits:
-
Object
- Object
- FuseFS::FuseDir
- Defined in:
- lib/fuse/fusedir.rb
Overview
This class is equivalent to using Object.new() as the virtual directory for target for start. It exists primarily to document the API but can also be used as a superclass for your filesystem providing sensible defaults
Method call sequences
Stat (getattr)
FUSE itself will generally stat referenced files and validate the results before performing any file/directory operations so this sequence is called very often
-
#directory? is checked first
-
#can_write? OR #can_mkdir? with ._rfusefs_check_ to determine write permissions
-
#times is called to determine atime,mtime,ctime info for the directory
-
-
#file? is checked next
-
#can_write?, #executable?, #size, #times are called to fill out the details
-
-
otherwise we tell FUSE that the path does not exist
List directory
FUSE confirms the path is a directory (via stat above) before we call #contents
FUSE will generally go on to stat each directory entry in the results
Reading files
FUSE confirms path is a file before we call #read_file
For fine control of file access see #raw_open, #raw_read, #raw_close
Writing files
FUSE confirms path for the new file is a directory
-
#can_write? is checked at file open
-
#write_to is called when the file is synced, flushed or closed
See also #raw_open, #raw_truncate, #raw_write, #raw_sync, #raw_close
Deleting files
FUSE confirms path is a file before we call #can_delete? then #delete
Creating directories
FUSE confirms parent is a directory before we call #can_mkdir? then #mkdir
Deleting directories
FUSE confirms path is a directory before we call #can_rmdir? then #rmdir
Renaming files and directories
FUSE confirms the rename is valid (eg. not renaming a directory to a file)
-
Try #rename to see if the virtual directory wants to handle this itself
-
If rename returns false/nil then we try to copy/delete (files only) ie.
-
#file?(from), #can_write?(to), #can_delete?(from) and if all true
-
#read_file(from), #write_to(to), #delete(from)
-
-
otherwise reject the rename
Signals
The filesystem can handle a signal by providing a ‘sig<name>` method. eg ’sighup’ #sigint and #sigterm are handled by default to provide a means to exit the filesystem
Direct Known Subclasses
Constant Summary collapse
- INIT_TIMES =
Array.new(3,0)
Instance Method Summary collapse
-
#can_delete?(path) ⇒ Boolean
abstract
True if the user can delete the file at path.
-
#can_mkdir?(path) ⇒ Boolean
abstract
True if user can make a directory at path.
-
#can_rmdir?(path) ⇒ Boolean
abstract
True if user can remove a directory at path.
-
#can_write?(path) ⇒ Boolean
abstract
True if the user can write to file at path.
-
#contents(path) ⇒ Array<String>
abstract
Array of file and directory names within path.
-
#delete(path) ⇒ void
abstract
Delete the file at path.
-
#directory?(path) ⇒ Boolean
abstract
True if path is a directory.
-
#executable?(path) ⇒ Boolean
abstract
True if path is an executable file.
-
#file?(path) ⇒ Boolean
abstract
True if path is a file.
-
#mkdir(path) ⇒ void
abstract
Make a directory at path.
-
#mounted ⇒ void
RFuseFS extension.
-
#raw_close(path, raw = nil) ⇒ void
abstract
Close the file previously opened at path (or filehandle raw).
-
#raw_open(path, mode, rfusefs = nil) ⇒ nil, Object
abstract
Raw file access.
-
#raw_read(path, offset, size, raw = nil) ⇒ void
abstract
Read sz bytes from file at path (or filehandle raw) starting at offset off.
-
#raw_sync(path, datasync, raw = nil) ⇒ Object
Sync buffered data to your filesystem.
-
#raw_truncate(path, offset, raw = nil) ⇒ Object
abstract
RFuseFS extension.
-
#raw_write(path, off, sz, buf, raw = nil) ⇒ void
abstract
Write sz bytes from file at path (or filehandle raw) starting at offset off.
-
#read_file(path) ⇒ String
abstract
The contents of the file at path.
-
#rename(from_path, to_path) ⇒ Boolean
abstract
Move a file or directory.
-
#rmdir(path) ⇒ void
abstract
Remove the directory at path.
-
#scan_path(path) ⇒ Array<String>
base,*rest = scan_path(path).
-
#sigint ⇒ void
Handle the INT signal and exit the filesystem.
-
#sigterm ⇒ void
Handle the TERM signal and exit the filesystem.
-
#size(path) ⇒ Integer
abstract
File size.
-
#split_path(path) ⇒ Array<String,String>
base,rest = split_path(path).
-
#statistics(path) ⇒ Array<Integer>, RFuse::StatVfs
abstract
RFuseFS extensions.
-
#times(path) ⇒ Array<Integer, Time>
abstract
File time information.
-
#touch(path, modtime) ⇒ void
abstract
Neat toy.
-
#unmounted ⇒ void
RFuseFS extension.
-
#write_to(path, str) ⇒ void
abstract
Write the contents of str to file at path.
-
#xattr(path) ⇒ Hash
abstract
RFuseFS extension.
Instance Method Details
#can_delete?(path) ⇒ Boolean
FuseFS api
Returns true if the user can delete the file at path.
202 |
# File 'lib/fuse/fusedir.rb', line 202 def can_delete?(path);return false;end |
#can_mkdir?(path) ⇒ Boolean
FuseFS api
Returns true if user can make a directory at path.
211 |
# File 'lib/fuse/fusedir.rb', line 211 def can_mkdir?(path);return false;end |
#can_rmdir?(path) ⇒ Boolean
FuseFS api
Returns true if user can remove a directory at path.
220 |
# File 'lib/fuse/fusedir.rb', line 220 def can_rmdir?(path);return false;end |
#can_write?(path) ⇒ Boolean
FuseFS api
Returns true if the user can write to file at path.
193 |
# File 'lib/fuse/fusedir.rb', line 193 def can_write?(path);return false;end |
#contents(path) ⇒ Array<String>
FuseFS api
Returns array of file and directory names within path.
171 |
# File 'lib/fuse/fusedir.rb', line 171 def contents(path);return [];end |
#delete(path) ⇒ void
FuseFS api
This method returns an undefined value.
Delete the file at path
207 |
# File 'lib/fuse/fusedir.rb', line 207 def delete(path);end |
#directory?(path) ⇒ Boolean
FuseFS api
Returns true if path is a directory.
163 |
# File 'lib/fuse/fusedir.rb', line 163 def directory?(path);return false;end |
#executable?(path) ⇒ Boolean
FuseFS api
Returns true if path is an executable file.
175 |
# File 'lib/fuse/fusedir.rb', line 175 def executable?(path);return false;end |
#file?(path) ⇒ Boolean
FuseFS api
Returns true if path is a file.
167 |
# File 'lib/fuse/fusedir.rb', line 167 def file?(path);end |
#mkdir(path) ⇒ void
FuseFS api
This method returns an undefined value.
Make a directory at path
216 |
# File 'lib/fuse/fusedir.rb', line 216 def mkdir(path);end |
#mounted ⇒ void
This method returns an undefined value.
RFuseFS extension. Called when the filesystem is mounted
317 |
# File 'lib/fuse/fusedir.rb', line 317 def mounted();end |
#raw_close(path, raw = nil) ⇒ void
FuseFS api
This method returns an undefined value.
Close the file previously opened at path (or filehandle raw)
293 |
# File 'lib/fuse/fusedir.rb', line 293 def raw_close(path,raw=nil);end |
#raw_open(path, mode, rfusefs = nil) ⇒ nil, Object
FuseFS api
Raw file access
247 |
# File 'lib/fuse/fusedir.rb', line 247 def raw_open(path,mode,rfusefs = nil);end |
#raw_read(path, offset, size, raw = nil) ⇒ void
FuseFS api
This method returns an undefined value.
Read sz bytes from file at path (or filehandle raw) starting at offset off
276 |
# File 'lib/fuse/fusedir.rb', line 276 def raw_read(path,offset,size,raw=nil);end |
#raw_sync(path, datasync, raw = nil) ⇒ Object
Sync buffered data to your filesystem
288 |
# File 'lib/fuse/fusedir.rb', line 288 def raw_sync(path,datasync,raw=nil);end |
#raw_truncate(path, offset, raw) ⇒ void #raw_truncate(path, offset) ⇒ Boolean
FuseFS api
RFuseFS extension.
266 |
# File 'lib/fuse/fusedir.rb', line 266 def raw_truncate(path,offset,raw=nil);end |
#raw_write(path, off, sz, buf, raw = nil) ⇒ void
FuseFS api
This method returns an undefined value.
Write sz bytes from file at path (or filehandle raw) starting at offset off
281 |
# File 'lib/fuse/fusedir.rb', line 281 def raw_write(path,off,sz,buf,raw=nil);end |
#read_file(path) ⇒ String
FuseFS api
Returns the contents of the file at path.
189 |
# File 'lib/fuse/fusedir.rb', line 189 def read_file(path);return "";end |
#rename(from_path, to_path) ⇒ Boolean
FuseFS api
Move a file or directory.
236 |
# File 'lib/fuse/fusedir.rb', line 236 def rename(from_path,to_path);end |
#rmdir(path) ⇒ void
FuseFS api
This method returns an undefined value.
Remove the directory at path
225 |
# File 'lib/fuse/fusedir.rb', line 225 def rmdir(path);end |
#scan_path(path) ⇒ Array<String>
base,*rest = scan_path(path)
157 158 159 |
# File 'lib/fuse/fusedir.rb', line 157 def scan_path(path) path.scan(/[^\/]+/) end |
#sigint ⇒ void
This method returns an undefined value.
Handle the INT signal and exit the filesystem
|
# File 'lib/fuse/fusedir.rb', line 130
|
#sigterm ⇒ void
This method returns an undefined value.
Handle the TERM signal and exit the filesystem
138 |
# File 'lib/fuse/fusedir.rb', line 138 INIT_TIMES = Array.new(3,0) |
#size(path) ⇒ Integer
FuseFS api
File size
180 |
# File 'lib/fuse/fusedir.rb', line 180 def size(path); read_file(path).length ;end |
#split_path(path) ⇒ Array<String,String>
base,rest = split_path(path)
145 146 147 148 149 150 151 152 |
# File 'lib/fuse/fusedir.rb', line 145 def split_path(path) cur, *rest = path.scan(/[^\/]+/) if rest.empty? [ cur, nil ] else [ cur, File::SEPARATOR + File.join(rest) ] end end |
#statistics(path) ⇒ Array<Integer>, RFuse::StatVfs
FuseFS api
RFuseFS extensions. File system statistics
312 |
# File 'lib/fuse/fusedir.rb', line 312 def statistics(path); [0,0,0,0]; end |
#times(path) ⇒ Array<Integer, Time>
FuseFS api
File time information. RFuseFS extension.
185 |
# File 'lib/fuse/fusedir.rb', line 185 def times(path);return INIT_TIMES;end |
#touch(path, modtime) ⇒ void
FuseFS api
This method returns an undefined value.
Neat toy. Called when a file is touched or has its timestamp explicitly modified
230 |
# File 'lib/fuse/fusedir.rb', line 230 def touch(path,modtime);end |
#unmounted ⇒ void
This method returns an undefined value.
RFuseFS extension. Called when the filesystem is unmounted
322 |
# File 'lib/fuse/fusedir.rb', line 322 def unmounted();end |
#write_to(path, str) ⇒ void
FuseFS api
This method returns an undefined value.
Write the contents of str to file at path
198 |
# File 'lib/fuse/fusedir.rb', line 198 def write_to(path,str);end |
#xattr(path) ⇒ Hash
FuseFS api
RFuseFS extension. Extended attributes.
302 |
# File 'lib/fuse/fusedir.rb', line 302 def xattr(path); {} ; end |