I'm stat()
'ing this symlink (on Kubuntu GNU/Linux 16.04), and am getting the weird value of 0100600 octal (33152 decimal). If I bitwise-and it with S_IFMT
(which is 0170000 octal), I get 0600 octal. What does that mean? stat.h
lists the following values:
/* File types. */
#define __S_IFDIR 0040000 /* Directory. */
#define __S_IFCHR 0020000 /* Character device. */
#define __S_IFBLK 0060000 /* Block device. */
#define __S_IFREG 0100000 /* Regular file. */
#define __S_IFIFO 0010000 /* FIFO. */
#define __S_IFLNK 0120000 /* Symbolic link. */
#define __S_IFSOCK 0140000 /* Socket. */
I'm expecting to see 0120000, not 0600 (all octal). What gives?
Based on @dave_thompson_085's observation: Indeed, stat()
follows symlinks; I should be calling lstat()
- which does exactly the same thing, but doesn't follow the link.