109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
* then dispatches to the appropriate registered
* handler
* 3. flexible -- Attempts to find a core Xvfs instance for the
* process at runtime, if found do #2, otherwise
* fallback to #1
*
*/
int xvfs_standalone_register(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo) {
Tcl_Filesystem *xvfs_tclfs_Info;
int tcl_ret;
static int registered = 0;
/*
* Ensure this instance is not already registered
*/
if (registered) {
|
>
<
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
* then dispatches to the appropriate registered
* handler
* 3. flexible -- Attempts to find a core Xvfs instance for the
* process at runtime, if found do #2, otherwise
* fallback to #1
*
*/
static Tcl_Filesystem xvfs_tclfs_standalone_fs;
int xvfs_standalone_register(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo) {
int tcl_ret;
static int registered = 0;
/*
* Ensure this instance is not already registered
*/
if (registered) {
|
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
if (fsInfo->protocolVersion != XVFS_PROTOCOL_VERSION) {
if (interp) {
Tcl_SetResult(interp, "Protocol mismatch", NULL);
}
return(TCL_ERROR);
}
xvfs_tclfs_Info = (Tcl_Filesystem *) Tcl_AttemptAlloc(sizeof(*xvfs_tclfs_Info));
if (!xvfs_tclfs_Info) {
if (interp) {
Tcl_SetResult(interp, "Unable to allocate Tcl_Filesystem object", NULL);
}
return(TCL_ERROR);
}
xvfs_tclfs_Info->typeName = "xvfs";
xvfs_tclfs_Info->structureLength = sizeof(*xvfs_tclfs_Info);
xvfs_tclfs_Info->version = TCL_FILESYSTEM_VERSION_1;
xvfs_tclfs_Info->pathInFilesystemProc = xvfs_tclfs_standalone_pathInFilesystem;
xvfs_tclfs_Info->dupInternalRepProc = NULL;
xvfs_tclfs_Info->freeInternalRepProc = NULL;
xvfs_tclfs_Info->internalToNormalizedProc = NULL;
xvfs_tclfs_Info->createInternalRepProc = NULL;
xvfs_tclfs_Info->normalizePathProc = NULL;
xvfs_tclfs_Info->filesystemPathTypeProc = NULL;
xvfs_tclfs_Info->filesystemSeparatorProc = NULL;
xvfs_tclfs_Info->statProc = xvfs_tclfs_standalone_stat;
xvfs_tclfs_Info->accessProc = NULL;
xvfs_tclfs_Info->openFileChannelProc = xvfs_tclfs_standalone_openFileChannel;
xvfs_tclfs_Info->matchInDirectoryProc = NULL;
xvfs_tclfs_Info->utimeProc = NULL;
xvfs_tclfs_Info->linkProc = NULL;
xvfs_tclfs_Info->listVolumesProc = xvfs_tclfs_standalone_listVolumes;
xvfs_tclfs_Info->fileAttrStringsProc = NULL;
xvfs_tclfs_Info->fileAttrsGetProc = NULL;
xvfs_tclfs_Info->fileAttrsSetProc = NULL;
xvfs_tclfs_Info->createDirectoryProc = NULL;
xvfs_tclfs_Info->removeDirectoryProc = NULL;
xvfs_tclfs_Info->deleteFileProc = NULL;
xvfs_tclfs_Info->copyFileProc = NULL;
xvfs_tclfs_Info->renameFileProc = NULL;
xvfs_tclfs_Info->copyDirectoryProc = NULL;
xvfs_tclfs_Info->lstatProc = NULL;
xvfs_tclfs_Info->loadFileProc = NULL;
xvfs_tclfs_Info->getCwdProc = NULL;
xvfs_tclfs_Info->chdirProc = NULL;
xvfs_tclfs_standalone_info.fsInfo = fsInfo;
xvfs_tclfs_standalone_info.mountpoint = Tcl_NewObj();
Tcl_AppendStringsToObj(xvfs_tclfs_standalone_info.mountpoint, XVFS_ROOT_MOUNTPOINT, fsInfo->name, NULL);
tcl_ret = Tcl_FSRegister(NULL, xvfs_tclfs_Info);
if (tcl_ret != TCL_OK) {
if (interp) {
Tcl_SetResult(interp, "Tcl_FSRegister() failed", NULL);
}
return(tcl_ret);
}
|
<
<
<
<
<
<
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
if (fsInfo->protocolVersion != XVFS_PROTOCOL_VERSION) {
if (interp) {
Tcl_SetResult(interp, "Protocol mismatch", NULL);
}
return(TCL_ERROR);
}
xvfs_tclfs_standalone_fs.typeName = "xvfs";
xvfs_tclfs_standalone_fs.structureLength = sizeof(xvfs_tclfs_standalone_fs);
xvfs_tclfs_standalone_fs.version = TCL_FILESYSTEM_VERSION_1;
xvfs_tclfs_standalone_fs.pathInFilesystemProc = xvfs_tclfs_standalone_pathInFilesystem;
xvfs_tclfs_standalone_fs.dupInternalRepProc = NULL;
xvfs_tclfs_standalone_fs.freeInternalRepProc = NULL;
xvfs_tclfs_standalone_fs.internalToNormalizedProc = NULL;
xvfs_tclfs_standalone_fs.createInternalRepProc = NULL;
xvfs_tclfs_standalone_fs.normalizePathProc = NULL;
xvfs_tclfs_standalone_fs.filesystemPathTypeProc = NULL;
xvfs_tclfs_standalone_fs.filesystemSeparatorProc = NULL;
xvfs_tclfs_standalone_fs.statProc = xvfs_tclfs_standalone_stat;
xvfs_tclfs_standalone_fs.accessProc = NULL;
xvfs_tclfs_standalone_fs.openFileChannelProc = xvfs_tclfs_standalone_openFileChannel;
xvfs_tclfs_standalone_fs.matchInDirectoryProc = NULL;
xvfs_tclfs_standalone_fs.utimeProc = NULL;
xvfs_tclfs_standalone_fs.linkProc = NULL;
xvfs_tclfs_standalone_fs.listVolumesProc = xvfs_tclfs_standalone_listVolumes;
xvfs_tclfs_standalone_fs.fileAttrStringsProc = NULL;
xvfs_tclfs_standalone_fs.fileAttrsGetProc = NULL;
xvfs_tclfs_standalone_fs.fileAttrsSetProc = NULL;
xvfs_tclfs_standalone_fs.createDirectoryProc = NULL;
xvfs_tclfs_standalone_fs.removeDirectoryProc = NULL;
xvfs_tclfs_standalone_fs.deleteFileProc = NULL;
xvfs_tclfs_standalone_fs.copyFileProc = NULL;
xvfs_tclfs_standalone_fs.renameFileProc = NULL;
xvfs_tclfs_standalone_fs.copyDirectoryProc = NULL;
xvfs_tclfs_standalone_fs.lstatProc = NULL;
xvfs_tclfs_standalone_fs.loadFileProc = NULL;
xvfs_tclfs_standalone_fs.getCwdProc = NULL;
xvfs_tclfs_standalone_fs.chdirProc = NULL;
xvfs_tclfs_standalone_info.fsInfo = fsInfo;
xvfs_tclfs_standalone_info.mountpoint = Tcl_NewObj();
Tcl_AppendStringsToObj(xvfs_tclfs_standalone_info.mountpoint, XVFS_ROOT_MOUNTPOINT, fsInfo->name, NULL);
tcl_ret = Tcl_FSRegister(NULL, &xvfs_tclfs_standalone_fs);
if (tcl_ret != TCL_OK) {
if (interp) {
Tcl_SetResult(interp, "Tcl_FSRegister() failed", NULL);
}
return(tcl_ret);
}
|