Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!rice!sun-spots-request From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.sys.sun Subject: Re: ls -i vs. stat() Keywords: Miscellaneous Message-ID: <1990Sep20.204314.1826@rice.edu> Date: 21 Sep 90 00:02:07 GMT Sender: sun-spots-request@rice.edu Organization: Sun-Spots Lines: 27 Approved: Sun-Spots@rice.edu Originator: spots@titan.rice.edu X-Sun-Spots-Digest: Volume 9, Issue 319, message 3 In article <1990Aug23.225411.10266@rice.edu>, jsulliva@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@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/