rfuse-ng 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
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.2.0"
8
+ gem.version = "0.3.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/filler.c CHANGED
@@ -6,7 +6,6 @@ VALUE rfiller_initialize(VALUE self){
6
6
  return self;
7
7
  }
8
8
 
9
-
10
9
  VALUE rfiller_new(VALUE class){
11
10
  VALUE self;
12
11
  struct filler_t *f;
@@ -14,7 +13,7 @@ VALUE rfiller_new(VALUE class){
14
13
  return self;
15
14
  }
16
15
 
17
- VALUE rfiller_push(VALUE self,VALUE name, VALUE stat,VALUE offset) {
16
+ VALUE rfiller_push(VALUE self, VALUE name, VALUE stat, VALUE offset) {
18
17
  struct filler_t *f;
19
18
  Data_Get_Struct(self,struct filler_t,f);
20
19
  struct stat st;
@@ -24,10 +23,22 @@ VALUE rfiller_push(VALUE self,VALUE name, VALUE stat,VALUE offset) {
24
23
  return self;
25
24
  }
26
25
 
26
+ VALUE rfiller_push_old(VALUE self, VALUE name, VALUE type, VALUE inode) {
27
+ printf("Called rfilter_push_old\n");
28
+ struct filler_t *f;
29
+ Data_Get_Struct(self,struct filler_t,f);
30
+ // TODO: architecture dependent int types
31
+ printf("Before df\n");
32
+ f->df(f->dh, STR2CSTR(name), NUM2INT(type), NUM2INT(inode));
33
+ printf("After df\n");
34
+ return self;
35
+ }
36
+
27
37
  VALUE rfiller_init(VALUE module) {
28
38
  VALUE cFiller=rb_define_class_under(module,"Filler",rb_cObject);
29
39
  rb_define_alloc_func(cFiller,rfiller_new);
30
40
  rb_define_method(cFiller,"initialize",rfiller_initialize,0);
31
41
  rb_define_method(cFiller,"push",rfiller_push,3);
42
+ rb_define_method(cFiller,"push_old",rfiller_push_old,3);
32
43
  return cFiller;
33
44
  }
data/ext/filler.h CHANGED
@@ -3,11 +3,14 @@
3
3
 
4
4
  struct filler_t {
5
5
  fuse_fill_dir_t filler;
6
- void *buffer;
6
+ void *buffer;
7
+ fuse_dirh_t dh;
8
+ fuse_dirfil_t df;
7
9
  };
8
10
 
9
11
  VALUE rfiller_initialize(VALUE self);
10
12
  VALUE rfiller_new(VALUE class);
11
- VALUE rfiller_push(VALUE self,VALUE name, VALUE stat,VALUE offset);
13
+ VALUE rfiller_push(VALUE self, VALUE name, VALUE stat, VALUE offset);
14
+ VALUE rfiller_push_old(VALUE self, VALUE name, VALUE type, VALUE inode);
12
15
 
13
16
  VALUE rfiller_init(VALUE module);
data/ext/helper.c CHANGED
@@ -12,9 +12,34 @@ void rstat2stat(VALUE rstat, struct stat *statbuf){
12
12
  statbuf->st_blksize=NUM2ULONG(rb_funcall(rstat,rb_intern("blksize"),0));
13
13
  statbuf->st_blocks=NUM2ULONG(rb_funcall(rstat,rb_intern("blocks"),0));
14
14
  statbuf->st_atime=NUM2ULONG(rb_funcall(rb_funcall(rstat,
15
- rb_intern("atime"),0),rb_intern("to_i"),0));
15
+ rb_intern("atime"),0),rb_intern("to_i"),0));
16
16
  statbuf->st_mtime=NUM2ULONG(rb_funcall(rb_funcall(rstat,
17
17
  rb_intern("mtime"),0),rb_intern("to_i"),0));
18
18
  statbuf->st_ctime=NUM2ULONG(rb_funcall(rb_funcall(rstat,
19
19
  rb_intern("ctime"),0),rb_intern("to_i"),0));
20
20
  };
21
+
22
+ struct fuse_args * rarray2fuseargs(VALUE rarray){
23
+
24
+ Check_Type(rarray, T_ARRAY);
25
+
26
+ struct fuse_args *args = malloc(sizeof(struct fuse_args));
27
+
28
+ args->argc = RARRAY(rarray)->len;
29
+ args->argv = malloc(args->argc * sizeof(char *) + 1);
30
+ /* Nope, this isn't really 'allocated'. The elements
31
+ * of this array shouldn't be freed */
32
+ args->allocated = 0;
33
+
34
+ int i;
35
+ VALUE v;
36
+ for(i = 0; i < args->argc; i++) {
37
+ v = RARRAY(rarray)->ptr[i];
38
+ Check_Type(v, T_STRING);
39
+ args->argv[i] = STR2CSTR(RSTRING(v));
40
+ }
41
+ args->argv[args->argc] = NULL;
42
+
43
+ return args;
44
+ }
45
+
data/ext/helper.h CHANGED
@@ -1,7 +1,11 @@
1
1
  #include <sys/stat.h>
2
2
  #include <ruby.h>
3
+ #include <fuse.h>
3
4
 
4
5
  #ifndef _RHUSE_HELPER_H
5
6
  #define _RHUSE_HELPER_H
7
+
6
8
  void rstat2stat(VALUE rstat,struct stat *statbuf);
9
+ struct fuse_args * rarray2fuseargs(VALUE rarray);
10
+
7
11
  #endif