@@ -5,10 +5,12 @@ #include #include #include #include #include + +#define APPFS_CACHEDIR "/tmp/appfs-cache" #define APPFS_DEBUG(x...) { fprintf(stderr, "%i:%s: ", __LINE__, __func__); fprintf(stderr, x); fprintf(stderr, "\n"); } Tcl_Interp *interp; @@ -161,11 +163,11 @@ } static int appfs_getmanifest(const char *hostname, const char *sha1) { } -static int appfs_getattr(const char *path, struct stat *stbuf) { +static int appfs_fuse_getattr(const char *path, struct stat *stbuf) { int res = 0; APPFS_DEBUG("Enter (path = %s, ...)", path); memset(stbuf, 0, sizeof(struct stat)); @@ -174,24 +176,24 @@ stbuf->st_nlink = 2; return res; } -static int appfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { +static int appfs_fuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { APPFS_DEBUG("Enter (path = %s, ...)", path); filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0); return 0; } -static int appfs_open(const char *path, struct fuse_file_info *fi) { +static int appfs_fuse_open(const char *path, struct fuse_file_info *fi) { return(-ENOENT); } -static int appfs_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { +static int appfs_fuse_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { return(-ENOENT); } #ifdef APPFS_TEST_DRIVER static int appfs_test_driver(void) { @@ -208,17 +210,18 @@ return(0); } #endif static struct fuse_operations appfs_oper = { - .getattr = appfs_getattr, - .readdir = appfs_readdir, - .open = appfs_open, - .read = appfs_read, + .getattr = appfs_fuse_getattr, + .readdir = appfs_fuse_readdir, + .open = appfs_fuse_open, + .read = appfs_fuse_read }; int main(int argc, char **argv) { + const char *cachedir = APPFS_CACHEDIR; int tcl_ret; interp = Tcl_CreateInterp(); if (interp == NULL) { fprintf(stderr, "Unable to create Tcl Interpreter. Aborting.\n"); @@ -236,10 +239,17 @@ tcl_ret = Tcl_Eval(interp, "" #include "appfs.tcl.h" ""); if (tcl_ret != TCL_OK) { fprintf(stderr, "Unable to initialize Tcl AppFS script. Aborting.\n"); + fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp)); + + return(1); + } + + if (Tcl_SetVar(interp, "::appfs::cachedir", cachedir, TCL_GLOBAL_ONLY) == NULL) { + fprintf(stderr, "Unable to set cache directory. This should never fail.\n"); return(1); } tcl_ret = appfs_Tcl_Eval(interp, 1, "::appfs::init");