rfuse-ng 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/CHANGELOG.txt +2 -0
- data/LICENSE +482 -0
- data/README.ng +11 -0
- data/README.rfuse +57 -0
- data/Rakefile +23 -0
- data/THANKS +1 -0
- data/TODO.txt +6 -0
- data/ext/context.c +47 -0
- data/ext/context.h +5 -0
- data/ext/extconf.rb +12 -0
- data/ext/file_info.c +45 -0
- data/ext/file_info.h +11 -0
- data/ext/filler.c +33 -0
- data/ext/filler.h +13 -0
- data/ext/helper.c +20 -0
- data/ext/helper.h +7 -0
- data/ext/intern_rfuse.c +32 -0
- data/ext/intern_rfuse.h +21 -0
- data/ext/rfuse.c +864 -0
- data/ext/rfuse.h +3 -0
- data/ext/rfuse_mod.c +12 -0
- data/sample/test-ruby.rb +353 -0
- data/test/runtest +7 -0
- metadata +82 -0
data/ext/file_info.c
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#include "file_info.h"
|
2
|
+
#include <fuse.h>
|
3
|
+
|
4
|
+
|
5
|
+
VALUE wrap_file_info(struct fuse_file_info *ffi) {
|
6
|
+
VALUE rRFuse;
|
7
|
+
VALUE rFileInfo;
|
8
|
+
rRFuse=rb_const_get(rb_cObject,rb_intern("RFuse"));
|
9
|
+
rFileInfo=rb_const_get(rRFuse,rb_intern("FileInfo"));
|
10
|
+
return Data_Wrap_Struct(rFileInfo,0,0,ffi); //shouldn't be freed!
|
11
|
+
|
12
|
+
};
|
13
|
+
|
14
|
+
|
15
|
+
VALUE file_info_initialize(VALUE self){
|
16
|
+
return self;
|
17
|
+
}
|
18
|
+
|
19
|
+
VALUE file_info_new(VALUE class){
|
20
|
+
VALUE self;
|
21
|
+
struct fuse_file_info *f;
|
22
|
+
self = Data_Make_Struct(class, struct fuse_file_info, 0,NULL,f);
|
23
|
+
return self;
|
24
|
+
}
|
25
|
+
|
26
|
+
VALUE file_info_writepage(VALUE self) {
|
27
|
+
struct fuse_file_info *f;
|
28
|
+
Data_Get_Struct(self,struct fuse_file_info,f);
|
29
|
+
return INT2FIX(f->writepage);
|
30
|
+
}
|
31
|
+
|
32
|
+
VALUE file_info_flags(VALUE self) {
|
33
|
+
struct fuse_file_info *f;
|
34
|
+
Data_Get_Struct(self,struct fuse_file_info,f);
|
35
|
+
return INT2FIX(f->flags);
|
36
|
+
}
|
37
|
+
|
38
|
+
VALUE file_info_init(VALUE module) {
|
39
|
+
VALUE cFileInfo=rb_define_class_under(module,"FileInfo",rb_cObject);
|
40
|
+
rb_define_alloc_func(cFileInfo,file_info_new);
|
41
|
+
rb_define_method(cFileInfo,"initialize",file_info_initialize,0);
|
42
|
+
rb_define_method(cFileInfo,"flags",file_info_flags,0);
|
43
|
+
rb_define_method(cFileInfo,"writepage",file_info_writepage,0);
|
44
|
+
return cFileInfo;
|
45
|
+
}
|
data/ext/file_info.h
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#include <fuse.h>
|
2
|
+
#include <ruby.h>
|
3
|
+
|
4
|
+
VALUE wrap_file_info(struct fuse_file_info *ffi);
|
5
|
+
|
6
|
+
VALUE file_info_initialize(VALUE self);
|
7
|
+
VALUE file_info_new(VALUE class);
|
8
|
+
VALUE file_info_flags(VALUE self);
|
9
|
+
VALUE file_info_writepage(VALUE self);
|
10
|
+
|
11
|
+
VALUE file_info_init(VALUE module);
|
data/ext/filler.c
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#include "filler.h"
|
2
|
+
#include <fuse.h>
|
3
|
+
#include "helper.h"
|
4
|
+
|
5
|
+
VALUE rfiller_initialize(VALUE self){
|
6
|
+
return self;
|
7
|
+
}
|
8
|
+
|
9
|
+
|
10
|
+
VALUE rfiller_new(VALUE class){
|
11
|
+
VALUE self;
|
12
|
+
struct filler_t *f;
|
13
|
+
self = Data_Make_Struct(class, struct filler_t, 0,free,f);
|
14
|
+
return self;
|
15
|
+
}
|
16
|
+
|
17
|
+
VALUE rfiller_push(VALUE self,VALUE name, VALUE stat,VALUE offset) {
|
18
|
+
struct filler_t *f;
|
19
|
+
Data_Get_Struct(self,struct filler_t,f);
|
20
|
+
struct stat st;
|
21
|
+
memset(&st, 0, sizeof(st));
|
22
|
+
rstat2stat(stat,&st);
|
23
|
+
f->filler(f->buffer,STR2CSTR(name),&st,NUM2LONG(offset));
|
24
|
+
return self;
|
25
|
+
}
|
26
|
+
|
27
|
+
VALUE rfiller_init(VALUE module) {
|
28
|
+
VALUE cFiller=rb_define_class_under(module,"Filler",rb_cObject);
|
29
|
+
rb_define_alloc_func(cFiller,rfiller_new);
|
30
|
+
rb_define_method(cFiller,"initialize",rfiller_initialize,0);
|
31
|
+
rb_define_method(cFiller,"push",rfiller_push,3);
|
32
|
+
return cFiller;
|
33
|
+
}
|
data/ext/filler.h
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#include <fuse.h>
|
2
|
+
#include <ruby.h>
|
3
|
+
|
4
|
+
struct filler_t {
|
5
|
+
fuse_fill_dir_t filler;
|
6
|
+
void *buffer;
|
7
|
+
};
|
8
|
+
|
9
|
+
VALUE rfiller_initialize(VALUE self);
|
10
|
+
VALUE rfiller_new(VALUE class);
|
11
|
+
VALUE rfiller_push(VALUE self,VALUE name, VALUE stat,VALUE offset);
|
12
|
+
|
13
|
+
VALUE rfiller_init(VALUE module);
|
data/ext/helper.c
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#include "helper.h"
|
2
|
+
|
3
|
+
void rstat2stat(VALUE rstat, struct stat *statbuf){
|
4
|
+
statbuf->st_dev=FIX2ULONG(rb_funcall(rstat,rb_intern("dev"),0));
|
5
|
+
statbuf->st_ino=FIX2ULONG(rb_funcall(rstat,rb_intern("ino"),0));
|
6
|
+
statbuf->st_mode=FIX2UINT(rb_funcall(rstat,rb_intern("mode"),0));
|
7
|
+
statbuf->st_nlink=FIX2UINT(rb_funcall(rstat,rb_intern("nlink"),0));
|
8
|
+
statbuf->st_uid=FIX2UINT(rb_funcall(rstat,rb_intern("uid"),0));
|
9
|
+
statbuf->st_gid=FIX2UINT(rb_funcall(rstat,rb_intern("gid"),0));
|
10
|
+
statbuf->st_rdev=FIX2ULONG(rb_funcall(rstat,rb_intern("rdev"),0));
|
11
|
+
statbuf->st_size=FIX2ULONG(rb_funcall(rstat,rb_intern("size"),0));
|
12
|
+
statbuf->st_blksize=NUM2ULONG(rb_funcall(rstat,rb_intern("blksize"),0));
|
13
|
+
statbuf->st_blocks=NUM2ULONG(rb_funcall(rstat,rb_intern("blocks"),0));
|
14
|
+
statbuf->st_atime=NUM2ULONG(rb_funcall(rb_funcall(rstat,
|
15
|
+
rb_intern("atime"),0),rb_intern("to_i"),0));
|
16
|
+
statbuf->st_mtime=NUM2ULONG(rb_funcall(rb_funcall(rstat,
|
17
|
+
rb_intern("mtime"),0),rb_intern("to_i"),0));
|
18
|
+
statbuf->st_ctime=NUM2ULONG(rb_funcall(rb_funcall(rstat,
|
19
|
+
rb_intern("ctime"),0),rb_intern("to_i"),0));
|
20
|
+
};
|
data/ext/helper.h
ADDED
data/ext/intern_rfuse.c
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#include <stdlib.h>
|
2
|
+
#include <string.h>
|
3
|
+
#include <fuse.h>
|
4
|
+
#include "intern_rfuse.h"
|
5
|
+
|
6
|
+
struct intern_fuse *intern_fuse_new() {
|
7
|
+
struct intern_fuse *inf;
|
8
|
+
inf = (struct intern_fuse *) malloc(sizeof(struct intern_fuse));
|
9
|
+
return inf;
|
10
|
+
};
|
11
|
+
|
12
|
+
int intern_fuse_destroy(struct intern_fuse *inf){
|
13
|
+
//you have to take care, that fuse is unmounted yourself!
|
14
|
+
fuse_destroy(inf->fuse);
|
15
|
+
free(inf);
|
16
|
+
return 0;
|
17
|
+
};
|
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)
|
26
|
+
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);
|
31
|
+
return 0;
|
32
|
+
};
|
data/ext/intern_rfuse.h
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
#include <fuse.h>
|
3
|
+
|
4
|
+
#define MOUNTNAME_MAX 1024
|
5
|
+
struct intern_fuse {
|
6
|
+
int fd;
|
7
|
+
struct fuse *fuse;
|
8
|
+
struct fuse_operations fuse_op;
|
9
|
+
struct fuse_context *fuse_ctx;
|
10
|
+
char mountname[MOUNTNAME_MAX];
|
11
|
+
int state; //created,mounted,running
|
12
|
+
};
|
13
|
+
|
14
|
+
struct intern_fuse *intern_fuse_new();
|
15
|
+
|
16
|
+
int intern_fuse_init(struct intern_fuse *inf,
|
17
|
+
const char *mountpoint,
|
18
|
+
const char *kernelopts,
|
19
|
+
const char *libopts);
|
20
|
+
|
21
|
+
int intern_fuse_destroy(struct intern_fuse *inf);
|