Diff

Differences From Artifact [ced159acac]:

To Artifact [307533bbcd]:


1







2
3
4
5
6
7
8
9
10
<?







	if {[info exists ::xvfs::xvfsCoreH]} {
?><?= $::xvfs::xvfsCoreH ?><?
	} else {
?>#include <xvfs-core.h><? } ?>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <tcl.h>


>
>
>
>
>
>
>

|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?
	# Care must be taken when editing this file as
	# it may be processed by either "xvfs-create"
	# which uses a full Tcl and Rivet parser
	# or by "xvfs-create-c" which uses a much
	# simpler one that only knows about printable
	# sections and ignores all Tcl sections

	if {[info exists ::xvfs::xvfsCoreH]} {
		::minirivet::_emitOutput $::xvfs::xvfsCoreH
	} else {
?>#include <xvfs-core.h><? } ?>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <tcl.h>

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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
	} data;
};
#endif

<?
	package require xvfs

	xvfs::main $::xvfs::argv

?>
static long xvfs_<?= $::xvfs::fsName ?>_nameToIndex(const char *path) {
<?
		if {[llength $::xvfs::outputFiles] < 3} {
			set hashMode perfectHashFunction
		} else {
			set hashMode hashTable
		}

		if {$hashMode eq "hashTable"} {
			set hashTable [::xvfs::generateHashTable pathIndex path pathLen XVFS_NAME_LOOKUP_ERROR $::xvfs::outputFiles prefix "\t" hashTableSize 30 validate "strcmp(path, xvfs_${::xvfs::fsName}_data\[pathIndex\].name) == 0" onValidated "return(pathIndex);"]
			set hashTableHeader [dict get $hashTable header]
			puts $hashTableHeader
		}
?>	long pathIndex;
	ssize_t pathLen;

	if (path == NULL) {
		return(XVFS_NAME_LOOKUP_ERROR);
	}

	pathLen = strlen(path);

<?
		if {$hashMode eq "perfectHashFunction"} {
?>
	pathIndex = <?= [::xvfs::generatePerfectHashFunctionCall "path" pathLen XVFS_NAME_LOOKUP_ERROR $::xvfs::outputFiles] ?>;
	if (pathIndex < 0 || pathIndex >= <?= [llength $::xvfs::outputFiles] ?>) {
		pathIndex = XVFS_NAME_LOOKUP_ERROR;
	}

	if (pathIndex != XVFS_NAME_LOOKUP_ERROR) {
		if (strcmp(path, xvfs_<?= $::xvfs::fsName ?>_data[pathIndex].name) == 0) {
			return(pathIndex);
		}
	}
<?
		} else {
			puts [dict get $hashTable body]
		}
?>
	return(XVFS_NAME_LOOKUP_ERROR);
}

static const char **xvfs_<?= $::xvfs::fsName ?>_getChildren(const char *path, Tcl_WideInt *count) {
	const struct xvfs_file_data *fileInfo;
	long inode;








|
|
<


<
<
<
<
<
<
<
|
|
|
<
|








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
<







58
59
60
61
62
63
64
65
66

67
68







69
70
71

72
73
74
75
76
77
78
79
80















81
82

83
84
85
86
87
88
89
	} data;
};
#endif

<?
	package require xvfs

	set ::xvfs::fileInfoStruct [xvfs::main $::xvfs::argv]
?><?= $::xvfs::fileInfoStruct ?>

static long xvfs_<?= $::xvfs::fsName ?>_nameToIndex(const char *path) {
<?







	set hashTable [::xvfs::generateHashTable pathIndex path pathLen XVFS_NAME_LOOKUP_ERROR $::xvfs::outputFiles prefix "\t" hashTableSize 30 validate "strcmp(path, xvfs_${::xvfs::fsName}_data\[pathIndex\].name) == 0" onValidated "return(pathIndex);"]
	set hashTableHeader [dict get $hashTable header]
?><?= $hashTableHeader ?>

	long pathIndex;
	ssize_t pathLen;

	if (path == NULL) {
		return(XVFS_NAME_LOOKUP_ERROR);
	}

	pathLen = strlen(path);
















<?= [dict get $hashTable body] ?>


	return(XVFS_NAME_LOOKUP_ERROR);
}

static const char **xvfs_<?= $::xvfs::fsName ?>_getChildren(const char *path, Tcl_WideInt *count) {
	const struct xvfs_file_data *fileInfo;
	long inode;

214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
	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   = <?= [zlib adler32 $::xvfs::fsName] ?>;
	statBuf->st_rdev  = <?= [zlib adler32 $::xvfs::fsName] ?>;
	statBuf->st_ino   = inode;
	statBuf->st_uid   = 0;
	statBuf->st_gid   = 0;
	statBuf->st_atime = 0;
	statBuf->st_ctime = 0;
	statBuf->st_mtime = 0;
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE







|
|







196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
	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   = <?= [zlib adler32 $::xvfs::fsName 0] ?>;
	statBuf->st_rdev  = <?= [zlib adler32 $::xvfs::fsName 0] ?>;
	statBuf->st_ino   = inode;
	statBuf->st_uid   = 0;
	statBuf->st_gid   = 0;
	statBuf->st_atime = 0;
	statBuf->st_ctime = 0;
	statBuf->st_mtime = 0;
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE