Diff

Differences From Artifact [9cae19dbb7]:

To Artifact [d452ee8ca8]:


   429    429   		Tcl_IncrRefCount(last_homedir_obj);
   430    430   	}
   431    431   
   432    432          	Tcl_SetObjResult(interp, homedir_obj);
   433    433   
   434    434           return(TCL_OK);
   435    435   }
          436  +
          437  +static int tcl_appfs_simulate_user_fs_enter(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
          438  +	appfs_simulate_user_fs_enter();
          439  +
          440  +	return(TCL_OK);
          441  +}
          442  +
          443  +static int tcl_appfs_simulate_user_fs_leave(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
          444  +	appfs_simulate_user_fs_leave();
          445  +
          446  +	return(TCL_OK);
          447  +}
   436    448   
   437    449   /*
   438    450    * Generate an inode for a given path.  The inode should be computed in such
   439    451    * a way that it is unlikely to be duplicated and remains the same for a given
   440    452    * file
   441    453    */
   442    454   static long long appfs_get_path_inode(const char *path) {
................................................................................
   467    479   	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;
   468    480   	int tcl_ret;
   469    481   
   470    482   	interp = appfs_TclInterp();
   471    483   	if (interp == NULL) {
   472    484   		return(-EIO);
   473    485   	}
          486  +
          487  +	appfs_simulate_user_fs_enter();
   474    488   
   475    489   	tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::getattr", path);
          490  +
          491  +	appfs_simulate_user_fs_leave();
          492  +
   476    493   	if (tcl_ret != TCL_OK) {
   477    494   		APPFS_DEBUG("::appfs::getattr(%s) failed.", path);
   478    495   		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
   479    496   
   480    497   		return(-ENOENT);
   481    498   	}
   482    499   
................................................................................
   555    572   					pathinfo->typeinfo.symlink.size = attr_value_int;
   556    573   					pathinfo->typeinfo.symlink.source[attr_value_int] = '\0';
   557    574   
   558    575   					memcpy(pathinfo->typeinfo.symlink.source, attr_value_str, attr_value_int);
   559    576   				}
   560    577   			}
   561    578   			break;
   562         -		case 'p': /* pipe/fifo */
          579  +		case 'F': /* pipe/fifo */
          580  +			pathinfo->type = APPFS_PATHTYPE_FIFO;
   563    581   			break;
   564    582   		case 'S': /* UNIX domain socket */
          583  +			pathinfo->type = APPFS_PATHTYPE_SOCKET;
   565    584   			break;
   566    585   		default:
   567    586   			return(-EIO);
   568    587   	}
   569    588   
   570    589   	Tcl_DictObjGet(interp, attrs_dict, attr_key_packaged, &attr_value);
   571    590   	if (attr_value != NULL) {
................................................................................
   705    724   			break;
   706    725   		case APPFS_PATHTYPE_SYMLINK:
   707    726   			stbuf->st_mode = S_IFLNK | 0555;
   708    727   			stbuf->st_nlink = 1;
   709    728   			stbuf->st_size = pathinfo.typeinfo.symlink.size;
   710    729   			break;
   711    730   		case APPFS_PATHTYPE_SOCKET:
          731  +			stbuf->st_mode = S_IFSOCK | 0555;
          732  +			stbuf->st_nlink = 1;
          733  +			stbuf->st_size = 0;
          734  +			break;
   712    735   		case APPFS_PATHTYPE_FIFO:
          736  +			stbuf->st_mode = S_IFIFO | 0555;
          737  +			stbuf->st_nlink = 1;
          738  +			stbuf->st_size = 0;
          739  +			break;
   713    740   		case APPFS_PATHTYPE_INVALID:
   714    741   			retval = -ENOENT;
   715    742   
   716    743   			break;
   717    744   	}
   718    745   
   719    746   	if (pathinfo.packaged) {
................................................................................
   734    761   	interp = appfs_TclInterp();
   735    762   	if (interp == NULL) {
   736    763   		return(0);
   737    764   	}
   738    765   
   739    766   	filler(buf, ".", NULL, 0);
   740    767   	filler(buf, "..", NULL, 0);
          768  +
          769  +	appfs_simulate_user_fs_enter();
   741    770   
   742    771   	tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::getchildren", path);
          772  +
          773  +	appfs_simulate_user_fs_leave();
          774  +
   743    775   	if (tcl_ret != TCL_OK) {
   744    776   		APPFS_DEBUG("::appfs::getchildren(%s) failed.", path);
   745    777   		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
   746    778   
   747    779   		return(0);
   748    780   	}
   749    781   
................................................................................
  1145   1177   #ifdef USE_TCL_STUBS
  1146   1178   	if (Tcl_InitStubs(interp, TCL_VERSION, 0) == 0L) {
  1147   1179   		return(TCL_ERROR);
  1148   1180   	}
  1149   1181   #endif
  1150   1182   
  1151   1183   	Tcl_CreateObjCommand(interp, "appfsd::get_homedir", tcl_appfs_get_homedir, NULL, NULL);
         1184  +	Tcl_CreateObjCommand(interp, "appfsd::simulate_user_fs_enter", tcl_appfs_simulate_user_fs_enter, NULL, NULL);
         1185  +	Tcl_CreateObjCommand(interp, "appfsd::simulate_user_fs_leave", tcl_appfs_simulate_user_fs_leave, NULL, NULL);
  1152   1186   
  1153   1187   	Tcl_PkgProvide(interp, "appfsd", "1.0");
  1154   1188   
  1155   1189   	return(TCL_OK);
  1156   1190   }
  1157   1191   
  1158   1192   /*