Lines of
xvfs-core.c
from check-in e5b6962adf
that are changed by the sequence of edits moving toward
check-in d121970301:
1: #include <xvfs-core.h>
e5b6962adf 2019-05-02 2: #include <tcl.h>
e5b6962adf 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);
14: }
15:
16: /*
17: * There are three (3) modes of operation for Xvfs_Register:
18: * 1. standalone -- We register our own Tcl_Filesystem
19: * and handle requests under `//xvfs:/<fsName>`
20: * 2. client -- A single Tcl_Filesystem is registered for the
21: * interp to handle requests under `//xvfs:/` which
22: * then dispatches to the appropriate registered
23: * handler
24: * 3. flexible -- Attempts to find a core Xvfs instance for the
25: * process at runtime, if found do #2, otherwise
26: * fallback to #1
27: *
28: */
29: static int xvfs_standalone_register(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo) {
e5b6962adf 2019-05-02 30: Tcl_Filesystem *xvfsInfo;
31: int tcl_ret;
e5b6962adf 2019-05-02 32:
33: /*
34: * In standalone mode, we only support the same protocol we are
35: * compiling for.
36: */
37: if (fsInfo->protocolVersion != XVFS_PROTOCOL_VERSION) {
38: if (interp) {
39: Tcl_SetResult(interp, "Protocol mismatch", NULL);
40: }
41: return(TCL_ERROR);
42: }
43:
e5b6962adf 2019-05-02 44: xvfsInfo = (Tcl_Filesystem *) Tcl_AttemptAlloc(sizeof(*xvfsInfo));
e5b6962adf 2019-05-02 45: if (!xvfsInfo) {
46: if (interp) {
47: Tcl_SetResult(interp, "Unable to allocate Tcl_Filesystem object", NULL);
48: }
49: return(TCL_ERROR);
50: }
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);
85: if (tcl_ret != TCL_OK) {
86: if (interp) {
87: Tcl_SetResult(interp, "Tcl_FSRegister() failed", NULL);
88: }
89:
90: return(tcl_ret);
91: }
92:
93: return(TCL_OK);
94: }
95:
96: int Xvfs_Register(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo) {
97: return(xvfs_standalone_register(interp, fsInfo));
98: }