Diff

Differences From Artifact [ade95f924e]:

To Artifact [ba1c738961]:


    48     48   /*
    49     49    * AppFS Path Type:  Describes the type of path a given file is
    50     50    */
    51     51   typedef enum {
    52     52   	APPFS_PATHTYPE_INVALID,
    53     53   	APPFS_PATHTYPE_FILE,
    54     54   	APPFS_PATHTYPE_DIRECTORY,
    55         -	APPFS_PATHTYPE_SYMLINK
           55  +	APPFS_PATHTYPE_SYMLINK,
           56  +	APPFS_PATHTYPE_SOCKET,
           57  +	APPFS_PATHTYPE_FIFO,
    56     58   } appfs_pathtype_t;
    57     59   
    58     60   /*
    59     61    * AppFS Path Information:
    60     62    *         Completely describes a specific path, how it should be returned to
    61     63    *         to the kernel
    62     64    */
................................................................................
   499    501   					pathinfo->typeinfo.symlink.size = attr_value_int;
   500    502   					pathinfo->typeinfo.symlink.source[attr_value_int] = '\0';
   501    503   
   502    504   					memcpy(pathinfo->typeinfo.symlink.source, attr_value_str, attr_value_int);
   503    505   				}
   504    506   			}
   505    507   			break;
          508  +		case 'p': /* pipe/fifo */
          509  +			break;
          510  +		case 'S': /* UNIX domain socket */
          511  +			break;
   506    512   		default:
   507    513   			return(-EIO);
   508    514   	}
   509    515   
   510    516   	Tcl_DictObjGet(interp, attrs_dict, attr_key_packaged, &attr_value);
   511    517   	if (attr_value != NULL) {
   512    518   		pathinfo->packaged = 1;
................................................................................
   520    526   		}
   521    527   	} else {
   522    528   		pathinfo->time = 0;
   523    529   	}
   524    530   
   525    531   	return(0);
   526    532   }
          533  +
          534  +static char *appfs_prepare_to_create(const char *path) {
          535  +	Tcl_Interp *interp;
          536  +	const char *real_path;
          537  +	int tcl_ret;
          538  +
          539  +	interp = appfs_TclInterp();
          540  +	if (interp == NULL) {
          541  +		return(NULL);
          542  +	}
          543  +
          544  +	tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::prepare_to_create", path);
          545  +	if (tcl_ret != TCL_OK) {
          546  +		APPFS_DEBUG("::appfs::prepare_to_create(%s) failed.", path);
          547  +		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
          548  +
          549  +		return(NULL);
          550  +	}
          551  +
          552  +	real_path = Tcl_GetStringResult(interp);
          553  +	if (real_path == NULL) {
          554  +		return(NULL);
          555  +	}
          556  +
          557  +	return(strdup(real_path));
          558  +}
   527    559   
   528    560   static int appfs_fuse_readlink(const char *path, char *buf, size_t size) {
   529    561   	struct appfs_pathinfo pathinfo;
   530    562   	int retval = 0;
   531    563   
   532    564   	APPFS_DEBUG("Enter (path = %s, ...)", path);
   533    565   
................................................................................
   590    622   			stbuf->st_size = pathinfo.typeinfo.file.size;
   591    623   			break;
   592    624   		case APPFS_PATHTYPE_SYMLINK:
   593    625   			stbuf->st_mode = S_IFLNK | 0555;
   594    626   			stbuf->st_nlink = 1;
   595    627   			stbuf->st_size = pathinfo.typeinfo.symlink.size;
   596    628   			break;
          629  +		case APPFS_PATHTYPE_SOCKET:
          630  +		case APPFS_PATHTYPE_FIFO:
   597    631   		case APPFS_PATHTYPE_INVALID:
   598         -			retval = -EIO;
          632  +			retval = -ENOENT;
   599    633   
   600    634   			break;
   601    635   	}
   602    636   
   603    637   	if (pathinfo.packaged) {
   604    638   		stbuf->st_mode |= 0222;
   605    639   	}
................................................................................
   749    783   		return(-EIO);
   750    784   	}
   751    785   
   752    786   	write_ret = write(fi->fh, buf, size);
   753    787   
   754    788   	return(write_ret);
   755    789   }
          790  +
          791  +static int appfs_fuse_mknod(const char *path, mode_t mode, dev_t device) {
          792  +	char *real_path;
          793  +	int mknod_ret;
          794  +
          795  +	if ((mode & S_IFCHR) == S_IFCHR) {
          796  +		return(-EPERM);
          797  +	}
          798  +
          799  +	if ((mode & S_IFBLK) == S_IFBLK) {
          800  +		return(-EPERM);
          801  +	}
          802  +
          803  +	real_path = appfs_prepare_to_create(path);
          804  +	if (real_path == NULL) {
          805  +		return(-EIO);
          806  +	}
          807  +
          808  +	mknod_ret = mknod(real_path, mode, device);
          809  +
          810  +	free(real_path);
          811  +
          812  +	if (mknod_ret != 0) {
          813  +		return(errno * -1);
          814  +	}
          815  +
          816  +	return(0);
          817  +}
          818  +
          819  +static int appfs_fuse_create(const char *path, mode_t mode, struct fuse_file_info *fi) {
          820  +	int fd;
          821  +	int chmod_ret;
          822  +
          823  +	fd = appfs_fuse_open(path, fi);
          824  +	if (fd < 0) {
          825  +		return(fd);
          826  +	}
          827  +
          828  +	chmod_ret = fchmod(fd, mode);
          829  +	if (chmod_ret != 0) {
          830  +		close(fd);
          831  +
          832  +		return(-EIO);
          833  +	}
          834  +
          835  +	return(fd);
          836  +}
   756    837   
   757    838   /*
   758    839    * SQLite3 mode: Execute raw SQL and return success or failure
   759    840    */
   760    841   static int appfs_sqlite3(const char *sql) {
   761    842   	Tcl_Interp *interp;
   762    843   	const char *sql_ret;
................................................................................
   841    922   static struct fuse_operations appfs_operations = {
   842    923   	.getattr   = appfs_fuse_getattr,
   843    924   	.readdir   = appfs_fuse_readdir,
   844    925   	.readlink  = appfs_fuse_readlink,
   845    926   	.open      = appfs_fuse_open,
   846    927   	.release   = appfs_fuse_close,
   847    928   	.read      = appfs_fuse_read,
   848         -	.write     = appfs_fuse_write
          929  +	.write     = appfs_fuse_write,
          930  +	.mknod     = appfs_fuse_mknod,
          931  +	.create    = appfs_fuse_create,
   849    932   };
   850    933   
   851    934   /*
   852    935    * FUSE option parsing callback
   853    936    */
   854    937   static int appfs_fuse_opt_cb(void *data, const char *arg, int key, struct fuse_args *outargs) {
   855    938   	static int seen_cachedir = 0;