return res;
}
-static int xmp_statfs(struct statfs *fst)
+static int xmp_statfs(struct fuse_statfs *fst)
{
struct statfs st;
int rv = statfs("/",&st);
- if(!rv)
- memcpy(fst,&st,sizeof(st));
+ if(!rv) {
+ fst->block_size = st.f_bsize;
+ fst->blocks = st.f_blocks;
+ fst->blocks_free = st.f_bavail;
+ fst->files = st.f_files;
+ fst->files_free = st.f_ffree;
+ fst->namelen = st.f_namelen;
+ }
return rv;
}
return size;
}
-static int null_statfs(struct statfs *st)
+static int null_statfs(struct fuse_statfs *st)
{
- return st->f_blocks = st->f_bavail = st->f_bsize = st->f_files =
- st->f_ffree = st->f_namelen = 0;
+ return st->block_size = st->blocks = st->blocks_free = st->files =
+ st->files_free = st->namelen = 0;
}
static struct fuse_operations null_oper = {
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/statfs.h>
#include <utime.h>
+#include "fusestat.h"
/* ----------------------------------------------------------- *
* Basic FUSE API *
* ----------------------------------------------------------- */
int (*open) (const char *, int);
int (*read) (const char *, char *, size_t, off_t);
int (*write) (const char *, const char *, size_t, off_t);
- int (*statfs) (struct statfs *);
+ int (*statfs) (struct fuse_statfs *);
};
/** Extra context that may be needed by some filesystems */
--- /dev/null
+#ifndef __FUSESTAT_H_
+#define __FUSESTAT_H_
+/* this is seperated out into its own file because both
+ * kernel and lib use it, but neither can #include the
+ * other's headerfile */
+typedef struct fuse_statfs {
+ long block_size;
+ long blocks;
+ long blocks_free;
+ long files;
+ long files_free;
+ long namelen;
+} fuse_statfs_t;
+#endif
/* This file defines the kernel interface of FUSE */
+#include "fusestat.h"
/** Version number of this interface */
#define FUSE_KERNEL_VERSION 2
char buf[0];
};
-typedef struct fuse_statfs {
- long block_size;
- long blocks;
- long blocks_free;
- long files;
- long files_free;
- long namelen;
-} fuse_statfs_t;
-
struct fuse_statfs_out {
struct fuse_statfs st;
};
attr->_dummy = 4096;
}
-static void convert_statfs(struct statfs *st, struct fuse_statfs *fst)
-{
- fst->block_size = st->f_bsize;
- fst->blocks = st->f_blocks;
- fst->blocks_free = st->f_bavail;
- fst->files = st->f_files;
- fst->files_free = st->f_ffree;
- fst->namelen = st->f_namelen;
-}
-
static int fill_dir(struct fuse_dirhandle *dh, char *name, int type)
{
struct fuse_dirent dirent;
static void do_statfs(struct fuse *f, struct fuse_in_header *in)
{
int res;
- struct statfs sbuf;
struct fuse_statfs_out arg;
res = -ENOSYS;
if(f->op.statfs)
- res = f->op.statfs(&sbuf);
- if(res == 0)
- convert_statfs(&sbuf,&arg.st);
+ res = f->op.statfs(&arg.st);
send_reply(f, in, res, &arg, sizeof(arg));
}
else
rv = -ENOENT;
} else {
+ DEBUGf("populating\n");
result->st_blocks = POPi;
result->st_blksize = POPi;
result->st_ctime = POPi;
FREETMPS;
LEAVE;
PUTBACK;
+ DEBUGf("getattr end %i %o\n",rv,result->st_mode);
return rv;
}
return rv;
}
-int _PLfuse_statfs (struct statfs *st) {
+int _PLfuse_statfs (struct fuse_statfs *st) {
int rv;
char *rvstr;
dSP;
rv = call_sv(_PLfuse_callbacks[17],G_ARRAY);
SPAGAIN;
if(rv > 5) {
- st->f_bsize = POPi;
- st->f_bavail = st->f_bfree = POPi;
- st->f_blocks = POPi;
- st->f_ffree = POPi;
- st->f_files = POPi;
- st->f_namelen = POPi;
+ st->block_size = POPi;
+ st->blocks_free = POPi;
+ st->blocks = POPi;
+ st->files_free = POPi;
+ st->files = POPi;
+ st->namelen = POPi;
if(rv > 6)
rv = POPi;
else
sub x_getattr {
my ($file) = fixup(shift);
- return -ENOENT() unless -e $file;
- return (lstat($file));
+ my (@list) = lstat($file);
+ return -$! unless @list;
+ return @list;
}
sub x_getdir {
sub x_write {
my ($file,$buf,$off) = @_;
- debug("write",@_);
+ debug("write",$file,length($buf),$off);
my ($rv);
return -ENOENT() unless -e ($file = fixup($file));
return -ENOSYS() unless sysopen(FILE,$file,O_RDWR()|O_APPEND()|O_CREAT());
sub err { return (-shift || -$!) }
sub x_readlink { return readlink(fixup(shift) ); }
-sub x_unlink { return unlink(fixup(shift)) ? 0 : -$!; }
-sub x_rmdir { return err(rmdir(fixup(shift)) ); }
-sub x_symlink { return err(symlink(fixup(shift),fixup(shift))); }
-sub x_rename { return err(rename(fixup(shift),fixup(shift)) ); }
-sub x_link { return err(link(fixup(shift),fixup(shift)) ); }
-sub x_chmod { return err(chmod(fixup(shift),shift) ); }
-sub x_chown { return err(chown(fixup(shift),shift,shift) ); }
-sub x_chmod { return err(chmod(fixup(shift),shift) ); }
+sub x_unlink { return unlink(fixup(shift)) ? 0 : -$!; }
+sub x_rmdir { return err(rmdir(fixup(shift)) ); }
+sub x_symlink { return err(symlink(fixup(shift),fixup(shift))); }
+sub x_rename {
+ debug("rename",@_);
+ my ($old) = fixup(shift);
+ my ($new) = fixup(shift);
+ my ($err) = rename($old,$new) ? 0 : -ENOENT();
+ debug("old=$old,new=$new,err=$err");
+ return $err;
+}
+sub x_link { return err(link(fixup(shift),fixup(shift)) ); }
+sub x_chown {
+ debug("chown",@_);
+ my ($fn) = fixup(shift);
+ my ($uid,$gid) = @_;
+ my ($err) = chown($uid,$gid,$fn) ? 0 : -$!;
+ debug("fn=$fn,uid=$uid,gid=$gid,err=$err");
+ return $err;
+}
+sub x_chmod {
+ debug("chmod",@_);
+ my ($fn) = fixup(shift);
+ my ($mode) = shift;
+ my ($err) = chmod($mode,$fn) ? 0 : -$!;
+ debug("fn=$fn,mode=$mode,err=$err");
+ return $err;
+}
sub x_truncate { return truncate(fixup(shift),shift) ? 0 : -$! ; }
-sub x_utime { return utime($_[1],$_[2],fixup($_[0])) ? 0:-$!; }
+sub x_utime { return utime($_[1],$_[2],fixup($_[0])) ? 0:-$!; }
sub x_mkdir { my ($name, $perm) = @_; return 0 if mkdir(fixup($name),$perm); return -$!; }
sub x_rmdir { return 0 if rmdir fixup(shift); return -$!; }
}
}
+# kludge
+sub x_statfs {return 255,1000000,500000,1000000,500000,4096}
my ($mountpoint) = "";
$mountpoint = shift(@ARGV) if @ARGV;
Fuse::main(
unthreaded=>1,
- debug=>1,
mountpoint=>$mountpoint,
getattr=>\&x_getattr,
readlink=>\&x_readlink,
utime=>\&x_utime,
open=>\&x_open,
read=>\&x_read,
- write=>\&x_write
+ write=>\&x_write,
+ statfs=>\&x_statfs
);