Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
fizx committed Sep 18, 2009
1 parent 4411351 commit b8b78a4
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 280 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
.DS_Store
coverage
rdoc
pkg
pkg
*.o
*.bundle
*.log
Makefile
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ begin
gem.email = "[email protected]"
gem.homepage = "http://github.com/fizx/fusefs"
gem.authors = ["Kyle Maxwell"]
gem.extensions = ["ext/extconf.rb"]
end
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
Expand Down
157 changes: 0 additions & 157 deletions ext/Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion ext/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'mkmf'
dir_config('fusefs_lib.so')
if have_library('fuse')
if have_library('fuse_ino64') || have_library('fuse')
create_makefile('fusefs_lib')
else
puts "No FUSE install available"
Expand Down
68 changes: 20 additions & 48 deletions ext/fusefs_fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
/* This is rewriting most of the things that occur
* in fuse_main up through fuse_loop */

#define FUSE_USE_VERSION 22
#define FUSE_USE_VERSION 26
#define _FILE_OFFSET_BITS 64

#include <fuse.h>
/* #include "fuse_i.h"
#include "fuse_compat.h"
#include "fuse_kernel.h"
#include "fuse_kernel_compat5.h" */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
Expand All @@ -24,25 +19,32 @@
#include <sys/uio.h>
#include <signal.h>

struct fuse * fuse_instance = NULL;
static unsigned int fusefd;
struct fuse *fuse_instance = NULL;
struct fuse_chan *fusech = NULL;
static char *mounted_at = NULL;

static int set_one_signal_handler(int signal, void (*handler)(int));

int fusefs_fd() {
return fusefd;
if(fusech == NULL)
return -1;
return fuse_chan_fd(fusech);
}

int
fusefs_unmount() {
char buf[128];

if (mounted_at && fusech) {
fuse_unmount(mounted_at, fusech);
sprintf(buf, "/sbin/umount %s", mounted_at);
system(buf);
}
if (fuse_instance)
fuse_destroy(fuse_instance);
fuse_instance = NULL;
if (mounted_at)
fuse_unmount(mounted_at);
free(mounted_at);
fusefd = -1;
fusech = NULL;
}

static void
Expand All @@ -53,38 +55,8 @@ fusefs_ehandler() {
}

int
fusefs_setup(char *mountpoint, const struct fuse_operations *op, char *opts) {
char fuse_new_opts[1024];
char fuse_mount_opts[1024];
char nopts[1024];

char *cur;
char *ptr;

fuse_new_opts[0] = '\0';
fuse_mount_opts[0] = '\0';

for (cur=opts;cur;cur = ptr) {
ptr = strchr(cur,',');
if (ptr) *(ptr++) = '\0';
if (fuse_is_lib_option(cur)) {
if (fuse_new_opts[0]) {
strcpy(nopts,fuse_new_opts);
snprintf(fuse_new_opts,1024,"%s,%s",nopts,cur);
} else {
snprintf(fuse_new_opts,1024,"%s",cur);
}
} else {
if (fuse_mount_opts[0]) {
strcpy(nopts,fuse_mount_opts);
snprintf(fuse_mount_opts,1024,"%s,%s",nopts,cur);
} else {
snprintf(fuse_mount_opts,1024,"%s",cur);
}
}
}

fusefd = -1;
fusefs_setup(char *mountpoint, const struct fuse_operations *op, struct fuse_args *opts) {
fusech = NULL;
if (fuse_instance != NULL) {
return 0;
}
Expand All @@ -93,10 +65,10 @@ fusefs_setup(char *mountpoint, const struct fuse_operations *op, char *opts) {
}

/* First, mount us */
fusefd = fuse_mount(mountpoint, fuse_mount_opts[0] ? fuse_mount_opts : NULL);
if (fusefd == -1) return 0;
fusech = fuse_mount(mountpoint, opts);
if (fusech == NULL) return 0;

fuse_instance = fuse_new(fusefd, fuse_new_opts[0] ? fuse_new_opts : NULL, op, sizeof(*op));
fuse_instance = fuse_new(fusech, opts, op, sizeof(*op), NULL);
if (fuse_instance == NULL)
goto err_unmount;

Expand All @@ -115,7 +87,7 @@ fusefs_setup(char *mountpoint, const struct fuse_operations *op, char *opts) {
err_destroy:
fuse_destroy(fuse_instance);
err_unmount:
fuse_unmount(mountpoint);
fuse_unmount(mountpoint, fusech);
return 0;
}

Expand Down
4 changes: 3 additions & 1 deletion ext/fusefs_fuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
#ifndef __FUSEFS_FUSE_H_
#define __FUSEFS_FUSE_H_

struct fuse_args;

int fusefs_fd();
int fusefs_unmount();
int fusefs_ehandler();
int fusefs_setup(char *mountpoint, const struct fuse_operations *op, char *opts);
int fusefs_setup(char *mountpoint, const struct fuse_operations *op, struct fuse_args *opts);
int fusefs_process();
int fusefs_uid();
int fusefs_gid();
Expand Down
Binary file removed ext/fusefs_fuse.o
Binary file not shown.
Binary file removed ext/fusefs_lib.bundle
Binary file not shown.
Loading

0 comments on commit b8b78a4

Please sign in to comment.