public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Documenting stat(2)
@ 2001-01-18  5:28 Eric S. Raymond
  2001-01-18  6:46 ` Linus Torvalds
  2001-01-18 12:56 ` Felix von Leitner
  0 siblings, 2 replies; 10+ messages in thread
From: Eric S. Raymond @ 2001-01-18  5:28 UTC (permalink / raw)
  To: Linux Kernel List

I'm trying to pin down and document the behavior of the size field in
stat(2) on Linux and under various stat emulations on Windows and the
Mac.  What I find out will be documented where it will do some good (in
particular I'll send a stat.2 man page patch to Andries Brouwer).

Here is what I think I know about stat(2) that isn't in the
Linux man pages:

* For a plain file or directory (S_IFREG or S_IFDIR), the st_size
field reports the size of the file in bytes.

* For a symlink (S_IFLNK) it reports the size of the link file, not the
size of the file the link points to. 

* For a socket or FIFO (S_IFSOCK, S_IFIFO) it reports the count of bytes
waiting to be read. 

* For a block special device (S_IFBLK) it returns 0.

I don't know what it should be expected to return for terminal or
other special devices.  My guess is number of characters waiting
in clists.

Can anyone verify, correct, or expand on the above?  Reply to 
esr@thyrsus.com, please, and thanks in advance.

(Among other things, this may turn into a substantial improvement
in the documented capabilities of Perl and Python.)
-- 
		<a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a>

The spirit of resistance to government is so valuable on certain
occasions, that I wish it always to be kept alive.  It will often be
exercised when wrong, but better so than not to be exercised at all.
I like a little rebellion now and then.  It is like a storm in the
Atmosphere.
	-- Thomas Jefferson, letter to Abigail Adams, 1787
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Documenting stat(2)
@ 2001-01-18  7:05 dmeyer
  2001-01-18 11:53 ` Padraig Brady
  0 siblings, 1 reply; 10+ messages in thread
From: dmeyer @ 2001-01-18  7:05 UTC (permalink / raw)
  To: linux-kernel

In article <9463fj$gsq$1@penguin.transmeta.com> you write:
> Basically, the _only_ think you should depend on is that st_size
> contains:
>  - for regular files, the size of the file in bytes
>  - for symlinks, the length of the symlink.

I don't think this is right - for a symlink, stat should return the
size of the file; lstat should return the size of the symlink.

-- 
David M. Meyer
dmeyer@dmeyer.net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2001-01-20 18:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-01-18  5:28 Documenting stat(2) Eric S. Raymond
2001-01-18  6:46 ` Linus Torvalds
2001-01-18 12:56 ` Felix von Leitner
  -- strict thread matches above, loose matches on Subject: below --
2001-01-18  7:05 dmeyer
2001-01-18 11:53 ` Padraig Brady
2001-01-18 15:54   ` dmeyer
2001-01-18 20:52   ` Igmar Palsenberg
2001-01-19  1:00     ` Mike Castle
2001-01-20 19:39       ` Igmar Palsenberg
2001-01-19 10:18   ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox