class GitRoom::Mounter
Public Instance Methods
chmod(ctx, path, mode)
click to toggle source
# File lib/gitroom/mounter.rb, line 44 def chmod(ctx, path, mode) find_node path @node.update_attributes! :mode => mode end
chown(ctx, path, uid, gid)
click to toggle source
# File lib/gitroom/mounter.rb, line 49 def chown(ctx, path, uid, gid) find_node path @node.update_attributes! :uid => uid, :gid => gid end
getattr(ctx, path)
click to toggle source
# File lib/gitroom/mounter.rb, line 21 def getattr(ctx, path) find_node path begin @node.stat rescue print "Unexpected in stat #{path}" enoent(path) end end
getxattr(ctx, path, name)
click to toggle source
# File lib/gitroom/mounter.rb, line 123 def getxattr(ctx, path, name) find_node path @node.getxattr(name) || '' end
init(ctx,rfuseconninfo)
click to toggle source
# File lib/gitroom/mounter.rb, line 168 def init(ctx,rfuseconninfo) print "RFuse TestFS started\n" print "init called\n" print "proto_major:#{rfuseconninfo.proto_major}\n" end
ioctl(ctx, path, cmd, arg, ffi, flags, data)
click to toggle source
# File lib/gitroom/mounter.rb, line 155 def ioctl(ctx, path, cmd, arg, ffi, flags, data) # FT: I was not been able to test it. print "*** IOCTL: command: ", cmd, "\n" end
listxattr(ctx, path)
click to toggle source
# File lib/gitroom/mounter.rb, line 128 def listxattr(ctx, path) find_node path @node.listxattr end
mkdir(ctx, path, mode)
click to toggle source
# File lib/gitroom/mounter.rb, line 31 def mkdir(ctx, path, mode) update_node path, mode cached_node_present! path end
mknod(ctx, path, mode, major, minor)
click to toggle source
# File lib/gitroom/mounter.rb, line 36 def mknod(ctx, path, mode, major, minor) update_node path, mode, ctx.uid, ctx.gid, false, '' cached_node_present! path end
open(ctx, path, ffi)
click to toggle source
# File lib/gitroom/mounter.rb, line 41 def open(ctx, path, ffi) end
poll(ctx, path, ffi, ph, reventsp)
click to toggle source
# File lib/gitroom/mounter.rb, line 160 def poll(ctx, path, ffi, ph, reventsp) print "*** POLL: ", path, "\n" # This is how we notify the caller if something happens: ph.notifyPoll # when the GC harvests the object it calls fuse_pollhandle_destroy # by itself. end
read(ctx, path, size, offset, fi)
click to toggle source
# File lib/gitroom/mounter.rb, line 93 def read(ctx, path, size, offset, fi) find_node path eisdir(path) if @node.directory res = '' begin res = read_cached_node @node, size, offset rescue print "Unexpected in read #{path}: #{$!}\n" enoent(path) end res end
readdir(ctx, path, filler, offset, ffi)
click to toggle source
# File lib/gitroom/mounter.rb, line 14 def readdir(ctx, path, filler, offset, ffi) find_node path @node.nodes.each do |node| filler.push node.name, node.stat, 0 end end
removexattr(ctx, path, name)
click to toggle source
# File lib/gitroom/mounter.rb, line 133 def removexattr(ctx, path, name) find_node path @node.removexattr name end
rename(ctx, path, as)
click to toggle source
def link(ctx, path, as) end
# File lib/gitroom/mounter.rb, line 85 def rename(ctx, path, as) find_node path move_node(@node, as) cached_node_absent! path cached_node_absent! as cached_node_present! as end
rmdir(ctx, path)
click to toggle source
# File lib/gitroom/mounter.rb, line 71 def rmdir(ctx, path) find_node path @node.destroy cached_node_absent! path end
setxattr(ctx, path, name, value, size, flags)
click to toggle source
# File lib/gitroom/mounter.rb, line 118 def setxattr(ctx, path, name, value, size, flags) find_node path @node.setxattr name, value, flags end
statfs(ctx,path)
click to toggle source
# File lib/gitroom/mounter.rb, line 139 def statfs(ctx,path) s = RFuse::StatVfs.new s.f_bsize = 1024 s.f_frsize = 1024 s.f_blocks = 1000000 s.f_bfree = 500000 s.f_bavail = 990000 s.f_files = 10000 s.f_ffree = 9900 s.f_favail = 9900 s.f_fsid = 23423 s.f_flag = 0 s.f_namemax = 10000 return s end
truncate(ctx, path, offset)
click to toggle source
# File lib/gitroom/mounter.rb, line 54 def truncate(ctx, path, offset) find_node path # @node.update_attributes! :content => @node.content[0..offset] @node.truncate_content offset end
unlink(ctx, path)
click to toggle source
# File lib/gitroom/mounter.rb, line 65 def unlink(ctx, path) find_node path @node.destroy cached_node_absent! path end
utime(ctx, path, actime, modtime)
click to toggle source
# File lib/gitroom/mounter.rb, line 60 def utime(ctx, path, actime, modtime) find_node path @node.update_attributes! :updated_at => Time.at([actime, modtime].max) end
write(ctx, path, buf, offset, fi)
click to toggle source
# File lib/gitroom/mounter.rb, line 106 def write(ctx, path, buf, offset, fi) find_node path eisdir(path) if @node.directory begin write_cached_node @node, buf, offset rescue print "Unexpected in write #{path}: #{$!}\n" enoent(path) end buf.size end
Private Instance Methods
eisdir(path = nil)
click to toggle source
# File lib/gitroom/mounter.rb, line 227 def eisdir(path = nil) # print "Raising eisdir #{path}\n" raise Errno::EISDIR.new(path) end
enoent(path = nil)
click to toggle source
# File lib/gitroom/mounter.rb, line 217 def enoent(path = nil) # print "Raising enoent #{path}\n" raise Errno::ENOENT.new(path) end
enotdir(path = nil)
click to toggle source
# File lib/gitroom/mounter.rb, line 222 def enotdir(path = nil) # print "Raising enotdir #{path}\n" raise Errno::ENOTDIR.new(path) end
find_node(path, ignore = false)
click to toggle source
# File lib/gitroom/mounter.rb, line 176 def find_node(path, ignore = false) @node = nil # @node = Node.where(:path => path).first @node = find_cached_node(path) enoent(path) if @node.nil? && !ignore @node end
move_node(node, path)
click to toggle source
# File lib/gitroom/mounter.rb, line 211 def move_node(node, path) nodes = split_dirnode(path) nodes[:node] && nodes[:node].destroy node.update_attributes! :path => path, :node_id => nodes[:dirnode].id, :name => nodes[:name] end
split_dirnode(path)
click to toggle source
# File lib/gitroom/mounter.rb, line 203 def split_dirnode(path) names = split_dirpath path node = find_node path, true dirnode = find_node names[:dirname] enotdir(path) unless dirnode.directory { :node => node, :dirnode => dirnode, :name => names[:name], :dirname => names[:dirname] } end
split_dirpath(path)
click to toggle source
# File lib/gitroom/mounter.rb, line 198 def split_dirpath(path) pathname = Pathname.new path { :name => pathname.basename.to_s, :dirname => pathname.dirname.to_s } end
update_node(path, mode, uid = nil, gid = nil, directory = true, content = nil)
click to toggle source
# File lib/gitroom/mounter.rb, line 184 def update_node(path, mode, uid = nil, gid = nil, directory = true, content = nil) nodes = split_dirnode(path) uid ||= nodes[:dirnode].uid gid ||= nodes[:dirnode].gid nodes[:node] ||= if directory Node.create! :name => nodes[:name], :path => path, :directory => true, :node_id => nodes[:dirnode].id, :mode => mode, :uid => uid, :gid => gid else Node.create! :name => nodes[:name], :path => path, :directory => false, :node_id => nodes[:dirnode].id, :mode => mode end end