Skip to content
Tcl Source Code History Of Ticket 678662ffffffffffffffffffffffffffffffffff
Login

History Of Ticket 678662ffffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 678662ffffffffffffffffffffffffffffffffff

  1. Ticket change [3186ba3490] (rid 93442) by jcw on 2003-02-01 13:44:10:

    1. assignee initialized to: "vincentdarley"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Below a transcript which I can not figure out.  All based on the latest CVS, Feb 1.  FYI, I added a debug puts to tclkit's boot.tcl, showing the mount command it sets up on startup:
      
      try $ mkdir foo
      try $ cd foo/
      foo $ ln -s ../tclkit bar
      foo $ cd ..
      try $ foo/bar 
      vfs::filesystem mount /home/shared/basekit/tclkit/try/foo/bar ::vfs::mk4::handler exe
      application-specific initialization failed: unknown encoding "iso8859-1"
      % vfs::filesystem info
      /home/shared/basekit/tclkit/tclkit
      % info nameofexe
      /home/shared/basekit/tclkit/try/foo/bar
      % pwd
      /home/shared/basekit/tclkit/try
      %
      
      The weird part is the output of "vfs::filesystem info".  That path was how tclkit was originally built, but I've moved it inside "try/", so it does not exist.  Note that the symlink is relative, it has a ".." in it.  This is a tricky case.
      
      There seems to be something hosed, I'm checking into it.  In the same case as above - watch this:
      
      try $ ./tclkit
      vfs::filesystem mount /home/shared/basekit/tclkit/try/tclkit ::vfs::mk4::handler exe
      % file readlink foo/bar
      ../tclkit
      % file size foo/bar
      3011296
      % open foo/bar
      file4
      % open [file readlink foo/bar]
      couldn't open "../tclkit": no such file or directory
      
      Everything appears to be ok, this shows that open and open/readlink are not identical (logical, though perhaps not expected).  Explanation: the ".." in the symlink would need to be resolved against the dir in which the symlink resides.
      
      Now compare with running the same tclkit executable through a symlink:
      
      try $ foo/bar
      vfs::filesystem mount /home/shared/basekit/tclkit/try/foo/bar ::vfs::mk4::handler exe
      application-specific initialization failed: unknown encoding "iso8859-1"
      % file readlink foo/bar
      ../tclkit
      % file size foo/bar
      3011296
      % open foo/bar
      file4
      % seek file4 0 end
      % tell file4
      3011296
      % open [file readlink foo/bar]
      mk1
      % read mk1
      % file stat foo/bar sb
      % array get sb
      mtime 1044103928 atime 1044103927 gid 100 nlink 1 mode 33261 type file ctime 1044103953 uid 500 ino 273302 size 3011296 dev 778
      % seek mk1 0 end
      error during seek on "mk1": Success
      % tell mk1
      -1
      % 
      
      This second case shows that the original path still looks like a file (the tclkit executable), but opening the dereferenced symlink ends up being inside VFS.  I don't understand what it is, the "file" seems to be bogus (rightly so maybe, since the thing *should* be a mountpoint now, i.e. a dir).
      
      Looks like a couple of things are not right.  I'm not sure exactly *what* the correct results for all these cases should be, but wanted to pass this on.
      
      It all came about when I noticed that symlinked starkits did not mount properly.  I started adding some code, but it's getting hairy.
      
      Would it be better if "file readlink" returned a path which was fully resolved?  The way it is now, it looks like translating a symlink to the real file will require some nasty path trickery.  What I can think of so far to deal with relative symlinks on Unix is:
        set f [file join [file dirname $f] [file readlink $f]]
      Yikes...
      
    4. foundin initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "jcw"
    9. subsystem initialized to: "37. File System"
    10. title initialized to: "symlinks and mountpoints - confused?"
    11. type initialized to: "RFE"
  2. Ticket change [6e9c4a2bd6] (rid 100179) by jcw on 2003-02-01 21:23:52:

    1. icomment:
      Logged In: YES 
      user_id=1983
      
      Got it... I think.  Same example as before:
      
      % file normalize foo/bar
      /home/shared/basekit/tclkit/try/foo/bar
      % file readlink foo/bar
      ../tclkit
      % file normalize [file readlink foo/bar]
      /home/shared/basekit/tclkit/tclkit
      % 
      
      FWIW, the resolved symlink points to:
        /home/shared/basekit/tclkit/try/tclkit
      
      Nothing in the above is technically wrong.  But it's what is causing the "vfs::filesystem info" to report a bad path, somewhere in tclvfs.  IMO, the potential confusion is important enough to treat this as a core issue, not just tclvfs.
      
      
    2. login: "jcw"
    3. mimetype: "text/plain"
    4. username: "jcw"
  3. Ticket change [1adeceb091] (rid 123049) by vincentdarley on 2003-02-05 01:10:26:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      Isn't this a bug in VfsFullyNormalizePath in tclvfs/vfs.c. 
      What does that function give when passed your 
      try/foo/bar path? 
      
      I don't believe it is mounting the thing in the right place.
      
      In principle it would actually be more helpful if Tcl 
      provided an API to return a fully normalized path, but, 
      currently it doesn't.  (In retrospect this was a bit of an 
      oversight of TIP 17).
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. username: "vincentdarley"
  4. Ticket change [1ea0110364] (rid 91005) by vincentdarley on 2003-02-05 01:25:23:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      Oops sorry.  Isn't there are clear bug in your 'file 
      normalize [file readlink foo/bar]'
      
      Or should that line instead be 'file normalize [file join 
      [pwd] [file readlink foo/bar]]'
      
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. username: "vincentdarley"
  5. Ticket change [731655b28e] (rid 104984) by jcw on 2003-02-05 01:37:11:

    1. icomment:
      Logged In: YES 
      user_id=1983
      
      Yes, this is indeed (on purpose) naively wrong:
      - file normalize [file readlink foo/bar]'
      
      But the solution you offer does not work, I think:
      - file normalize [file join [pwd] [file readlink foo/bar]]
      
      Explanation: readlink will return "../tclkit".  Join that to pwd, which is try, and you end up with /home/shared/tclkit/tclkit
      
      This is not rigth either: the point is that symlinks resolve relatively to where *they* are, not to what my pwd happens to be.  This is the essence of the whole problem, IMO.
      
      Methinks we may need a better file normalize (or perhaps "file normalize -full") which does symlink expansion.  This is all solvable, but I'm afraid the current situation will trip people.  Well, at least one person... me.  Heh.
      
      
    2. login: "jcw"
    3. mimetype: "text/plain"
    4. username: "jcw"
  6. Ticket change [b809c19a30] (rid 128909) by vincentdarley on 2003-02-05 01:46:09:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      So in fact you want:
      
      set me "foo/bar"
      file normalize [file join [file dirname $me] [file readlink 
      $me]]
      
      I agree 'file normalize -full' and an equivalent C API are 
      needed.
      
      Vince.
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. username: "vincentdarley"
  7. Ticket change [0931a64570] (rid 89676) by vincentdarley on 2003-02-05 02:01:24:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      I've committed what I think is a fix to vfs.c -- please 
      test.
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. username: "vincentdarley"
  8. Ticket change [c1b6d616aa] (rid 111368) by jcw on 2003-02-05 02:23:55:

    1. icomment:
      Logged In: YES 
      user_id=1983
      
      Error gone (running tclkit through a symlink).
      Flesystem mount listed ok now.
      BINGO!
      
      
    2. login: "jcw"
    3. mimetype: "text/plain"
    4. username: "jcw"
  9. Ticket change [05420291ab] (rid 89025) by vincentdarley on 2003-02-05 02:28:24:

    1. assignee changed to: "nobody"
    2. subsystem changed to: "None"
    3. title changed to:
      Tcl needs 'file normalize -full' and similar C api.
      
  10. Ticket change [213fd49b19] (rid 130550) by dgp on 2003-02-05 02:49:08:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      Isn't this just a bug in [file normalize] ?
      
      Why add a "-full" switch?  Why not just fix the bug?
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  11. Ticket change [874b19fdf1] (rid 131669) by jcw on 2003-02-05 03:00:50:

    1. icomment:
      Logged In: YES 
      user_id=1983
      
      Looks like there are different ways to interpret "normalization":
        - convert relative path to absolute path (based on curr dir)
        - simplify "a/b/../c" to "a/c"
        - expand symlinks
        - a combination of the above
      (first two can be done on non-existent paths, btw, rest not)
      
      I'll leave it to others as to how this translates to features and options in Tcl.
      
      
    2. login: "jcw"
    3. mimetype: "text/plain"
    4. username: "jcw"
  12. Ticket change [4a26dab803] (rid 126489) by vincentdarley on 2003-02-05 19:51:23:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      Well, 2 comments:
      
      'normalization' is defined in Tcl's man pages to be a 
      unique representation of the filesystem from Tcl's point 
      of view. This actually goes beyond jcw's list to include 
      the unique case-sensitive name (even on case-
      insensitive systems like Win/Mac).  BUT, it does not 
      include expansion of a symlink in the final element of 
      the path, because Tcl's view is that it wants to see the 
      symlink (for 'file delete', etc).
      
      This is why an additional 'file normalize -full' is needed, 
      and why it isn't a bug in [file normalize].  Otherwise I 
      could never ask Tcl for the full normalized path to a 
      symlink which would be a curious omission.
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. username: "vincentdarley"
  13. Ticket change [357c39da9c] (rid 106943) by dgp on 2003-02-06 22:45:49:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      Thanks, Vince.  I understand better now.
      (Looking at the docs always helps.)
      
      So, it seems clear that the [file] command
      does not hide links from the caller.  The
      caller is expected to know that links exist
      and behave somewhat differently from
      normal files.
      
      Given that, it seems the correct answer
      has already been identified.  If the caller
      does want to follow a symlink reference,
      that caller should evaluate:
      
          file join [file dirname $link] [file readlink $link]
      
      and then [file normalize] the result, if normalized
      form is required.  All the tools are in place, and
      it's up to the caller to use them correctly.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  14. Ticket change [1517969c6c] (rid 124506) by hobbs on 2003-02-07 02:14:08:

    1. icomment:
      Logged In: YES 
      user_id=72656
      
      I agree with dgp's analysis.  The tools are all there.  We could 
      stack more up for Tcl to auto-handle it, but if the user is going 
      to add the flag, they already know a different "path" is 
      needed.  The default behavior that file normalize works on non-
      existent files/dirs is important.
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. username: "hobbs"
  15. Ticket change [604d05aa74] (rid 115966) by hobbs on 2003-11-12 07:27:44:

    1. assignee changed to: "vincentdarley"
    2. subsystem changed to: "37. File System"
  16. Ticket change [5ce53ab0d8] (rid 261548) by serhiy.storchaka on 2026-11-13 11:18:45:

    1. closedate changed to: "2461357.9713335303"
    2. closer changed to: "serhiy.storchaka"
    3. icomment:
      Closing per dgp's and hobbs' comments: the existing commands are sufficient, and neither file normalize -full nor a separate C API was added.
      
    4. login: "serhiy.storchaka"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Rejected"
    7. status changed to: "Closed"