Class: GitRoom::Mounter

Inherits:
Object show all
Includes:
NodeCached, Test::Unit::Assertions
Defined in:
lib/gitroom/mounter.rb

Constant Summary

Constants included from NodeCached

NodeCached::CACHE_FILES, NodeCached::EXPIRE_TIME, NodeCached::MAX_FILE_SIZE, NodeCached::READ_SCORE, NodeCached::WRITE_SCORE

Instance Method Summary collapse

Methods included from NodeCached

#cache_file!, #cached_file_clean!, #cached_file_content, #cached_file_content_expires, #cached_file_content_touch!, #cached_file_rank, #cached_file_rank_change!, #cached_node_absent!, #cached_node_present!, #cached_node_present?, #find_cached_node, #read_cached_node, #write_cached_node

Instance Method Details

#chmod(ctx, path, mode) ⇒ Object



44
45
46
47
# 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) ⇒ Object



49
50
51
52
# 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) ⇒ Object



21
22
23
24
25
26
27
28
29
# 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) ⇒ Object



123
124
125
126
# File 'lib/gitroom/mounter.rb', line 123

def getxattr(ctx, path, name)
  find_node path
  @node.getxattr(name) || ''
end

#init(ctx, rfuseconninfo) ⇒ Object



168
169
170
171
172
# 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) ⇒ Object



155
156
157
158
# 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) ⇒ Object



128
129
130
131
# File 'lib/gitroom/mounter.rb', line 128

def listxattr(ctx, path)
  find_node path
  @node.listxattr
end

#mkdir(ctx, path, mode) ⇒ Object



31
32
33
34
# 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) ⇒ Object



36
37
38
39
# 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) ⇒ Object



41
42
# File 'lib/gitroom/mounter.rb', line 41

def open(ctx, path, ffi)
end

#poll(ctx, path, ffi, ph, reventsp) ⇒ Object



160
161
162
163
164
165
166
# 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) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
# 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) ⇒ Object



14
15
16
17
18
19
# 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) ⇒ Object



133
134
135
136
# File 'lib/gitroom/mounter.rb', line 133

def removexattr(ctx, path, name)
  find_node path
  @node.removexattr name
end

#rename(ctx, path, as) ⇒ Object

def link(ctx, path, as) end



85
86
87
88
89
90
91
# 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) ⇒ Object



71
72
73
74
75
# 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) ⇒ Object



118
119
120
121
# 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) ⇒ Object



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# 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) ⇒ Object



54
55
56
57
58
# 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


65
66
67
68
69
# 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) ⇒ Object



60
61
62
63
# 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) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
# 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