Diff

Differences From Artifact [94451bedbe]:

To Artifact [3533698919]:


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
14
15
16
17
18
19
20







21
22
23
24
25
26
27
28



























29
30
31
32
33
34
35







-
-
-
-
-
-
-








-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







proc ::vfs::kitdll::Unmount {local} {
	vfs::filesystem unmount $local
}

# Implementation

## Filesystem Data
namespace eval ::vfs::kitdll::data {}
set ::vfs::kitdll::data(joe) "Test\n"
set {::vfs::kitdll::metadata()} [list type directory ino 0 mode 0555 nlink 2 uid 0 gid 0 size 0 atime 0 mtime 0 ctime 0]
set ::vfs::kitdll::metadata(joe) [list type file ino 1 mode 0444 nlink 1 uid 0 gid 0 size 5 atime 0 mtime 0 ctime 0]
set ::vfs::kitdll::metadata(sub) [list type directory ino 2 mode 0555 nlink 1 uid 0 gid 0 size 0 atime 0 mtime 0 ctime 0]
set ::vfs::kitdll::metadata(sub/sub2) [list type directory ino 3 mode 0555 nlink 1 uid 0 gid 0 size 0 atime 0 mtime 0 ctime 0]

proc ::vfs::kitdll::data::getData {hashkey file {start 0} {end "end"}} {
	if {![info exists ::vfs::kitdll::data($file)]} {
		return -code error "Invalid operation"
	}

	return [string range $::vfs::kitdll::data($file) $start $end]
}

proc ::vfs::kitdll::data::getMetadata {hashkey file} {
	if {![info exists ::vfs::kitdll::metadata($file)]} {
		return -code error "No such file"
	}

	return $::vfs::kitdll::metadata($file)
}

proc ::vfs::kitdll::data::getChildren {hashkey directory} {
	set pattern [file join $directory {[^/]*}]

	set children [array names ::vfs::kitdll::metadata -regexp "^${pattern}\$"]

	set newchildren [list]
	foreach child $children {
		if {$child == ""} {
			continue
		}

		set tail [lindex [split $child /] end]

		lappend newchildren $tail
	}

	return $newchildren
}

## VFS and Chan I/O
### Dispatchers
proc ::vfs::kitdll::vfshandler {hashkey subcmd args} {
	set cmd $args
	set cmd [linsert $cmd 0 "::vfs::kitdll::vfsop_${subcmd}" $hashkey]

	return [eval $cmd]
212
213
214
215
216
217
218
219
220


221
222

223
224
225
226
227
228
229
178
179
180
181
182
183
184


185
186
187

188
189
190
191
192
193
194
195







-
-
+
+

-
+







		}

		unset -nocomplain metadata
		catch {
			array set metadata [::vfs::kitdll::data::getMetadata $hashkey $child]
		}

		if {[string index $actualpath end] == "/"} {
			set child "${actualpath}${child}"
		if {[string index $root end] == "/"} {
			set child "${root}${child}"
		} else {
			set child "${actualpath}/${child}"
			set child "${root}/${child}"
		}
		if {[string index $child end] == "/"} {
			set child [string range $child 0 end-1]
		}

		if {![info exists metadata(type)]} {
			continue
342
343
344
345
346
347
348


308
309
310
311
312
313
314
315
316







+
+
	vfs::filesystem posixerror $::vfs::posix(EROFS)
}
proc ::vfs::kitdll::vfsop_utime {} {
	vfs::filesystem posixerror $::vfs::posix(EROFS)
}

package provide vfs::kitdll 1.0

::vfs::kitdll::Mount vfs_kitdll_data /tmp