ls -i vs. stat()
Randal Schwartz
merlyn at iwarp.intel.com
Fri Sep 21 10:02:07 AEST 1990
In article <1990Aug23.225411.10266 at rice.edu>, jsulliva at killington (Jeff Sullivan) writes:
| I have noticed that 'ls -i' is giving different i-numbers for linked
| files, while stat() says that they are the same. This was noticed on
| SunOS 4.0.3.
[program deleted]
| $ stattest stat.*
| i-number = 2953 stat.c
| i-number = 2953 stat.link
| $ ln -i stat.*
| 2953 stat.c 38379 stat.link
|
| Is this the correct output for the 'ls -i' command? I would expect all
| links to have the same i-number as the original.
My guess is that stat.link is a symlink pointing at stat.c. (I can't tell
from the info you give.) The stat(2) syscall gives you information on the
pointed-at file, while "ls -i" is giving you the real inode information.
If you want different numbers in your C program, use lstat(2) instead of
stat(2). If you want the same number from "ln -i", use real links, not
symlinks.
Just another Unix hacker,
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III |
| merlyn at iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/
More information about the Comp.sys.sun
mailing list