Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#4448 unexpected absolute path with vfs

obsolete: 8.5.5
closed
Don Porter
7
2009-11-18
2009-10-27
Stephen Huntley
No

When using "file join" on a string that happens to include a virtual volume name as a substring, the string is improperly split at the substring boundary, and the command acts as though there were a space at the substring boundary.

For convenience I have attached a file (templatevfs.tcl) to make it easy to create a virtual volume by mounting a virtual filesystem, but the issue should not be construed as limited to this vfs.

Example:

% cd
% file mkdir testvfs
% source templatevfs.tcl
% vfs::template::mount -volume testvfs testvfs
testvfs
%file volumes ; # note testvfs is now a virtual volume
testvfs /
% file join testvfstest ; # expect response: testvfstest
testvfs/test

Note in the last statement "testvfstest" is an arbitrary string which just happens to start with "testvfs". The command "file join testvfstest" should simply echo the argument string. But the command acts as if there were a space between "testvfs" and "test".

Also note:

% file join foo testvfstest
testvfs/test

Discarding "foo" would be expected if there were a space between "testvfs" and "test", since the command discards arguments that come before a volume name. But the response should be "foo/testvfstest". This illustrates that "testvfs" is being treated as a volume name rather than as a substring.

Tested on Ubuntu Hardy.

Discussion

1 2 > >> (Page 1 of 2)
  • template vfs code

     
    Attachments
  • Don Porter
    Don Porter
    2009-10-27

    At the point of failure, what does
    [file pathtype testvfstest] return?

     
  • Don Porter
    Don Porter
    2009-10-27

    • assigned_to: vincentdarley --> dgp
    • priority: 5 --> 7
    • status: open --> pending
     
  • Don Porter
    Don Porter
    2009-10-27

    The values returned by [file system testvfstest]
    and [file normalize testvfstest] might be useful
    as well.

     
  • After executing the steps above:

    % file join testvfstest
    testvfs/test
    % file pathtype testvfstest
    absolute
    % file system testvfstest
    native
    % file normalize testvfstest
    <home>/testvfs/test

     
    • status: pending --> open
     
  • Don Porter
    Don Porter
    2009-10-28

    Thanks for the replies.

    Since "testvfstest" is seen as
    an absolute path, [file join] is behaving
    properly as documented.

    The bug, if there is one, is the combination
    of results you just posted. Whether the
    flaw is in Tcl, tclvfs, the vfs::template driver,
    or your code, I cannot say without diving
    deeper. Can you, or someone in any
    of those projects say with more clarity,
    which of the command outcomes you
    posted are incorrect, and why?

    Thanks.

     
  • Don Porter
    Don Porter
    2009-10-28

    • status: open --> pending
     
  • Don Porter
    Don Porter
    2009-10-28

    • summary: "file join" improperly injects space --> unexpected absolute path with vfs
     
  • It is incorrect for [file pathtype] to return a value of "absolute" in the given example. Since there is no path separator in the string "testvfstest", the only time [file pathtype testvfstest] should return "absolute" would be if there were a mounted volume named "testvfstest", but there isn't.

    It is also incorrect for [file join testvfstest] to return "testvfs/test", even if it were correct that testvfstest was an absolute path. If [file join] is passed an absolute path as the sole argument, the argument should be returned unchanged. If [file join] is passed an arbitrary string that doesn't correspond to an existing file, the string should also be returned unchanged. Whichever is the case, [file join] should simply pass the argument back unchanged.

    There is no file or volume named "testvfstest". The handler code written by me is not called when either the [file pathtype] command or the [file join] command is executed. Thus the problem is either with Tcl or the Tclvfs extension.

     
1 2 > >> (Page 1 of 2)