Subject: Re: sys/stat.h: S_IFLNK
To: Thorbjörn jemander <thoan@ifm.liu.se>
From: Chris G. Demetriou <cgd@sibyte.com>
List: tech-misc
Date: 01/09/2001 22:02:33
Thorbjörn jemander <thoan@ifm.liu.se> writes:
> Ah, no sorry, there was a parenthesis missing there. Sorry for
> that typo. What I do is a mask in a switch statement where
> all other non-type bits are masked away with S_IFMT:
>
> switch (file_stat.st_mode & S_IFMT) {
> [ ... ]
I'd think so, yes.
I don't know why stat on a regular file would get you into a S_IFLNK
case in code like you mention above.. Certainly, it shouldn't.
(BTW, using the S_IF* constants isn't portable, as i believe has
already been noted. Only portable way i know of to do what you're
trying to do is repeated if/else.)
> The problem is not on a masking level, it's on
> the file type flag interpretation level. What does these flags
> really mean (''character special '' for instance) and where
> can I read about them?
uh, well, the manual page actually does say what the things are.
"character special" and "block special" are devices. c.f. the 'mknod'
manual page ("make device special file"), etc.
cgd