I have the code below, only part of it is shown here, and I check if there is a file type.
struct stat *buf /* just to show the type buf is*/ switch (buf.st_mode & S_IFMT) { case S_IFBLK: printf(" block device\n"); break; case S_IFCHR: printf(" character device\n"); break; case S_IFDIR: printf(" directory\n"); break; case S_IFIFO: printf(" FIFO/pipe\n"); break; case S_IFLNK: printf(" symlink\n"); break; case S_IFREG: printf(" regular file\n"); break; case S_IFSOCK: printf(" socket\n"); break; default: printf(" unknown?\n"); break; }
Problem: st_mode value obtained when I do a printf("\nMode: %d\n",buf.st_mode); , the result is 33188.
I tested my program with the usual file type and symlink. In both cases, the output was a "regular file", i.e. The symlink case fails, and I don't understand why?
c linux system-calls symlink stat
Eternal learningner
source share