This file is indexed.

/usr/share/tcltk/vfs1.3/tclprocvfs.tcl is in tcl-vfs 1.3-20080503-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 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
 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
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
192
193
194
195
196
197
198
199
200
package provide vfs::ns 0.5

package require vfs 1.0

# Thanks to jcw for the idea here.  This is a 'file system' which
# is actually a representation of the Tcl command namespace hierarchy.
# Namespaces are directories, and procedures are files.  Tcl allows
# procedures with the same name as a namespace, which are hidden in
# a filesystem representation.

namespace eval vfs::ns {}

proc vfs::ns::Mount {ns local} {
    if {![namespace exists ::$ns]} {
	error "No such namespace"
    }
    ::vfs::log "ns $ns mounted at $local"
    vfs::filesystem mount $local [list vfs::ns::handler $ns]
    vfs::RegisterMount $local [list vfs::ns::Unmount]
    return $local
}

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

proc vfs::ns::handler {ns cmd root relative actualpath args} {
    regsub -all / $relative :: relative
    if {$cmd == "matchindirectory"} {
	eval [list $cmd $ns $relative $actualpath] $args
    } else {
	eval [list $cmd $ns $relative] $args
    }
}

# If we implement the commands below, we will have a perfect
# virtual file system for namespaces.

proc vfs::ns::stat {ns name} {
    ::vfs::log "stat $name"
    if {[namespace exists ::${ns}::${name}]} {
	return [list type directory size 0 mode 0777 \
	  ino -1 depth 0 name $name atime 0 ctime 0 mtime 0 dev -1 \
	  uid -1 gid -1 nlink 1]
    } elseif {[llength [info procs ::${ns}::${name}]]} {
	return [list type file]
    } else {
	return -code error "could not read \"$name\": no such file or directory"
    }
}

proc vfs::ns::access {ns name mode} {
    ::vfs::log "access $name $mode"
    if {[namespace exists ::${ns}::${name}]} {
	return 1
    } elseif {[llength [info procs ::${ns}::${name}]]} {
	if {$mode & 2} {
	    error "read-only"
	}
	return 1
    } else {
	error "No such file"
    }
}

proc vfs::ns::exists {ns name} {
    if {[namespace exists ::${ns}::${name}]} {
	return 1
    } elseif {[llength [info procs ::${ns}::${name}]]} {
	return 1
    } else {
	return 0
    }
}

proc vfs::ns::open {ns name mode permissions} {
    ::vfs::log "open $name $mode $permissions"
    # return a list of two elements:
    # 1. first element is the Tcl channel name which has been opened
    # 2. second element (optional) is a command to evaluate when
    #    the channel is closed.
    switch -- $mode {
	"" -
	"r" {
	    set nfd [vfs::memchan]
	    set encoding [fconfigure $nfd -encoding]
	    set eofchar [fconfigure $nfd -eofchar]
	    set translation [fconfigure $nfd -translation]
	    fconfigure $nfd -translation binary
	    puts -nonewline $nfd [_generate ::${ns}::${name}]
	    fconfigure $nfd -translation $translation -encoding $encoding -eofchar $eofchar
	    seek $nfd 0
	    return [list $nfd]
	}
	default {
	    return -code error "illegal access mode \"$mode\""
	}
    }
}

proc vfs::ns::_generate {p} {
    lappend a proc $p
    set argslist [list]
    foreach arg [info args $p] {
	if {[info default $p $arg v]} {
	    lappend argslist [list $arg $v]
	} else {
	    lappend argslist $arg
	}
    }
    lappend a $argslist [info body $p]
}

proc vfs::ns::matchindirectory {ns path actualpath pattern type} {
    ::vfs::log "matchindirectory $path $actualpath $pattern $type"
    set res [list]

    if {[::vfs::matchDirectories $type]} {
	# add matching directories to $res
	if {[string length $pattern]} {
	    eval lappend res [namespace children ::${ns}::${path} $pattern]
	} else {
	    if {[namespace exists ::${ns}::${path}]} {
		eval lappend res ::${ns}::${path}
	    }
	}
    }
    
    if {[::vfs::matchFiles $type]} {
	# add matching files to $res
	if {[string length $pattern]} {
	    eval lappend res [info procs ::${ns}::${path}::$pattern]
	} else {
	    eval lappend res [info procs ::${ns}]
	}
    }
    set realres [list]
    foreach r $res {
	regsub "^(::)?${ns}(::)?${path}(::)?" $r $actualpath rr
	lappend realres $rr
    }
    #::vfs::log $realres
    
    return $realres
}

proc vfs::ns::createdirectory {ns name} {
    ::vfs::log "createdirectory $name"
    namespace eval ::${ns}::${name} {}
}

proc vfs::ns::removedirectory {ns name recursive} {
    ::vfs::log "removedirectory $name"
    namespace delete ::${ns}::${name}
}

proc vfs::ns::deletefile {ns name} {
    ::vfs::log "deletefile $name"
    rename ::${ns}::${name} {}
}

proc vfs::ns::fileattributes {ns name args} {
    ::vfs::log "fileattributes $args"
    switch -- [llength $args] {
	0 {
	    # list strings
	    return [list -args -body]
	}
	1 {
	    # get value
	    set index [lindex $args 0]
	    switch -- $index {
		0 {
		    ::info args ::${ns}::${name}
		}
		1 {
		    ::info body ::${ns}::${name}
		}
	    }
	}
	2 {
	    # set value
	    set index [lindex $args 0]
	    set val [lindex $args 1]
	    switch -- $index {
		0 {
		    error "read-only"
		}
		1 {
		    error "unimplemented"
		}
	    }
	}
    }
}

proc vfs::ns::utime {what name actime mtime} {
    ::vfs::log "utime $name"
    error ""
}