Annotation For xvfs-core.c

Origin for each line in xvfs-core.c from check-in e5b6962adf:

69e476dcd5 2019-05-02    1: #include <xvfs-core.h>
69e476dcd5 2019-05-02    2: #include <tcl.h>
69e476dcd5 2019-05-02    3: 
e5b6962adf 2019-05-02    4: static int xvfs_tclvfs_standalone_pathInFilesystem(Tcl_Obj *path, ClientData *dataPtr) {
e5b6962adf 2019-05-02    5: 	return(TCL_ERROR);
e5b6962adf 2019-05-02    6: }
e5b6962adf 2019-05-02    7: 
e5b6962adf 2019-05-02    8: static int xvfs_tclvfs_normalizePath(Tcl_Interp *interp, Tcl_Obj *path, int nextCheckpoint) {
e5b6962adf 2019-05-02    9: 	return(TCL_ERROR);
e5b6962adf 2019-05-02   10: }
e5b6962adf 2019-05-02   11: 
e5b6962adf 2019-05-02   12: static Tcl_Obj *xvfs_tclvfs_listVolumes() {
e5b6962adf 2019-05-02   13: 	return(NULL);
e5b6962adf 2019-05-02   14: }
e5b6962adf 2019-05-02   15: 
32b55a907b 2019-05-02   16: /*
32b55a907b 2019-05-02   17:  * There are three (3) modes of operation for Xvfs_Register:
32b55a907b 2019-05-02   18:  *    1. standalone -- We register our own Tcl_Filesystem
32b55a907b 2019-05-02   19:  *                     and handle requests under `//xvfs:/<fsName>`
32b55a907b 2019-05-02   20:  *    2. client -- A single Tcl_Filesystem is registered for the
32b55a907b 2019-05-02   21:  *                 interp to handle requests under `//xvfs:/` which
32b55a907b 2019-05-02   22:  *                 then dispatches to the appropriate registered
32b55a907b 2019-05-02   23:  *                 handler
32b55a907b 2019-05-02   24:  *    3. flexible -- Attempts to find a core Xvfs instance for the
32b55a907b 2019-05-02   25:  *                   process at runtime, if found do #2, otherwise
32b55a907b 2019-05-02   26:  *                   fallback to #1
32b55a907b 2019-05-02   27:  *
32b55a907b 2019-05-02   28:  */
e5b6962adf 2019-05-02   29: static int xvfs_standalone_register(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo) {
e5b6962adf 2019-05-02   30: 	Tcl_Filesystem *xvfsInfo;
e5b6962adf 2019-05-02   31: 	int tcl_ret;
e5b6962adf 2019-05-02   32: 	
e5b6962adf 2019-05-02   33: 	/*
e5b6962adf 2019-05-02   34: 	 * In standalone mode, we only support the same protocol we are
e5b6962adf 2019-05-02   35: 	 * compiling for.
e5b6962adf 2019-05-02   36: 	 */
e5b6962adf 2019-05-02   37: 	if (fsInfo->protocolVersion != XVFS_PROTOCOL_VERSION) {
e5b6962adf 2019-05-02   38: 		if (interp) {
e5b6962adf 2019-05-02   39: 			Tcl_SetResult(interp, "Protocol mismatch", NULL);
e5b6962adf 2019-05-02   40: 		}
e5b6962adf 2019-05-02   41: 		return(TCL_ERROR);
e5b6962adf 2019-05-02   42: 	}
e5b6962adf 2019-05-02   43: 	
e5b6962adf 2019-05-02   44: 	xvfsInfo = (Tcl_Filesystem *) Tcl_AttemptAlloc(sizeof(*xvfsInfo));
e5b6962adf 2019-05-02   45: 	if (!xvfsInfo) {
e5b6962adf 2019-05-02   46: 		if (interp) {
e5b6962adf 2019-05-02   47: 			Tcl_SetResult(interp, "Unable to allocate Tcl_Filesystem object", NULL);
e5b6962adf 2019-05-02   48: 		}
e5b6962adf 2019-05-02   49: 		return(TCL_ERROR);
e5b6962adf 2019-05-02   50: 	}
e5b6962adf 2019-05-02   51: 	
e5b6962adf 2019-05-02   52: 	xvfsInfo->typeName                   = "xvfs";
e5b6962adf 2019-05-02   53: 	xvfsInfo->structureLength            = sizeof(*xvfsInfo);
e5b6962adf 2019-05-02   54: 	xvfsInfo->version                    = TCL_FILESYSTEM_VERSION_1;
e5b6962adf 2019-05-02   55: 	xvfsInfo->pathInFilesystemProc       = xvfs_tclvfs_standalone_pathInFilesystem;
e5b6962adf 2019-05-02   56: 	xvfsInfo->dupInternalRepProc         = NULL;
e5b6962adf 2019-05-02   57: 	xvfsInfo->freeInternalRepProc        = NULL;
e5b6962adf 2019-05-02   58: 	xvfsInfo->internalToNormalizedProc   = NULL;
e5b6962adf 2019-05-02   59: 	xvfsInfo->createInternalRepProc      = NULL;
e5b6962adf 2019-05-02   60: 	xvfsInfo->normalizePathProc          = xvfs_tclvfs_normalizePath;
e5b6962adf 2019-05-02   61: 	xvfsInfo->filesystemPathTypeProc     = NULL;
e5b6962adf 2019-05-02   62: 	xvfsInfo->filesystemSeparatorProc    = NULL;
e5b6962adf 2019-05-02   63: 	xvfsInfo->statProc                   = NULL;
e5b6962adf 2019-05-02   64: 	xvfsInfo->accessProc                 = NULL;
e5b6962adf 2019-05-02   65: 	xvfsInfo->openFileChannelProc        = NULL;
e5b6962adf 2019-05-02   66: 	xvfsInfo->matchInDirectoryProc       = NULL;
e5b6962adf 2019-05-02   67: 	xvfsInfo->utimeProc                  = NULL;
e5b6962adf 2019-05-02   68: 	xvfsInfo->linkProc                   = NULL;
e5b6962adf 2019-05-02   69: 	xvfsInfo->listVolumesProc            = xvfs_tclvfs_listVolumes;
e5b6962adf 2019-05-02   70: 	xvfsInfo->fileAttrStringsProc        = NULL;
e5b6962adf 2019-05-02   71: 	xvfsInfo->fileAttrsGetProc           = NULL;
e5b6962adf 2019-05-02   72: 	xvfsInfo->fileAttrsSetProc           = NULL;
e5b6962adf 2019-05-02   73: 	xvfsInfo->createDirectoryProc        = NULL;
e5b6962adf 2019-05-02   74: 	xvfsInfo->removeDirectoryProc        = NULL;
e5b6962adf 2019-05-02   75: 	xvfsInfo->deleteFileProc             = NULL;
e5b6962adf 2019-05-02   76: 	xvfsInfo->copyFileProc               = NULL;
e5b6962adf 2019-05-02   77: 	xvfsInfo->renameFileProc             = NULL;
e5b6962adf 2019-05-02   78: 	xvfsInfo->copyDirectoryProc          = NULL;
e5b6962adf 2019-05-02   79: 	xvfsInfo->lstatProc                  = NULL;
e5b6962adf 2019-05-02   80: 	xvfsInfo->loadFileProc               = NULL;
e5b6962adf 2019-05-02   81: 	xvfsInfo->getCwdProc                 = NULL;
e5b6962adf 2019-05-02   82: 	xvfsInfo->chdirProc                  = NULL;
e5b6962adf 2019-05-02   83: 
e5b6962adf 2019-05-02   84: 	tcl_ret = Tcl_FSRegister(NULL, xvfsInfo);
e5b6962adf 2019-05-02   85: 	if (tcl_ret != TCL_OK) {
e5b6962adf 2019-05-02   86: 		if (interp) {
e5b6962adf 2019-05-02   87: 			Tcl_SetResult(interp, "Tcl_FSRegister() failed", NULL);
e5b6962adf 2019-05-02   88: 		}
e5b6962adf 2019-05-02   89: 		
e5b6962adf 2019-05-02   90: 		return(tcl_ret);
e5b6962adf 2019-05-02   91: 	}
e5b6962adf 2019-05-02   92: 	
e5b6962adf 2019-05-02   93: 	return(TCL_OK);
32b55a907b 2019-05-02   94: }
32b55a907b 2019-05-02   95: 
e5b6962adf 2019-05-02   96: int Xvfs_Register(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo) {
e5b6962adf 2019-05-02   97: 	return(xvfs_standalone_register(interp, fsInfo));
69e476dcd5 2019-05-02   98: }