Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 60c8d0497d28ef94b9da563ab385576a162aaf3f
Ticket: 1325803fffffffffffffffffffffffffffffffff
stat ino, nlink fields not set
User & Date: obonilla on 2005-10-15 00:36:11
Changes

  1. icomment:
    Logged In: YES 
    user_id=219610
    
    There should be a warning in the release notes or somewhere that st_ino 
    can have collisions on Windows and should then not be used for 
    determining whether a file is the same as another. A typical idiom (in C) 
    for determining if two files are links to the same file is:
    
      if (stat(filea, &sa) || stat(fileb, &sb)) return (error);
      if ((sa.st_ino == sb.st_ino) && (sa.st_dev == sb.st_dev) && 
    sa.st_nlink >= 2)) return (same);
    
    In Tcl it would be more verbose, but it would follow the same pattern. 
    This is dangerous because on Windows that code could very well say 
    yeah, they're the same when in fact they are not. Obviously, the current 
    code just returns 0 for st_ino, so it would fail that test...
    
    In Unix, the '.' and '..' directories, are links to self and parent 
    respectively. So if you create an empty directory, it will have 2 links 
    (self, and the link from the parent directory). If the directory doesn't have 
    any subdirectories, it will have 2 links (same as before). If you create a 
    subdirectory, that subdirectory also has . (self) and .. (to directory), so 
    now, our directory will have 3 links. 
    
    $ mkdir foobar
    $ ls -lad foobar
    drwxr-xr-x   2 ob  ob  68 Oct 14 10:34 foobar
    $ mkdir foobar/baz
    $ ls -lad foobar
    drwxr-xr-x   3 ob  ob  102 Oct 14 10:34 foobar
    $ 
    
    A common optimization for determining whether you have to recourse 
    into a directory or not, is to use hard links to see if the directory has any 
    subdirectories or not... but I have to admit it's kind of a special case... 
    maybe not worth implementing.
    
    
    
    
  2. login: "obonilla"
  3. mimetype: "text/plain"
  4. username: "obonilla"