Check-in [db5fcbef28]
Overview
Comment:Added basic write support
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tcl-ops
Files: files | file ages | folders
SHA1:db5fcbef28a6ac294a70d06d5c7506ad511091a1
User & Date: rkeene on 2014-11-07 12:26:49
Other Links: manifest | tags
Context
2014-11-07
13:04
Added validity checking for various types check-in: 5685a8f9a8 user: rkeene tags: tcl-ops
12:26
Added basic write support check-in: db5fcbef28 user: rkeene tags: tcl-ops
12:13
Added basic "open" support check-in: ebbca87b7e user: rkeene tags: tcl-ops
Changes

Modified appfsd.c from [a228e5eaeb] to [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    576   			stbuf->st_mode |= 0222;
   572    577   		}
   573         -	}
   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;
   580    584   	Tcl_Obj **children;
................................................................................
   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;

Modified appfsd.tcl from [23568748fe] to [1c94a0206c].

   481    481   
   482    482   		switch -- $pathinfo(_type) {
   483    483   			"toplevel" - "sites" - "packages" - "os-cpu" - "versions" {
   484    484   				set retval(type) directory
   485    485   				set retval(childcount) 2;
   486    486   			}
   487    487   			"files" {
          488  +				set retval(packaged) 1
          489  +
   488    490   				set localpath [_localpath $pathinfo(package) $pathinfo(hostname) $pathinfo(file)]
   489    491   				if {[file exists $localpath]} {
   490    492   					catch {
   491    493   						file lstat $localpath localpathinfo
   492    494   						set retval(time) $localpathinfo(mtime)
   493    495   
   494    496   						switch -- $localpathinfo(type) {