Check-in [ebf9995a42]
Overview
Comment:More rework
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ebf9995a423432fd2f2544b1f2180155206949e8
User & Date: rkeene on 2014-09-08 03:18:13
Other Links: manifest | tags
Context
2014-09-08
04:25
Working on creating an SQLite interface check-in: 676f99c72e user: rkeene tags: trunk
03:18
More rework check-in: ebf9995a42 user: rkeene tags: trunk
02:55
Removed warnings check-in: eed618f01c user: rkeene tags: trunk
Changes

Modified appfs.c from [09f9ed7337] to [4ce583b799].

     3      3   #include <string.h>
     4      4   #include <stdarg.h>
     5      5   #include <errno.h>
     6      6   #include <fcntl.h>
     7      7   #include <stdio.h>
     8      8   #include <fuse.h>
     9      9   #include <tcl.h>
           10  +
           11  +#define APPFS_CACHEDIR "/tmp/appfs-cache"
    10     12   
    11     13   #define APPFS_DEBUG(x...) { fprintf(stderr, "%i:%s: ", __LINE__, __func__); fprintf(stderr, x); fprintf(stderr, "\n"); }
    12     14   
    13     15   Tcl_Interp *interp;
    14     16   
    15     17   typedef enum {
    16     18   	APPFS_OS_UNKNOWN,
................................................................................
   159    161   
   160    162   static int appfs_getfile(const char *hostname, const char *sha1) {
   161    163   }
   162    164   
   163    165   static int appfs_getmanifest(const char *hostname, const char *sha1) {
   164    166   }
   165    167   
   166         -static int appfs_getattr(const char *path, struct stat *stbuf) {
          168  +static int appfs_fuse_getattr(const char *path, struct stat *stbuf) {
   167    169   	int res = 0;
   168    170   
   169    171   	APPFS_DEBUG("Enter (path = %s, ...)", path);
   170    172   
   171    173   	memset(stbuf, 0, sizeof(struct stat));
   172    174   
   173    175   	stbuf->st_mode = S_IFDIR | 0755;
   174    176   	stbuf->st_nlink = 2;
   175    177   
   176    178   	return res;
   177    179   }
   178    180   
   179         -static int appfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) {
          181  +static int appfs_fuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) {
   180    182   	APPFS_DEBUG("Enter (path = %s, ...)", path);
   181    183   
   182    184   	filler(buf, ".", NULL, 0);
   183    185   	filler(buf, "..", NULL, 0);
   184    186   
   185    187   	return 0;
   186    188   }
   187    189   
   188         -static int appfs_open(const char *path, struct fuse_file_info *fi) {
          190  +static int appfs_fuse_open(const char *path, struct fuse_file_info *fi) {
   189    191   	return(-ENOENT);
   190    192   }
   191    193   
   192         -static int appfs_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
          194  +static int appfs_fuse_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
   193    195   	return(-ENOENT);
   194    196   }
   195    197   
   196    198   #ifdef APPFS_TEST_DRIVER
   197    199   static int appfs_test_driver(void) {
   198    200   	struct appfs_package *packages;
   199    201   	int packages_count = 0;
................................................................................
   206    208   	}
   207    209   
   208    210   	return(0);
   209    211   }
   210    212   #endif
   211    213   
   212    214   static struct fuse_operations appfs_oper = {
   213         -	.getattr	= appfs_getattr,
   214         -	.readdir	= appfs_readdir,
   215         -	.open		= appfs_open,
   216         -	.read		= appfs_read,
          215  +	.getattr	= appfs_fuse_getattr,
          216  +	.readdir	= appfs_fuse_readdir,
          217  +	.open		= appfs_fuse_open,
          218  +	.read		= appfs_fuse_read
   217    219   };
   218    220   
   219    221   int main(int argc, char **argv) {
          222  +	const char *cachedir = APPFS_CACHEDIR;
   220    223   	int tcl_ret;
   221    224   
   222    225   	interp = Tcl_CreateInterp();
   223    226   	if (interp == NULL) {
   224    227   		fprintf(stderr, "Unable to create Tcl Interpreter.  Aborting.\n");
   225    228   
   226    229   		return(1);
................................................................................
   234    237   	}
   235    238   
   236    239   	tcl_ret = Tcl_Eval(interp, ""
   237    240   #include "appfs.tcl.h"
   238    241   	"");
   239    242   	if (tcl_ret != TCL_OK) {
   240    243   		fprintf(stderr, "Unable to initialize Tcl AppFS script.  Aborting.\n");
          244  +		fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp));
          245  +
          246  +		return(1);
          247  +	}
          248  +
          249  +	if (Tcl_SetVar(interp, "::appfs::cachedir", cachedir, TCL_GLOBAL_ONLY) == NULL) {
          250  +		fprintf(stderr, "Unable to set cache directory.  This should never fail.\n");
   241    251   
   242    252   		return(1);
   243    253   	}
   244    254   
   245    255   	tcl_ret = appfs_Tcl_Eval(interp, 1, "::appfs::init");
   246    256   	if (tcl_ret != TCL_OK) {
   247    257   		fprintf(stderr, "Unable to initialize Tcl AppFS script (::appfs::init).  Aborting.\n");