Diff

Differences From Artifact [070b2bd8e3]:

To Artifact [227a45ec34]:


   627    627   	memset(stbuf, 0, sizeof(struct stat));
   628    628   
   629    629   	stbuf->st_mtime = pathinfo.time;
   630    630   	stbuf->st_ctime = pathinfo.time;
   631    631   	stbuf->st_atime = pathinfo.time;
   632    632   	stbuf->st_ino   = pathinfo.inode;
   633    633   	stbuf->st_mode  = 0;
          634  +	stbuf->st_uid   = appfs_get_fsuid();
   634    635   
   635    636   	switch (pathinfo.type) {
   636    637   		case APPFS_PATHTYPE_DIRECTORY:
   637    638   			stbuf->st_mode = S_IFDIR | 0555;
   638    639   			stbuf->st_nlink = 2 + pathinfo.typeinfo.dir.childcount;
   639    640   			break;
   640    641   		case APPFS_PATHTYPE_FILE:
................................................................................
   841    842   		return(errno * -1);
   842    843   	}
   843    844   
   844    845   	return(0);
   845    846   }
   846    847   
   847    848   static int appfs_fuse_create(const char *path, mode_t mode, struct fuse_file_info *fi) {
          849  +	char *real_path;
   848    850   	int fd;
   849         -	int chmod_ret;
   850    851   
   851    852   	APPFS_DEBUG("Enter (path = %s, ...)", path);
   852    853   
   853         -	fd = appfs_fuse_open(path, fi);
   854         -	if (fd < 0) {
   855         -		return(fd);
          854  +	if ((mode & S_IFCHR) == S_IFCHR) {
          855  +		return(-EPERM);
   856    856   	}
   857    857   
   858         -	chmod_ret = fchmod(fd, mode);
   859         -	if (chmod_ret != 0) {
   860         -		close(fd);
          858  +	if ((mode & S_IFBLK) == S_IFBLK) {
          859  +		return(-EPERM);
          860  +	}
   861    861   
          862  +	real_path = appfs_prepare_to_create(path);
          863  +	if (real_path == NULL) {
   862    864   		return(-EIO);
   863    865   	}
   864    866   
   865         -	return(fd);
          867  +	fd = creat(real_path, mode);
          868  +
          869  +	free(real_path);
          870  +
          871  +	if (fd < 0) {
          872  +		return(errno * -1);
          873  +	}
          874  +
          875  +	fi->fh = fd;
          876  +
          877  +	return(0);
   866    878   }
   867    879   
   868    880   static int appfs_fuse_truncate(const char *path, off_t size) {
   869    881   	char *real_path;
   870    882   	int truncate_ret;
   871    883   
   872    884   	APPFS_DEBUG("Enter (path = %s, ...)", path);
................................................................................
   928    940   		if (errno != EEXIST) {
   929    941   			return(errno * -1);
   930    942   		}
   931    943   	}
   932    944   
   933    945   	return(0);
   934    946   }
          947  +
          948  +static int appfs_fuse_chmod(const char *path, mode_t mode) {
          949  +	Tcl_Interp *interp;
          950  +	const char *real_path;
          951  +	int tcl_ret, chmod_ret;
          952  +
          953  +	APPFS_DEBUG("Enter (path = %s, ...)", path);
          954  +
          955  +	interp = appfs_TclInterp();
          956  +	if (interp == NULL) {
          957  +		return(-EIO);
          958  +	}
          959  +
          960  +	tcl_ret = appfs_Tcl_Eval(interp, 3, "::appfs::openpath", path, "write");
          961  +	if (tcl_ret != TCL_OK) {
          962  +		APPFS_DEBUG("::appfs::openpath(%s, %s) failed.", path, "write");
          963  +		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
          964  +
          965  +		return(-EIO);
          966  +	}
          967  +
          968  +	real_path = Tcl_GetStringResult(interp);
          969  +	if (real_path == NULL) {
          970  +		return(-EIO);
          971  +	}
          972  +
          973  +	chmod_ret = chmod(real_path, mode);
          974  +
          975  +	return(chmod_ret);
          976  +}
   935    977   
   936    978   /*
   937    979    * SQLite3 mode: Execute raw SQL and return success or failure
   938    980    */
   939    981   static int appfs_sqlite3(const char *sql) {
   940    982   	Tcl_Interp *interp;
   941    983   	const char *sql_ret;
................................................................................
  1027   1069   	.write     = appfs_fuse_write,
  1028   1070   	.mknod     = appfs_fuse_mknod,
  1029   1071   	.create    = appfs_fuse_create,
  1030   1072   	.truncate  = appfs_fuse_truncate,
  1031   1073   	.unlink    = appfs_fuse_unlink_rmdir,
  1032   1074   	.rmdir     = appfs_fuse_unlink_rmdir,
  1033   1075   	.mkdir     = appfs_fuse_mkdir,
         1076  +	.chmod     = appfs_fuse_chmod,
  1034   1077   };
  1035   1078   
  1036   1079   /*
  1037   1080    * FUSE option parsing callback
  1038   1081    */
  1039   1082   static int appfs_fuse_opt_cb(void *data, const char *arg, int key, struct fuse_args *outargs) {
  1040   1083   	static int seen_cachedir = 0;