rfuse-ng 0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.txt CHANGED
@@ -1,2 +1,10 @@
1
- 2010-05-01: 0.1 Froked from rfuse, fixed compile warnings, gemified.
1
+ 2010-05-01: 0.2.0
2
2
 
3
+ Switched to Fuse API 26 from 22. Fixed incompatibilities.
4
+ Arranged fuse_op filling code, made a TODO list of missing
5
+ functions.
6
+
7
+
8
+ 2010-05-01: 0.1
9
+
10
+ Froked from rfuse, fixed compile warnings, gemified.
data/README.ng CHANGED
@@ -1,3 +1,6 @@
1
+ INTRO
2
+ =====
3
+
1
4
  This project was forked from rfuse, a great FUSE language
2
5
  binding for Ruby.
3
6
 
@@ -8,4 +11,13 @@ important operations.
8
11
  The rfuse project was probably abandoned in 2005, this is
9
12
  why I have started this project.
10
13
 
14
+ DEPENDENCIES
15
+ ============
16
+
17
+ ruby 1.8
18
+ fuse 2.8
19
+
20
+ AUTHOR
21
+ ======
22
+
11
23
  Tamás László Fábián <giganetom@gmail.com>
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "rfuse-ng"
8
- gem.version = "0.1"
8
+ gem.version = "0.2.0"
9
9
  gem.summary = 'Ruby language binding for FUSE'
10
10
  gem.description = 'Ruby language binding for FUSE. It was forked from rfuse'
11
11
  gem.rubyforge_project = 'rfuse-ng'
data/ext/extconf.rb CHANGED
@@ -3,7 +3,7 @@ require 'mkmf'
3
3
  $CFLAGS << ' -Wall'
4
4
  $CFLAGS << ' -Werror'
5
5
  $CFLAGS << ' -D_FILE_OFFSET_BITS=64'
6
- $CFLAGS << ' -DFUSE_USE_VERSION=22'
6
+ $CFLAGS << ' -DFUSE_USE_VERSION=26'
7
7
 
8
8
  if have_library('fuse')
9
9
  create_makefile('rfuse_ng')
data/ext/intern_rfuse.c CHANGED
@@ -16,17 +16,27 @@ int intern_fuse_destroy(struct intern_fuse *inf){
16
16
  return 0;
17
17
  };
18
18
 
19
- int intern_fuse_init(struct intern_fuse *inf,
20
- const char *mountpoint,
21
- const char *kernelopts,
22
- const char *libopts) {
23
- int fd;
24
- fd=fuse_mount(mountpoint,kernelopts);
25
- if (fd==-1)
19
+ int intern_fuse_init(
20
+ struct intern_fuse *inf,
21
+ const char *mountpoint,
22
+ struct fuse_args *kernelopts,
23
+ struct fuse_args *libopts)
24
+ {
25
+ struct fuse_chan* fc;
26
+
27
+ fc = fuse_mount(mountpoint, kernelopts);
28
+
29
+ if (fc == NULL) {
30
+ return -1;
31
+ }
32
+
33
+ inf->fuse=fuse_new(fc, libopts, &(inf->fuse_op), sizeof(struct fuse_operations), NULL);
34
+ inf->fc = fc;
35
+
36
+ if (strlen(inf->mountname) > MOUNTNAME_MAX) {
26
37
  return -1;
27
- inf->fuse=fuse_new(fd,libopts,&(inf->fuse_op),sizeof(struct fuse_operations));
28
- inf->fd=fd;
29
- //TODO: check length
30
- strncpy(inf->mountname,mountpoint,MOUNTNAME_MAX);
38
+ }
39
+
40
+ strncpy(inf->mountname, mountpoint, MOUNTNAME_MAX);
31
41
  return 0;
32
42
  };
data/ext/intern_rfuse.h CHANGED
@@ -1,9 +1,9 @@
1
-
2
1
  #include <fuse.h>
3
2
 
4
3
  #define MOUNTNAME_MAX 1024
4
+
5
5
  struct intern_fuse {
6
- int fd;
6
+ struct fuse_chan *fc;
7
7
  struct fuse *fuse;
8
8
  struct fuse_operations fuse_op;
9
9
  struct fuse_context *fuse_ctx;
@@ -13,9 +13,11 @@ struct intern_fuse {
13
13
 
14
14
  struct intern_fuse *intern_fuse_new();
15
15
 
16
- int intern_fuse_init(struct intern_fuse *inf,
17
- const char *mountpoint,
18
- const char *kernelopts,
19
- const char *libopts);
16
+ int intern_fuse_init(
17
+ struct intern_fuse *inf,
18
+ const char *mountpoint,
19
+ struct fuse_args *args,
20
+ struct fuse_args *libopts
21
+ );
20
22
 
21
23
  int intern_fuse_destroy(struct intern_fuse *inf);
data/ext/rfuse.c CHANGED
@@ -28,6 +28,7 @@ static int unsafe_return_error(VALUE *args){
28
28
  printf ("ERROR %s\n",STR2CSTR(info));
29
29
  return rb_funcall(info,rb_intern("errno"),0);
30
30
  }
31
+
31
32
  static int return_error(int def_error){
32
33
  /*if the raised error has a method errno the return that value else
33
34
  return def(ault)_error */
@@ -51,12 +52,12 @@ static VALUE unsafe_readdir(VALUE *args){
51
52
  VALUE ffi = values[3];
52
53
  struct fuse_context *ctx = fuse_get_context();
53
54
  return rb_funcall(fuse_object,rb_intern("readdir"),5,wrap_context(ctx),path,filler,
54
- offset,ffi);
55
+ offset,ffi);
55
56
  }
56
57
 
57
58
  //call readdir with an Filler object
58
59
  static int rf_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
59
- off_t offset,struct fuse_file_info *ffi)
60
+ off_t offset,struct fuse_file_info *ffi)
60
61
  {
61
62
  VALUE fuse_module;
62
63
  VALUE rfiller_class;
@@ -112,7 +113,7 @@ static int rf_readlink(const char *path, char *buf, size_t size)
112
113
  return 0;
113
114
  }
114
115
  }
115
- //-----------------------------------------
116
+ //----------------------------GETATTR
116
117
  static VALUE unsafe_getattr(VALUE *args){
117
118
  VALUE *values=(VALUE*)args;
118
119
  VALUE path = values[0];
@@ -486,7 +487,7 @@ static VALUE unsafe_read(VALUE *args){
486
487
  VALUE ffi = values[3];
487
488
  struct fuse_context *ctx=fuse_get_context();
488
489
  return rb_funcall(fuse_object,rb_intern("read"),5,
489
- wrap_context(ctx),path,size,offset,ffi);
490
+ wrap_context(ctx),path,size,offset,ffi);
490
491
  }
491
492
 
492
493
  static int rf_read(const char *path,char * buf, size_t size,off_t offset,struct fuse_file_info *ffi)
@@ -526,7 +527,7 @@ static VALUE unsafe_write(VALUE *args){
526
527
  VALUE ffi = values[4];
527
528
  struct fuse_context *ctx=fuse_get_context();
528
529
  return rb_funcall(fuse_object,rb_intern("write"),6,
529
- wrap_context(ctx),path,buffer,size,offset,ffi);
530
+ wrap_context(ctx),path,buffer,size,offset,ffi);
530
531
  }
531
532
 
532
533
  static int rf_write(const char *path,const char *buf,size_t size, off_t offset,struct fuse_file_info *ffi)
@@ -557,11 +558,11 @@ static VALUE unsafe_setxattr(VALUE *args){
557
558
  VALUE flags = values[4];
558
559
  struct fuse_context *ctx=fuse_get_context();
559
560
  return rb_funcall(fuse_object,rb_intern("setxattr"),6,
560
- wrap_context(ctx),path,name,value,size,flags);
561
+ wrap_context(ctx),path,name,value,size,flags);
561
562
  }
562
563
 
563
564
  static int rf_setxattr(const char *path,const char *name,
564
- const char *value, size_t size, int flags)
565
+ const char *value, size_t size, int flags)
565
566
  {
566
567
  VALUE args[5];
567
568
  VALUE res;
@@ -587,11 +588,11 @@ static VALUE unsafe_getxattr(VALUE *args){
587
588
  VALUE size = values[2];
588
589
  struct fuse_context *ctx=fuse_get_context();
589
590
  return rb_funcall(fuse_object,rb_intern("getxattr"),4,
590
- wrap_context(ctx),path,name,size);
591
+ wrap_context(ctx),path,name,size);
591
592
  }
592
593
 
593
594
  static int rf_getxattr(const char *path,const char *name,char *buf,
594
- size_t size)
595
+ size_t size)
595
596
  {
596
597
  VALUE args[3];
597
598
  VALUE res;
@@ -621,11 +622,11 @@ static VALUE unsafe_listxattr(VALUE *args){
621
622
  VALUE size = values[1];
622
623
  struct fuse_context *ctx=fuse_get_context();
623
624
  return rb_funcall(fuse_object,rb_intern("listxattr"),3,
624
- wrap_context(ctx),path,size);
625
+ wrap_context(ctx),path,size);
625
626
  }
626
627
 
627
628
  static int rf_listxattr(const char *path,char *buf,
628
- size_t size)
629
+ size_t size)
629
630
  {
630
631
  VALUE args[2];
631
632
  VALUE res;
@@ -641,9 +642,9 @@ static int rf_listxattr(const char *path,char *buf,
641
642
  rbuf=rb_str2cstr(res,(long *)&length); //TODO protect this, too
642
643
  if (buf != NULL){
643
644
  if (length<=size) {
644
- memcpy(buf,rbuf,length); //check for size
645
+ memcpy(buf,rbuf,length); //check for size
645
646
  } else {
646
- return -ERANGE;
647
+ return -ERANGE;
647
648
  }
648
649
  printf("destination: %s,%d\n",buf,size);
649
650
  printf("source: %s,%d\n",rbuf,length);
@@ -663,7 +664,7 @@ static VALUE unsafe_removexattr(VALUE *args){
663
664
  VALUE name = values[1];
664
665
  struct fuse_context *ctx=fuse_get_context();
665
666
  return rb_funcall(fuse_object,rb_intern("removexattr"),3,
666
- wrap_context(ctx),path,name);
667
+ wrap_context(ctx),path,name);
667
668
  }
668
669
 
669
670
  static int rf_removexattr(const char *path,const char *name)
@@ -737,7 +738,7 @@ static VALUE unsafe_fsyncdir(VALUE *args){
737
738
  VALUE ffi = values[2];
738
739
  struct fuse_context *ctx=fuse_get_context();
739
740
  return rb_funcall(fuse_object,rb_intern("fsyncdir"),3,wrap_context(ctx),path,
740
- meta,ffi);
741
+ meta,ffi);
741
742
  }
742
743
 
743
744
  static int rf_fsyncdir(const char *path,int meta,struct fuse_file_info *ffi)
@@ -781,7 +782,7 @@ VALUE rf_exit(VALUE self){
781
782
  VALUE rf_unmount(VALUE self){
782
783
  struct intern_fuse *inf;
783
784
  Data_Get_Struct(self,struct intern_fuse,inf);
784
- fuse_unmount(inf->mountname);
785
+ fuse_unmount(inf->mountname, inf->fc);
785
786
  return Qnil;
786
787
  }
787
788
 
@@ -798,46 +799,88 @@ VALUE rf_invalidate(VALUE self,VALUE path){
798
799
  //-------------RUBY
799
800
 
800
801
 
801
- static VALUE rf_initialize(VALUE self,VALUE mountpoint,VALUE kernelopts,
802
- VALUE libopts) {
802
+ static struct fuse_args * rarray2fuseargs(VALUE rarray){
803
+
804
+ Check_Type(rarray, T_ARRAY);
805
+
806
+ struct fuse_args *args = malloc(sizeof(struct fuse_args));
807
+
808
+ args->argc = RARRAY(rarray)->len;
809
+ args->argv = malloc(args->argc * sizeof(char *) + 1);
810
+ /* Nope, this isn't really 'allocated'. The elements
811
+ * of this array shouldn't be freed */
812
+ args->allocated = 0;
813
+
814
+ int i;
815
+ VALUE v;
816
+ for(i = 0; i < args->argc; i++) {
817
+ v = RARRAY(rarray)->ptr[i];
818
+ Check_Type(v, T_STRING);
819
+ args->argv[i] = STR2CSTR(RSTRING(v));
820
+ }
821
+ args->argv[args->argc] = NULL;
822
+
823
+ return args;
824
+ }
825
+
826
+ static VALUE rf_initialize(
827
+ VALUE self,
828
+ VALUE mountpoint,
829
+ VALUE kernelopts,
830
+ VALUE libopts)
831
+ {
832
+ Check_Type(mountpoint, T_STRING);
833
+
803
834
  struct intern_fuse *inf;
804
835
  Data_Get_Struct(self,struct intern_fuse,inf);
805
- inf->fuse_op.getattr=rf_getattr;
806
- // inf->fuse_op.getdir=rf_getdir;
807
- inf->fuse_op.readlink=rf_readlink;
808
- inf->fuse_op.mkdir=rf_mkdir;
809
- inf->fuse_op.mknod=rf_mknod;
810
- inf->fuse_op.open=rf_open;
811
- inf->fuse_op.release=rf_release; //optional
812
- inf->fuse_op.flush=rf_flush; //optional
813
- inf->fuse_op.chmod=rf_chmod; //setattr
814
- inf->fuse_op.chown=rf_chown; //setattr
815
- inf->fuse_op.truncate=rf_truncate;//setattr
816
- inf->fuse_op.utime=rf_utime; //settattr
817
- inf->fuse_op.unlink=rf_unlink;
818
- inf->fuse_op.rmdir=rf_rmdir;
819
- inf->fuse_op.symlink=rf_symlink;
820
- inf->fuse_op.rename=rf_rename;
821
- inf->fuse_op.link=rf_link;
822
- inf->fuse_op.read=rf_read;
823
- inf->fuse_op.write=rf_write;
824
- inf->fuse_op.setxattr=rf_setxattr;
825
- inf->fuse_op.getxattr=rf_getxattr;
826
- inf->fuse_op.listxattr=rf_listxattr;
827
- inf->fuse_op.removexattr=rf_removexattr;
828
- inf->fuse_op.readdir=rf_readdir;
829
- inf->fuse_op.opendir=rf_opendir;
830
- inf->fuse_op.releasedir=rf_releasedir;
831
- inf->fuse_op.fsyncdir=rf_fsyncdir;
832
-
833
- /* TODO
834
- inf->fuse_op.statfs=rf_statfs;
835
- inf->fuse_op.fsnyc=rf_fsync; //option
836
- */
836
+ inf->fuse_op.getattr = rf_getattr;
837
+ inf->fuse_op.readlink = rf_readlink;
838
+ inf->fuse_op.mknod = rf_mknod;
839
+ inf->fuse_op.mkdir = rf_mkdir;
840
+ inf->fuse_op.unlink = rf_unlink;
841
+ inf->fuse_op.rmdir = rf_rmdir;
842
+ inf->fuse_op.symlink = rf_symlink;
843
+ inf->fuse_op.rename = rf_rename;
844
+ inf->fuse_op.link = rf_link;
845
+ inf->fuse_op.chmod = rf_chmod;
846
+ inf->fuse_op.chown = rf_chown;
847
+ inf->fuse_op.truncate = rf_truncate;
848
+ inf->fuse_op.utime = rf_utime; // Deprecated, use utimens instead
849
+ inf->fuse_op.open = rf_open;
850
+ inf->fuse_op.read = rf_read;
851
+ inf->fuse_op.write = rf_write;
852
+ //inf->fuse_op.statfs = rf_statfs; // TODO
853
+ inf->fuse_op.flush = rf_flush;
854
+ inf->fuse_op.release = rf_release;
855
+ //inf->fuse_op.fsnyc = rf_fsync; // TODO
856
+ inf->fuse_op.setxattr = rf_setxattr;
857
+ inf->fuse_op.getxattr = rf_getxattr;
858
+ inf->fuse_op.listxattr = rf_listxattr;
859
+ inf->fuse_op.removexattr = rf_removexattr;
860
+ inf->fuse_op.opendir = rf_opendir;
861
+ inf->fuse_op.readdir = rf_readdir;
862
+ inf->fuse_op.releasedir = rf_releasedir;
863
+ inf->fuse_op.fsyncdir = rf_fsyncdir;
864
+ //inf->fuse_op.init = rf_init;
865
+ //inf->fuse_op.destroy = rf_destroy;
866
+ //inf->fuse_op.access = rf_access;
867
+ //inf->fuse_op.create = rf_create;
868
+ //inf->fuse_op.ftruncate = rf_ftruncate;
869
+ //inf->fuse_op.fgetattr = rf_fgetattr;
870
+ //inf->fuse_op.lock = rf_lock;
871
+ //inf->fuse_op.utimens = rf_utimens;
872
+ //inf->fuse_op.bmap = rf_bmap;
873
+ //inf->fuse_op.ioctl = rf_ioctl;
874
+ //inf->fuse_op.poll = rf_poll;
875
+
876
+ struct fuse_args
877
+ *kargs = rarray2fuseargs(kernelopts),
878
+ *largs = rarray2fuseargs(libopts);
879
+
880
+ intern_fuse_init(inf, STR2CSTR(mountpoint), kargs, largs);
837
881
 
838
- intern_fuse_init(inf,STR2CSTR(mountpoint),STR2CSTR(kernelopts),
839
- STR2CSTR(libopts));
840
882
  fuse_object=self; // this won't work with multithreading!!!
883
+
841
884
  return self;
842
885
  }
843
886
 
@@ -852,7 +895,7 @@ static VALUE rf_new(VALUE class){
852
895
  VALUE rfuse_init(VALUE module){
853
896
  VALUE cFuse=rb_define_class_under(module,"Fuse",rb_cObject);
854
897
  rb_define_alloc_func(cFuse,rf_new);
855
- //initialize: string mountpoint,string kernel_opts,string lib_opts
898
+ //initialize: string mountpoint,array kernel_opts,array lib_opts
856
899
  rb_define_method(cFuse,"initialize",rf_initialize,3);
857
900
  rb_define_method(cFuse,"loop",rf_loop,0);
858
901
  //rb_define_method(cFuse,"loop_mt",rf_loop_mt,0); TODO: not until RIKE!
data/sample/test-ruby.rb CHANGED
@@ -121,218 +121,233 @@ class MyFile
121
121
  end
122
122
 
123
123
  #TODO: atime,mtime,ctime...nicer classes not only fixnums
124
- class Stat
125
- attr_accessor :uid,:gid,:mode,:size,:atime,:mtime,:ctime
126
- attr_accessor :dev,:ino,:nlink,:rdev,:blksize,:blocks
127
- def initialize(uid,gid,mode,size,atime,mtime,ctime,rdev,blocks,nlink,dev,ino,blksize)
128
- @uid=uid
129
- @gid=gid
130
- @mode=mode
131
- @size=size
132
- @atime=atime
133
- @mtime=mtime
134
- @ctime=ctime
135
- @dev=dev
136
- @ino=ino
137
- @nlink=nlink
138
- @rdev=rdev
139
- @blksize=blksize
140
- @blocks=blocks
141
- end
142
- end #class Stat
124
+ class Stat
125
+ attr_accessor :uid,:gid,:mode,:size,:atime,:mtime,:ctime
126
+ attr_accessor :dev,:ino,:nlink,:rdev,:blksize,:blocks
127
+ def initialize(uid,gid,mode,size,atime,mtime,ctime,rdev,blocks,nlink,dev,ino,blksize)
128
+ @uid=uid
129
+ @gid=gid
130
+ @mode=mode
131
+ @size=size
132
+ @atime=atime
133
+ @mtime=mtime
134
+ @ctime=ctime
135
+ @dev=dev
136
+ @ino=ino
137
+ @nlink=nlink
138
+ @rdev=rdev
139
+ @blksize=blksize
140
+ @blocks=blocks
141
+ end
142
+ end #class Stat
143
143
 
144
- module RFuse
145
- class Context
146
- def to_s
147
- 'uid:' + uid.to_s + ' gid:' + gid.to_s + ' pid:' + pid.to_s
148
- end
149
- end
150
- class FileInfo
151
- def to_s
152
- 'File_Info:---' + flags.to_s #+ ' writepage:' + writepage.to_s
153
- end
154
- end
144
+ class MyFuse < RFuse::Fuse
145
+
146
+ def initialize(mnt,kernelopt,libopt,root)
147
+ super(mnt,kernelopt,libopt)
148
+ @root=root
155
149
  end
156
- class MyFuse < RFuse::Fuse
157
- def initialize(mnt,kernelopt,libopt,root)
158
- super(mnt,kernelopt,libopt)
159
- @root=root
160
- end
161
- def readdir(ctx,path,filler,offset,ffi)
162
- puts "readdir:"+path
163
- puts ctx
164
- d=@root.search(path)
165
- if d.isdir then
166
- puts "getdir: listing directory"
167
- d.each {|name,obj|
168
- stat=Stat.new(obj.uid,obj.gid,obj.mode,obj.size,obj.actime,obj.modtime,
169
- 0,0,0,0,0,0,0)
170
- filler.push(name,stat,0)
171
- }
172
- else
173
- raise Errno::ENOTDIR.new(path)
174
- end
175
- end
176
150
 
177
- def getattr(ctx,path)
178
- puts "getattr:" + path
179
- puts ctx
180
- d=@root.search(path)
181
- stat=Stat.new(d.uid,d.gid,d.mode,d.size,d.actime,d.modtime,
182
- 0,0,0,0,0,0,0)
183
- puts d
184
- return stat
185
- end #getattr
186
-
187
- def mkdir(ctx,path,mode)
188
- puts "mkdir:" + path + " Mode:" + mode.to_s
189
- puts ctx
190
- @root.insert_obj(MyDir.new(File.basename(path),mode),path)
191
- end #mkdir
192
-
193
- def mknod(ctx,path,mode,dev)
194
- puts "mknod:" + path + " Mode:" + mode.to_s + " Device:" + dev.to_s
195
- puts ctx
196
- @root.insert_obj(MyFile.new(File.basename(path),mode,ctx.uid,ctx.gid),path)
197
- end #mknod
198
- def open(ctx,path,ffi)
199
- puts "open:" + path
200
- puts ctx
201
- # puts fi
202
- end
203
- def release(ctx,path,fi)
204
- puts "release:" + path
205
- puts ctx
206
- # puts fi
207
- end
208
- def flush(ctx,path,fi)
209
- puts "flush:" + path
210
- puts ctx
211
- # puts fi
212
- end
213
- def chmod(ctx,path,mode)
214
- puts "chmod:" + path + " Mode:" + mode.to_s
215
- puts ctx
216
- d=@root.search(path)
217
- d.mode=mode #TODO: check if this is ok for dir
218
- #raise Errno::EPERM.new(path)
219
- end
220
- def chown(ctx,path,uid,gid)
221
- puts "chown:" + path + " UID:" + uid.to_s + " GID:" + gid.to_s
222
- puts ctx
223
- d=@root.search(path)
224
- d.uid=uid
225
- d.gid=gid
226
- end
227
- def truncate(ctx,path,offset)
228
- puts "truncate:" + path + " offset: " + offset.to_s
229
- puts ctx
230
- end
231
- def utime(ctx,path,actime,modtime)
232
- puts "utime:" + path + " actime:" + actime.to_s +
233
- " modtime:" + modtime.to_s
234
- puts ctx
235
- d=@root.search(path)
236
- d.actime=actime
237
- d.modtime=modtime
238
- end
239
- def unlink(ctx,path)
240
- puts "utime:" + path
241
- puts ctx
242
- end
243
- def rmdir(ctx,path)
244
- puts "rmdir:" + path
245
- puts ctx
246
- end
247
- def symlink(ctx,path,as)
248
- puts "symlink:" + path + " as:" + as
249
- puts ctx
250
- end
251
- def rename(ctx,path,as)
252
- puts "rename:" + path + " as:" + as
253
- puts ctx
254
- end
255
- def link(ctx,path,as)
256
- puts "link:" + path + " as:" + as
257
- puts ctx
258
- end
259
- def read(ctx,path,size,offset,fi)
260
- puts "read:" + path + " size:" + size.to_s + " offset:" + offset.to_s
261
- puts ctx
262
- d=@root.search(path)
263
- if (d.isdir)
264
- raise Errno::EISDIR.new(path)
265
- return nil
266
- else
267
- return d.content
268
- end
151
+ def readdir(ctx,path,filler,offset,ffi)
152
+ puts "readdir:"+path
153
+ puts ctx
154
+ d=@root.search(path)
155
+ if d.isdir then
156
+ puts "getdir: listing directory"
157
+ d.each {|name,obj|
158
+ stat=Stat.new(obj.uid,obj.gid,obj.mode,obj.size,obj.actime,obj.modtime,
159
+ 0,0,0,0,0,0,0)
160
+ filler.push(name,stat,0)
161
+ }
162
+ else
163
+ raise Errno::ENOTDIR.new(path)
269
164
  end
270
- def write(ctx,path,buf,size,offset,fi)
271
- puts "write:" + path + " size:" + size.to_s + " offset:" + offset.to_s
272
- puts ctx
273
- puts "content:" + buf
274
- d=@root.search(path)
275
- if (d.isdir)
276
- raise Errno::EISDIR.new(path)
277
- else
278
- d.content=buf
279
- end
165
+ end
166
+
167
+ def getattr(ctx,path)
168
+ puts "getattr:" + path
169
+ puts ctx
170
+ d=@root.search(path)
171
+ stat=Stat.new(d.uid,d.gid,d.mode,d.size,d.actime,d.modtime,
172
+ 0,0,0,0,0,0,0)
173
+ puts d
174
+ return stat
175
+ end #getattr
176
+
177
+ def mkdir(ctx,path,mode)
178
+ puts "mkdir:" + path + " Mode:" + mode.to_s
179
+ puts ctx
180
+ @root.insert_obj(MyDir.new(File.basename(path),mode),path)
181
+ end #mkdir
182
+
183
+ def mknod(ctx,path,mode,dev)
184
+ puts "mknod:" + path + " Mode:" + mode.to_s + " Device:" + dev.to_s
185
+ puts ctx
186
+ @root.insert_obj(MyFile.new(File.basename(path),mode,ctx.uid,ctx.gid),path)
187
+ end #mknod
188
+
189
+ def open(ctx,path,ffi)
190
+ puts "open:" + path
191
+ puts ctx
192
+ end
193
+
194
+ def release(ctx,path,fi)
195
+ puts "release:" + path
196
+ puts ctx
197
+ end
198
+
199
+ def flush(ctx,path,fi)
200
+ puts "flush:" + path
201
+ puts ctx
202
+ end
203
+
204
+ def chmod(ctx,path,mode)
205
+ puts "chmod:" + path + " Mode:" + mode.to_s
206
+ puts ctx
207
+ d=@root.search(path)
208
+ d.mode=mode #TODO: check if this is ok for dir
209
+ #raise Errno::EPERM.new(path)
210
+ end
211
+
212
+ def chown(ctx,path,uid,gid)
213
+ puts "chown:" + path + " UID:" + uid.to_s + " GID:" + gid.to_s
214
+ puts ctx
215
+ d=@root.search(path)
216
+ d.uid=uid
217
+ d.gid=gid
218
+ end
219
+
220
+ def truncate(ctx,path,offset)
221
+ puts "truncate:" + path + " offset: " + offset.to_s
222
+ puts ctx
223
+ end
224
+
225
+ def utime(ctx,path,actime,modtime)
226
+ puts "utime:" + path + " actime:" + actime.to_s +
227
+ " modtime:" + modtime.to_s
228
+ puts ctx
229
+ d=@root.search(path)
230
+ d.actime=actime
231
+ d.modtime=modtime
232
+ end
233
+
234
+ def unlink(ctx,path)
235
+ puts "utime:" + path
236
+ puts ctx
237
+ end
238
+
239
+ def rmdir(ctx,path)
240
+ puts "rmdir:" + path
241
+ puts ctx
242
+ end
243
+
244
+ def symlink(ctx,path,as)
245
+ puts "symlink:" + path + " as:" + as
246
+ puts ctx
247
+ end
248
+
249
+ def rename(ctx,path,as)
250
+ puts "rename:" + path + " as:" + as
251
+ puts ctx
252
+ end
253
+
254
+ def link(ctx,path,as)
255
+ puts "link:" + path + " as:" + as
256
+ puts ctx
257
+ end
258
+
259
+ def read(ctx,path,size,offset,fi)
260
+ puts "read:" + path + " size:" + size.to_s + " offset:" + offset.to_s
261
+ puts ctx
262
+ d=@root.search(path)
263
+ if (d.isdir)
264
+ raise Errno::EISDIR.new(path)
280
265
  return nil
266
+ else
267
+ return d.content
281
268
  end
282
- def setxattr(ctx,path,name,value,size,flags)
283
- puts "setxattr:" + path + " name:" + name +
284
- " value:" + value.inspect + " size:" + size.to_s + " flags:" + flags.to_s +
285
- " rubysize:" + value.size.to_s
286
- puts ctx
287
- d=@root.search(path)
288
- d.setxattr(name,value,flags)
269
+ end
270
+
271
+ def write(ctx,path,buf,size,offset,fi)
272
+ puts "write:" + path + " size:" + size.to_s + " offset:" + offset.to_s
273
+ puts ctx
274
+ puts "content:" + buf
275
+ d=@root.search(path)
276
+ if (d.isdir)
277
+ raise Errno::EISDIR.new(path)
278
+ else
279
+ d.content=buf
289
280
  end
290
- def getxattr(ctx,path,name,size)
291
- puts "getxattr:" + path + " name:" + name +
292
- " size:" + size.to_s
293
- puts ctx
294
- d=@root.search(path)
295
- if (d)
296
- puts "found:" + d.name
297
- value=d.getxattr(name)
298
- if (value)
299
- puts "return: "+value.to_s + " size:"+value.size.to_s
300
- else
301
- value=""
302
- #raise Errno::ENOENT.new #TODO raise the correct error :
303
- #NOATTR which is not implemented in Linux/glibc
304
- end
305
- else
306
- raise Errno::ENOENT.new #TODO put this into DIR and FILE?
281
+ return nil
282
+ end
283
+
284
+ def setxattr(ctx,path,name,value,size,flags)
285
+ puts
286
+ "setxattr:" + path +
287
+ " name:" + name +
288
+ " value:" + value.inspect +
289
+ " size:" + size.to_s +
290
+ " flags:" + flags.to_s +
291
+ " rubysize:" + value.size.to_s
292
+ puts ctx
293
+ d=@root.search(path)
294
+ d.setxattr(name,value,flags)
295
+ end
296
+
297
+ def getxattr(ctx,path,name,size)
298
+ puts
299
+ "getxattr:" + path +
300
+ " name:" + name +
301
+ " size:" + size.to_s
302
+ puts ctx
303
+ d=@root.search(path)
304
+ if (d)
305
+ puts "found:" + d.name
306
+ value=d.getxattr(name)
307
+ if (value)
308
+ puts "return: "+value.to_s + " size:"+value.size.to_s
309
+ else
310
+ value=""
311
+ #raise Errno::ENOENT.new #TODO raise the correct error :
312
+ #NOATTR which is not implemented in Linux/glibc
307
313
  end
308
- return value
309
- end
310
- def listxattr(ctx,path,size)
311
- puts "listxattr:" + path + " size:" + size.to_s
312
- puts ctx
313
- d=@root.search(path)
314
- value= d.listxattr()
315
- puts "listxattr return: "+ value
316
- return value
317
- end
318
- def removexattr(ctx,path,name)
319
- puts "removexattr:" + path + " name:" + name
320
- puts ctx
321
- d=@root.search(path)
322
- d.removexattr(name)
323
- end
324
- def opendir(ctx,path,ffi)
325
- puts 'opendir:'+ path
326
- end
327
- def releasedir(ctx,path,ffi)
328
- puts 'releasedir:'+ path
329
- end
330
- def fsyncdir(ctx,path,meta,ffi)
331
- puts 'fsyncdir:'+ path
314
+ else
315
+ raise Errno::ENOENT.new #TODO put this into DIR and FILE?
332
316
  end
333
- end #class Fuse
317
+ return value
318
+ end
319
+
320
+ def listxattr(ctx,path,size)
321
+ puts "listxattr:" + path + " size:" + size.to_s
322
+ puts ctx
323
+ d=@root.search(path)
324
+ value= d.listxattr()
325
+ puts "listxattr return: "+ value
326
+ return value
327
+ end
334
328
 
335
- fo=MyFuse.new("/tmp/fuse","allow_other","debug",MyDir.new("",493));
329
+ def removexattr(ctx,path,name)
330
+ puts "removexattr:" + path + " name:" + name
331
+ puts ctx
332
+ d=@root.search(path)
333
+ d.removexattr(name)
334
+ end
335
+
336
+ def opendir(ctx,path,ffi)
337
+ puts 'opendir:'+ path
338
+ end
339
+
340
+ def releasedir(ctx,path,ffi)
341
+ puts 'releasedir:'+ path
342
+ end
343
+
344
+ def fsyncdir(ctx,path,meta,ffi)
345
+ puts 'fsyncdir:'+ path
346
+ end
347
+
348
+ end #class Fuse
349
+
350
+ fo = MyFuse.new("/tmp/fuse",["allow_other"],["debug"], MyDir.new("",493));
336
351
  #kernel: default_permissions,allow_other,kernel_cache,large_read,direct_io
337
352
  # max_read=N,fsname=NAME
338
353
  #library: debug,hard_remove
@@ -349,5 +364,3 @@ rescue
349
364
  f.puts "Error:" + $!
350
365
  f.close
351
366
  end
352
-
353
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfuse-ng
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - !binary |