|
[root@localhost work]# ll slink prog
-rwxr-xr-x 1 root root 12752 4月 19 23:25 prog
lrwxrwxrwx 1 root root 4 4月 20 12:44 slink -> prog
源文件file.c
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdlib.h>
int main()
{
int filedes;
struct stat statbuf;
unsigned short int modes;
stat("slink",&statbuf);
modes=statbuf.st_mode;
printf("slink mode is %o \n",modes);
printf("is link %d\n",S_ISLNK(modes));
}
gcc file.c -o file
./file
运行结果:
slink mode is 100755
is link 0
显示的竟然是prog文件的信息.
而不是链接文件slink的信息..
请高手解答. |
|