34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
unsigned int pathHash;
size_t pathLen;
if (path == NULL) {
return(XVFS_NAME_LOOKUP_ERROR);
}
pathLen = strlen(path);
pathHash = Tcl_ZlibAdler32(0, (const unsigned char *) path, pathLen);
switch (pathHash) {
<?
for {set index 0} {$index < [llength $::xvfs::outputFiles]} {incr index} {
set outputFile [lindex $::xvfs::outputFiles $index]
set outputFileHash [zlib adler32 $outputFile 0]
|
>
>
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
unsigned int pathHash;
size_t pathLen;
if (path == NULL) {
return(XVFS_NAME_LOOKUP_ERROR);
}
printf("Looking for %s\n", path);
pathLen = strlen(path);
pathHash = Tcl_ZlibAdler32(0, (const unsigned char *) path, pathLen);
switch (pathHash) {
<?
for {set index 0} {$index < [llength $::xvfs::outputFiles]} {incr index} {
set outputFile [lindex $::xvfs::outputFiles $index]
set outputFileHash [zlib adler32 $outputFile 0]
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
}
/*
* Get the inode from the lookup function
*/
inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
if (inode == XVFS_NAME_LOOKUP_ERROR) {
return(NULL);
}
fileInfo = &xvfs_<?= $::xvfs::fsName ?>_data[inode];
/*
* Ensure this is a directory
*/
if (fileInfo->type != XVFS_FILE_TYPE_DIR) {
return(NULL);
}
*count = fileInfo->size;
return(fileInfo->data.dirChildren);
}
static const unsigned char *xvfs_<?= $::xvfs::fsName ?>_getData(const char *path, Tcl_WideInt start, Tcl_WideInt *length) {
struct xvfs_file_data *fileInfo;
Tcl_WideInt resultLength;
long inode;
/*
* Validate input parameters
*/
if (start < 0) {
return(NULL);
}
if (length == NULL) {
return(NULL);
}
if (*length < 0) {
return(NULL);
}
/*
* Get the inode from the lookup function
*/
inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
if (inode == XVFS_NAME_LOOKUP_ERROR) {
return(NULL);
}
fileInfo = &xvfs_<?= $::xvfs::fsName ?>_data[inode];
/*
* Ensure this is a file that can be read
*/
if (fileInfo->type != XVFS_FILE_TYPE_REG) {
return(NULL);
}
/*
* Validate the length
*/
if (start > fileInfo->size) {
*length = -1;
return(NULL);
}
if (*length == 0) {
resultLength = fileInfo->size - start;
} else {
resultLength = MIN(fileInfo->size - start, *length);
|
>
>
|
>
|
>
>
>
|
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
|
}
/*
* Get the inode from the lookup function
*/
inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
if (inode == XVFS_NAME_LOOKUP_ERROR) {
*count = XVFS_RV_ERR_ENOENT;
return(NULL);
}
fileInfo = &xvfs_<?= $::xvfs::fsName ?>_data[inode];
/*
* Ensure this is a directory
*/
if (fileInfo->type != XVFS_FILE_TYPE_DIR) {
*count = XVFS_RV_ERR_ENOTDIR;
return(NULL);
}
*count = fileInfo->size;
return(fileInfo->data.dirChildren);
}
static const unsigned char *xvfs_<?= $::xvfs::fsName ?>_getData(const char *path, Tcl_WideInt start, Tcl_WideInt *length) {
struct xvfs_file_data *fileInfo;
Tcl_WideInt resultLength;
long inode;
/*
* Validate input parameters
*/
if (length == NULL) {
return(NULL);
}
if (start < 0) {
*length = XVFS_RV_ERR_EINVAL;
return(NULL);
}
if (*length < 0) {
*length = XVFS_RV_ERR_EINVAL;
return(NULL);
}
/*
* Get the inode from the lookup function
*/
inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
if (inode == XVFS_NAME_LOOKUP_ERROR) {
*length = XVFS_RV_ERR_ENOENT;
return(NULL);
}
fileInfo = &xvfs_<?= $::xvfs::fsName ?>_data[inode];
/*
* Ensure this is a file that can be read
*/
if (fileInfo->type != XVFS_FILE_TYPE_REG) {
*length = XVFS_RV_ERR_EISDIR;
return(NULL);
}
/*
* Validate the length
*/
if (start > fileInfo->size) {
*length = XVFS_RV_ERR_EFAULT;
return(NULL);
}
if (*length == 0) {
resultLength = fileInfo->size - start;
} else {
resultLength = MIN(fileInfo->size - start, *length);
|
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
struct xvfs_file_data *fileInfo;
long inode;
/*
* Validate input parameters
*/
if (!statBuf) {
return(-1);
}
/*
* Get the inode from the lookup function
*/
inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
if (inode == XVFS_NAME_LOOKUP_ERROR) {
return(-1);
}
fileInfo = &xvfs_<?= $::xvfs::fsName ?>_data[inode];
statBuf->st_dev = 0;
statBuf->st_rdev = 0;
statBuf->st_ino = inode;
|
|
|
|
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
struct xvfs_file_data *fileInfo;
long inode;
/*
* Validate input parameters
*/
if (!statBuf) {
return(XVFS_RV_ERR_EINVAL);
}
/*
* Get the inode from the lookup function
*/
inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
if (inode == XVFS_NAME_LOOKUP_ERROR) {
return(XVFS_RV_ERR_ENOENT);
}
fileInfo = &xvfs_<?= $::xvfs::fsName ?>_data[inode];
statBuf->st_dev = 0;
statBuf->st_rdev = 0;
statBuf->st_ino = inode;
|