ls -i vs. stat()

Jeff Sullivan jsulliva at killington.prime.com
Thu Aug 16 08:12:13 AEST 1990


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.

 The man page for 'ls' says:
     -i   For each file, print the i-number in the  first  column
	  of the report.

 The simple program I that called the stat() system call did this:
            stat(filename,&sbuf);
            printf("\ti-number = %-10d %s\n",sbuf.st_ino,filename);

 Running a simple test:
	$ stattest stat.c
        i-number = 2953       stat.c
	$ ln -s stat.c stat.link
	$ 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.

  Any help appreciated,

Jeff Sullivan | Computervision/Prime | jsulliva at cvbnet.prime.com
CADDS R&D     | Bedford, MA    01730 | sun!cvbnet!jsulliva



More information about the Comp.sys.sun mailing list