Check-in [a9fb6a2bd7]
Overview
Comment:Removed partial symlink implementation from KitDLL

Reorganized KitDLL code

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a9fb6a2bd7f21f317a00afa5c69aa4b9c4e17a90
User & Date: rkeene on 2010-09-26 04:50:52
Other Links: manifest | tags
Context
2010-09-26
04:50
Initial dir2c.tcl check-in: 1471135306 user: rkeene tags: trunk
04:50
Removed partial symlink implementation from KitDLL

Reorganized KitDLL code check-in: a9fb6a2bd7 user: rkeene tags: trunk

04:50
Fixed issue with glob of top dir check-in: cc20ec9009 user: rkeene tags: trunk
Changes

Modified kitdll/buildsrc/kitdll-0.0/cvfs.tcl from [abcb041a6c] to [aa949e8f6f].

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
}

# Implementation

## Filesystem Data
namespace eval ::vfs::kitdll::data {}
set ::vfs::kitdll::data(joe) "Test\n"
set ::vfs::kitdll::data(bob) "joe"
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(bob) [list type link ino 4 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"
	}







<


<







16
17
18
19
20
21
22

23
24

25
26
27
28
29
30
31
}

# 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"
	}
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

		lappend newchildren $tail
	}

	return $newchildren
}

## VFS
### Helpers
namespace eval ::vfs::kitdll::vfsdata {}
set ::vfs::kitdll::vfsdata::fileidx -1

### Implemented
#### Single Handler
proc ::vfs::kitdll::vfshandler {hashkey subcmd args} {
	set cmd $args
	set cmd [linsert $cmd 0 "::vfs::kitdll::vfsop_${subcmd}" $hashkey]

	return [eval $cmd]
}

proc ::vfs::kitdll::chanhandler {hashkey subcmd args} {
	set cmd $args
	set cmd [linsert $cmd 0 "::vfs::kitdll::chanop_${subcmd}" $hashkey]

	return [eval $cmd]
}

#### Actual handlers




##### Finished




















































proc ::vfs::kitdll::vfsop_stat {hashkey root relative actualpath} {
	catch {
		set ret [::vfs::kitdll::data::getMetadata $hashkey $relative]
	}

	if {![info exists ret]} {
		vfs::filesystem posixerror $::vfs::posix(ENOENT)







|
<
<
<
|
<
<














|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
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

		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]
}

proc ::vfs::kitdll::chanhandler {hashkey subcmd args} {
	set cmd $args
	set cmd [linsert $cmd 0 "::vfs::kitdll::chanop_${subcmd}" $hashkey]

	return [eval $cmd]
}

### Actual handlers
#### Channel operation handlers
proc ::vfs::kitdll::chanop_initialize {hashkey chanId mode} {
	return [list initialize finalize watch read seek]
}

proc ::vfs::kitdll::chanop_finalize {hashkey chanId} {
	unset -nocomplain ::vfs::kitdll::chandata([list $hashkey $chanId])

	return
}

proc ::vfs::kitdll::chanop_watch {hashkey chanId eventSpec} {
	array set chaninfo $::vfs::kitdll::chandata([list $hashkey $chanId])

	set chaninfo(watching) $eventSpec

	set ::vfs::kitdll::chandata([list $hashkey $chanId]) [array get chaninfo]

	if {[lsearch -exact $chaninfo(watching) "read"] != -1} {
		after 0 [list catch "chan postevent $chanId [list {read}]"]
	}

	return
}

proc ::vfs::kitdll::chanop_read {hashkey chanId bytes} {
	array set chaninfo $::vfs::kitdll::chandata([list $hashkey $chanId])

	set pos $chaninfo(pos)
	set len $chaninfo(len)

	if {[lsearch -exact $chaninfo(watching) "read"] != -1} {
		after 0 [list catch "chan postevent $chanId [list {read}]"]
	}

	if {$pos == $len} {
		return ""
	}

	set end [expr {$pos + $bytes}]
	if {$end > $len} {
		set end $len
	}

	set data [::vfs::kitdll::data::getData $hashkey $chaninfo(file) $pos $end]

	set dataLen [string length $data]
	incr pos $dataLen

	set chaninfo(pos) $pos

	set ::vfs::kitdll::chandata([list $hashkey $chanId]) [array get chaninfo]

	return $data
}

#### VFS operation handlers
proc ::vfs::kitdll::vfsop_stat {hashkey root relative actualpath} {
	catch {
		set ret [::vfs::kitdll::data::getMetadata $hashkey $relative]
	}

	if {![info exists ret]} {
		vfs::filesystem posixerror $::vfs::posix(ENOENT)
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120


121
122
123
124
125
126
127

	return 1
}

proc ::vfs::kitdll::vfsop_matchindirectory {hashkey root relative actualpath pattern types} {
	set ret [list]

	if {$pattern == ""} {
		catch {
			set test [::vfs::kitdll::data::getMetadata $hashkey $relative]
		}

		if {![info exists test]} {
			set children [list]
		}



		set children [list $relative]
	} else {
		set children [::vfs::kitdll::data::getChildren $hashkey $relative]
	}

	foreach child $children {







<
|
|
|

|
|
|
>
>







155
156
157
158
159
160
161

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177

	return 1
}

proc ::vfs::kitdll::vfsop_matchindirectory {hashkey root relative actualpath pattern types} {
	set ret [list]


	catch {
		array set metadata [::vfs::kitdll::data::getMetadata $hashkey $relative]
	}

	if {![info exists metadata]} {
		return [list]
	}

	if {$pattern == ""} {

		set children [list $relative]
	} else {
		set children [::vfs::kitdll::data::getChildren $hashkey $relative]
	}

	foreach child $children {
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
			return [format {0%o} $metadata(mode)]
		}
	}

	return -code error "Invalid index"
}

proc ::vfs::kitdll::chanop_initialize {hashkey chanId mode} {
	return [list initialize finalize watch read seek]
}

proc ::vfs::kitdll::chanop_finalize {hashkey chanId} {
	unset -nocomplain ::vfs::kitdll::chandata([list $hashkey $chanId])

	return
}

proc ::vfs::kitdll::chanop_watch {hashkey chanId eventSpec} {
	array set chaninfo $::vfs::kitdll::chandata([list $hashkey $chanId])

	set chaninfo(watching) $eventSpec

	set ::vfs::kitdll::chandata([list $hashkey $chanId]) [array get chaninfo]

	if {[lsearch -exact $chaninfo(watching) "read"] != -1} {
		after 0 [list catch "chan postevent $chanId [list {read}]"]
	}

	return
}

proc ::vfs::kitdll::chanop_read {hashkey chanId bytes} {
	array set chaninfo $::vfs::kitdll::chandata([list $hashkey $chanId])

	set pos $chaninfo(pos)
	set len $chaninfo(len)

	if {[lsearch -exact $chaninfo(watching) "read"] != -1} {
		after 0 [list catch "chan postevent $chanId [list {read}]"]
	}

	if {$pos == $len} {
		return ""
	}

	set end [expr {$pos + $bytes}]
	if {$end > $len} {
		set end $len
	}

	set data [::vfs::kitdll::data::getData $hashkey $chaninfo(file) $pos $end]

	set dataLen [string length $data]
	incr pos $dataLen

	set chaninfo(pos) $pos

	set ::vfs::kitdll::chandata([list $hashkey $chanId]) [array get chaninfo]

	return $data
}

proc ::vfs::kitdll::vfsop_open {hashkey root relative actualpath mode permissions} {
	if {$mode != "" && $mode != "r"} {
		vfs::filesystem posixerror $::vfs::posix(EROFS)
	}

	catch {
		array set metadata [::vfs::kitdll::data::getMetadata $hashkey $relative]







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







253
254
255
256
257
258
259























































260
261
262
263
264
265
266
			return [format {0%o} $metadata(mode)]
		}
	}

	return -code error "Invalid index"
}
























































proc ::vfs::kitdll::vfsop_open {hashkey root relative actualpath mode permissions} {
	if {$mode != "" && $mode != "r"} {
		vfs::filesystem posixerror $::vfs::posix(EROFS)
	}

	catch {
		array set metadata [::vfs::kitdll::data::getMetadata $hashkey $relative]
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314

		return [list $chan]
	}

	return -code error "No way to generate a channel, need either Tcl 8.5+, \"rechan\""
}

### No-Ops since we are a readonly filesystem
proc ::vfs::kitdll::vfsop_createdirectory {args} {
	vfs::filesystem posixerror $::vfs::posix(EROFS)
}
proc ::vfs::kitdll::vfsop_deletefile {args} {
	vfs::filesystem posixerror $::vfs::posix(EROFS)
}
proc ::vfs::kitdll::vfsop_removedirectory {args} {







|







295
296
297
298
299
300
301
302
303
304
305
306
307
308
309

		return [list $chan]
	}

	return -code error "No way to generate a channel, need either Tcl 8.5+, \"rechan\""
}

##### No-Ops since we are a readonly filesystem
proc ::vfs::kitdll::vfsop_createdirectory {args} {
	vfs::filesystem posixerror $::vfs::posix(EROFS)
}
proc ::vfs::kitdll::vfsop_deletefile {args} {
	vfs::filesystem posixerror $::vfs::posix(EROFS)
}
proc ::vfs::kitdll::vfsop_removedirectory {args} {