lsを書く。
ファイルタイプとパーミッションを調べるのにマスキングを使う。
sys/stat.hのファイルタイプのとこ
/* File type */
#define S_IFMT 0170000 /* [XSI] type of file mask */
#define S_IFIFO 0010000 /* [XSI] named pipe (fifo) */
#define S_IFCHR 0020000 /* [XSI] character special */
#define S_IFDIR 0040000 /* [XSI] directory */
#define S_IFBLK 0060000 /* [XSI] block special */
#define S_IFREG 0100000 /* [XSI] regular */
#define S_IFLNK 0120000 /* [XSI] symbolic link */
#define S_IFSOCK 0140000 /* [XSI] socket */
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
#define S_IFWHT 0160000 /* whiteout */
#define S_IFXATTR 0200000 /* extended attribute */
#endif
man ls
b Block special file.
c Character special file.
d Directory.
l Symbolic link.
s Socket link.
p FIFO.
- Regular file.