Diff

Differences From Artifact [a228e5eaeb]:

To Artifact [5b32138d43]:


   376    376   /* Get information about a path, and optionally list children */
   377    377   static int appfs_get_path_info(const char *path, struct appfs_pathinfo *pathinfo) {
   378    378   	Tcl_Interp *interp;
   379    379   	Tcl_Obj *attrs_dict, *attr_value;
   380    380   	const char *attr_value_str;
   381    381   	Tcl_WideInt attr_value_wide;
   382    382   	int attr_value_int;
   383         -	static __thread Tcl_Obj *attr_key_type = NULL, *attr_key_perms = NULL, *attr_key_size = NULL, *attr_key_time = NULL, *attr_key_source = NULL, *attr_key_childcount = NULL;
          383  +	static __thread Tcl_Obj *attr_key_type = NULL, *attr_key_perms = NULL, *attr_key_size = NULL, *attr_key_time = NULL, *attr_key_source = NULL, *attr_key_childcount = NULL, *attr_key_packaged = NULL;
   384    384   	int tcl_ret;
   385    385   
   386    386   	interp = appfs_TclInterp();
   387    387   	if (interp == NULL) {
   388    388   		return(-EIO);
   389    389   	}
   390    390   
................................................................................
   399    399   	if (attr_key_type == NULL) {
   400    400   		attr_key_type       = Tcl_NewStringObj("type", -1);
   401    401   		attr_key_perms      = Tcl_NewStringObj("perms", -1);
   402    402   		attr_key_size       = Tcl_NewStringObj("size", -1);
   403    403   		attr_key_time       = Tcl_NewStringObj("time", -1);
   404    404   		attr_key_source     = Tcl_NewStringObj("source", -1);
   405    405   		attr_key_childcount = Tcl_NewStringObj("childcount", -1);
          406  +		attr_key_packaged   = Tcl_NewStringObj("packaged", -1);
   406    407   	}
   407    408   
   408    409   	attrs_dict = Tcl_GetObjResult(interp);
   409    410   	tcl_ret = Tcl_DictObjGet(interp, attrs_dict, attr_key_type, &attr_value);
   410    411   	if (tcl_ret != TCL_OK) {
   411    412   		APPFS_DEBUG("[dict get \"type\"] failed");
   412    413   		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
................................................................................
   473    474   					memcpy(pathinfo->typeinfo.symlink.source, attr_value_str, attr_value_int);
   474    475   				}
   475    476   			}
   476    477   			break;
   477    478   		default:
   478    479   			return(-EIO);
   479    480   	}
          481  +
          482  +	Tcl_DictObjGet(interp, attrs_dict, attr_key_packaged, &attr_value);
          483  +	if (attr_value != NULL) {
          484  +		pathinfo->packaged = 1;
          485  +	}
   480    486   
   481    487   	Tcl_DictObjGet(interp, attrs_dict, attr_key_time, &attr_value);
   482    488   	if (attr_value != NULL) {
   483    489   		tcl_ret = Tcl_GetWideIntFromObj(NULL, attr_value, &attr_value_wide);
   484    490   		if (tcl_ret == TCL_OK) {
   485    491   			pathinfo->time = attr_value_wide;
   486    492   		}
................................................................................
   563    569   		case APPFS_PATHTYPE_INVALID:
   564    570   			retval = -EIO;
   565    571   
   566    572   			break;
   567    573   	}
   568    574   
   569    575   	if (pathinfo.packaged) {
   570         -		if (0) {
   571         -			stbuf->st_mode |= 0222;
   572         -		}
          576  +		stbuf->st_mode |= 0222;
   573    577   	}
   574    578   
   575    579   	return(retval);
   576    580   }
   577    581   
   578    582   static int appfs_fuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) {
   579    583   	Tcl_Interp *interp;
................................................................................
   697    701   		return(-EIO);
   698    702   	}
   699    703   
   700    704   	read_ret = read(fi->fh, buf, size);
   701    705   
   702    706   	return(read_ret);
   703    707   }
          708  +
          709  +static int appfs_fuse_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
          710  +	off_t lseek_ret;
          711  +	ssize_t write_ret;
          712  +
          713  +	APPFS_DEBUG("Enter (path = %s, ...)", path);
          714  +
          715  +	lseek_ret = lseek(fi->fh, offset, SEEK_SET);
          716  +	if (lseek_ret != offset) {
          717  +		return(-EIO);
          718  +	}
          719  +
          720  +	write_ret = write(fi->fh, buf, size);
          721  +
          722  +	return(write_ret);
          723  +}
   704    724   
   705    725   /*
   706    726    * SQLite3 mode: Execute raw SQL and return success or failure
   707    727    */
   708    728   static int appfs_sqlite3(const char *sql) {
   709    729   	Tcl_Interp *interp;
   710    730   	const char *sql_ret;
................................................................................
   788    808    */
   789    809   static struct fuse_operations appfs_operations = {
   790    810   	.getattr   = appfs_fuse_getattr,
   791    811   	.readdir   = appfs_fuse_readdir,
   792    812   	.readlink  = appfs_fuse_readlink,
   793    813   	.open      = appfs_fuse_open,
   794    814   	.release   = appfs_fuse_close,
   795         -	.read      = appfs_fuse_read
          815  +	.read      = appfs_fuse_read,
          816  +	.write     = appfs_fuse_write
   796    817   };
   797    818   
   798    819   /*
   799    820    * FUSE option parsing callback
   800    821    */
   801    822   static int appfs_fuse_opt_cb(void *data, const char *arg, int key, struct fuse_args *outargs) {
   802    823   	static int seen_cachedir = 0;