Version 10 of vfs filesystem configuration

Updated 2007-01-18 18:12:53 by LV

filesystem attributes

Currently, Tcl actually has no introspection into a filesystem, beyond the 'file system $path' command which returns a Tcl-specific name ("native", "vfs"), and a type for the particular system (e.g. "NTFS", "FAT32", "Samba" might be possibilities there).

How can Tcl tell if the system is read-only (e.g. a CDROM)? It can't, I think...

Recent work with tclvfs suggests that it would be useful to be able to read and possibly set a number of filesystem-specific attributes. Some support for this has been added to the tclvfs package, but we need to think about what should go, in the long-term, into Tcl's core. tclvfs has this:

    % vfs::attributes $mountpoint
    -state readonly -commit 0

where the 'state' and 'commit' names are filesystem specific (but there is a convention that all the filesystem should support 'state'). This is rather like the 'file attributes' command, but operates at the filesystem level rather than the individual file level.

In the above example, one can in fact set some of the attributes:

    % vfs::attributes $mountpoint -state translucent -commit 1

for example.

Perhaps we can extend/modify 'file system' to provide this sort of information too? Or perhaps it should all go in a new 'filesystem' command (a core version of 'vfs::filesystem', perhaps).


12Feb03 Brian Theado - I couldn't find this without looking at the source code, so I thought I'd document it here. Of the above, only mk4 and ftp are fully writable vfs's. The rest are readonly.

Vince - That's right, and mk4 has configurable writability.

NB. There's no reason why the webdav, ns and tar filesystems can't be read-write, if people contribute the code.

13feb03 jcw - FWIW, here is a Tcl package to create a ZIP archive from scratch. This does not allow modifying ZIPs, it just writes a fresh one from start to finish:

        http://www.equi4.com/critlib/zipper.README
        http://www.equi4.com/critlib/zipper.tcl

(It's in critlib for no good reason, really)

The other new development is support for reading compressed data on-the-fly. This is not implemented as a Tcl stacked channel, but it has the same effect: you give it a channel, and you get back a new channel handle (read-only for now). It's actually slightly more involved because you also have to pass the size of the file, both in compressed and in expanded state (this is needed for "seek to end"). See "vfs::zstream" proc in TclVFS "vfslib.tcl". This might be used to adapt the existing .tar reader to work with .tar.gz files.

Jan 18th, 2007 - I've tried the zipper example, but it fails! Two zip-applications answer the file is wasted. Whta could i do?

Feb 19th Vince -- you can now configure the writability of mk4 filesystems.


LV May 5, 2003 - on the starkit mailing list today, someone pointed out that read and/or write is not the only thing missing - you can't get permission modes, owner, or group info about a vfs'd file either.

There is no portable way to do this - starkits do not track file modes, owners, groups, links. Just names, dates, and sizes... jcw

Vince: the vfs layer supports the completely general notion of file attributes. It is up to each vfs what attributes they care to manipulate. The vfs can try to replicate what is provided by each native platform (which are different, of course: LV's comment above is very unix-centric), or can create entirely its own set of attributes.

LV yes, since I'm using Unix, my comments are Unix-centric. And since the original question came up by someone else on comp.lang.tcl and the starkit mailing list, apparently there are other unix / linux users who also have the same questions...


[ Category VFS ]