Diff

Differences From Artifact [a9240a597b]:

To Artifact [16b07e2510]:


   253    253   	if (retval != TCL_OK) {
   254    254   		APPFS_DEBUG("Tcl command failed, ::errorInfo contains: %s\n", Tcl_GetVar(interp, "::errorInfo", 0));
   255    255   	}
   256    256   
   257    257   	return(retval);
   258    258   }
   259    259   
   260         -/*
   261         - * AppFS: Request that a host's package index be updated locally
   262         - */
   263         -static void appfs_update_index(const char *hostname) {
   264         -	Tcl_Interp *interp;
   265         -	int tcl_ret;
   266         -
   267         -	APPFS_DEBUG("Enter: hostname = %s", hostname);
   268         -
   269         -	interp = appfs_TclInterp();
   270         -	if (interp == NULL) {
   271         -		return;
   272         -	}
   273         -
   274         -	tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::getindex", hostname);
   275         -	if (tcl_ret != TCL_OK) {
   276         -		APPFS_DEBUG("Call to ::appfs::getindex failed: %s", Tcl_GetStringResult(interp));
   277         -
   278         -		return;
   279         -	}
   280         -
   281         -	return;
   282         -}
   283         -
   284         -/*
   285         - * AppFS: Get a SHA1 from a host
   286         - *         Returns a local file name, or NULL if it cannot be fetched
   287         - */
   288         -static const char *appfs_getfile(const char *hostname, const char *sha1) {
   289         -	Tcl_Interp *interp;
   290         -	char *retval;
   291         -	int tcl_ret;
   292         -
   293         -	interp = appfs_TclInterp();
   294         -	if (interp == NULL) {
   295         -		return(NULL);
   296         -	}
   297         -
   298         -	tcl_ret = appfs_Tcl_Eval(interp, 3, "::appfs::download", hostname, sha1);
   299         -	if (tcl_ret != TCL_OK) {
   300         -		APPFS_DEBUG("Call to ::appfs::download failed: %s", Tcl_GetStringResult(interp));
   301         -
   302         -		return(NULL);
   303         -	}
   304         -
   305         -	retval = strdup(Tcl_GetStringResult(interp));
   306         -
   307         -	return(retval);
   308         -}
   309         -
   310         -/*
   311         - * AppFS: Update the manifest for a specific package (by the package SHA1) on
   312         - * a given host
   313         - */
   314         -static void appfs_update_manifest(const char *hostname, const char *sha1) {
   315         -	Tcl_Interp *interp;
   316         -	int tcl_ret;
   317         -
   318         -	interp = appfs_TclInterp();
   319         -	if (interp == NULL) {
   320         -		return;
   321         -	}
   322         -
   323         -	tcl_ret = appfs_Tcl_Eval(interp, 3, "::appfs::getpkgmanifest", hostname, sha1);
   324         -	if (tcl_ret != TCL_OK) {
   325         -		APPFS_DEBUG("Call to ::appfs::getpkgmanifest failed: %s", Tcl_GetStringResult(interp));
   326         -
   327         -		return;
   328         -	}
   329         -
   330         -	return;
   331         -}
   332         -
   333    260   /*
   334    261    * Determine the UID for the user making the current FUSE filesystem request.
   335    262    * This will be used to lookup the user's home directory so we can search for
   336    263    * locally modified files.
   337    264    */
   338    265   static uid_t appfs_get_fsuid(void) {
   339    266   	struct fuse_context *ctx;
................................................................................
   481    408   
   482    409   static int appfs_fuse_getattr(const char *path, struct stat *stbuf) {
   483    410   	struct appfs_pathinfo pathinfo;
   484    411   	int res = 0;
   485    412   
   486    413   	APPFS_DEBUG("Enter (path = %s, ...)", path);
   487    414   
   488         -	pathinfo.type = APPFS_PATHTYPE_INVALID;
   489         -
   490         -	res = appfs_get_path_info(path, &pathinfo, NULL);
   491         -	if (res != 0) {
   492         -		return(res);
   493         -	}
          415  +	pathinfo.type = APPFS_PATHTYPE_DIRECTORY;
          416  +	pathinfo.typeinfo.dir.childcount = 0;
   494    417   
   495    418   	memset(stbuf, 0, sizeof(struct stat));
   496    419   
   497    420   	stbuf->st_mtime = pathinfo.time;
   498    421   	stbuf->st_ctime = pathinfo.time;
   499    422   	stbuf->st_atime = pathinfo.time;
   500    423   	stbuf->st_ino   = pathinfo.inode;
................................................................................
   532    455   		}
   533    456   	}
   534    457   
   535    458   	return res;
   536    459   }
   537    460   
   538    461   static int appfs_fuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) {
   539         -	struct appfs_pathinfo pathinfo;
   540         -	struct appfs_children *children, *child;
          462  +	Tcl_Interp *interp;
          463  +	Tcl_Obj **children;
          464  +	int children_count, idx;
          465  +	int tcl_ret;
   541    466   	int retval;
   542    467   
   543    468   	APPFS_DEBUG("Enter (path = %s, ...)", path);
   544    469   
   545         -	retval = appfs_get_path_info(path, &pathinfo, &children);
   546         -	if (retval != 0) {
   547         -		return(retval);
          470  +	interp = appfs_TclInterp();
          471  +	if (interp == NULL) {
          472  +		return(0);
   548    473   	}
   549    474   
   550    475   	filler(buf, ".", NULL, 0);
   551    476   	filler(buf, "..", NULL, 0);
   552    477   
   553         -	for (child = children; child; child = child->_next) {
   554         -		filler(buf, child->name, NULL, 0);
          478  +
          479  +	tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::getchildren", path);
          480  +	if (tcl_ret != TCL_OK) {
          481  +		APPFS_DEBUG("::appfs::getchildren(%s) failed.", path);
          482  +		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
          483  +		
          484  +		return(0);
   555    485   	}
   556    486   
   557         -//	appfs_free_list_children(children);
          487  +	tcl_ret = Tcl_ListObjGetElements(interp, Tcl_GetObjResult(interp), &children_count, &children);
          488  +	if (tcl_ret != TCL_OK) {
          489  +		APPFS_DEBUG("Parsing list of children on path %s failed.", path);
          490  +		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
          491  +		
          492  +		return(0);
          493  +	}
          494  +
          495  +	for (idx = 0; idx < children_count; idx++) {
          496  +		filler(buf, Tcl_GetString(children[idx]), NULL, 0);
          497  +	}
   558    498   
   559    499   	return(0);
   560    500   }
   561    501   
   562    502   static int appfs_fuse_open(const char *path, struct fuse_file_info *fi) {
   563    503   	struct appfs_pathinfo pathinfo;
   564    504   	const char *real_path;