Diff

Differences From Artifact [ba1c738961]:

To Artifact [6a9a58fb18]:


   552    552   	real_path = Tcl_GetStringResult(interp);
   553    553   	if (real_path == NULL) {
   554    554   		return(NULL);
   555    555   	}
   556    556   
   557    557   	return(strdup(real_path));
   558    558   }
          559  +
          560  +static char *appfs_localpath(const char *path) {
          561  +	Tcl_Interp *interp;
          562  +	const char *real_path;
          563  +	int tcl_ret;
          564  +
          565  +	interp = appfs_TclInterp();
          566  +	if (interp == NULL) {
          567  +		return(NULL);
          568  +	}
          569  +
          570  +	tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::localpath", path);
          571  +	if (tcl_ret != TCL_OK) {
          572  +		APPFS_DEBUG("::appfs::localpath(%s) failed.", path);
          573  +		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
          574  +
          575  +		return(NULL);
          576  +	}
          577  +
          578  +	real_path = Tcl_GetStringResult(interp);
          579  +	if (real_path == NULL) {
          580  +		return(NULL);
          581  +	}
          582  +
          583  +	return(strdup(real_path));
          584  +}
   559    585   
   560    586   static int appfs_fuse_readlink(const char *path, char *buf, size_t size) {
   561    587   	struct appfs_pathinfo pathinfo;
   562    588   	int retval = 0;
   563    589   
   564    590   	APPFS_DEBUG("Enter (path = %s, ...)", path);
   565    591   
................................................................................
   830    856   		close(fd);
   831    857   
   832    858   		return(-EIO);
   833    859   	}
   834    860   
   835    861   	return(fd);
   836    862   }
          863  +
          864  +static int appfs_fuse_truncate(const char *path, off_t size) {
          865  +	char *real_path;
          866  +	int truncate_ret;
          867  +
          868  +	real_path = appfs_localpath(path);
          869  +	if (real_path == NULL) {
          870  +		return(-EIO);
          871  +	}
          872  +
          873  +	truncate_ret = truncate(real_path, size);
          874  +
          875  +	free(real_path);
          876  +
          877  +	if (truncate_ret != 0) {
          878  +		return(errno * -1);
          879  +	}
          880  +
          881  +	return(truncate_ret);
          882  +}
   837    883   
   838    884   /*
   839    885    * SQLite3 mode: Execute raw SQL and return success or failure
   840    886    */
   841    887   static int appfs_sqlite3(const char *sql) {
   842    888   	Tcl_Interp *interp;
   843    889   	const char *sql_ret;
................................................................................
   925    971   	.readlink  = appfs_fuse_readlink,
   926    972   	.open      = appfs_fuse_open,
   927    973   	.release   = appfs_fuse_close,
   928    974   	.read      = appfs_fuse_read,
   929    975   	.write     = appfs_fuse_write,
   930    976   	.mknod     = appfs_fuse_mknod,
   931    977   	.create    = appfs_fuse_create,
          978  +	.truncate  = appfs_fuse_truncate,
   932    979   };
   933    980   
   934    981   /*
   935    982    * FUSE option parsing callback
   936    983    */
   937    984   static int appfs_fuse_opt_cb(void *data, const char *arg, int key, struct fuse_args *outargs) {
   938    985   	static int seen_cachedir = 0;