int stat(const char *pathname, struct stat *buf);
stat 構造体
/usr/include/bits/stat.h
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
struct stat info;
if( 0 < stat("file_name", &info) ) {
perror("stat");
return 1;
}
mode_t mod = info.st_mode;
if( (mod & S_IFMT) == S_IFREG) puts("regular file");
if( (mod & S_IFMT) == S_IFDIR) puts("directory");
if( (mod & S_IFMT) == S_IFCHR) puts("char device");
if( (mod & S_IFMT) == S_IFBLK) puts("block device");
if( (mod & S_IFMT) == S_IFLNK) puts("simbolic link");
if( (mod & S_IFMT) == S_IFSOCK) puts("socket");
fputs("owner access mode: ", stdout);
(mod & S_IRUSR & S_IRUSR) ? putchar('r') : putchar('-');
(mod & S_IWUSR & S_IWUSR) ? putchar('w') : putchar('-');
(mod & S_IXUSR & S_IXUSR) ? putchar('x') : putchar('-');
putchar('\n');
JM Project
http://linuxjm.sourceforge.jp/html/LDP_man-pages/man2/stat.2.html
stat - システムコールの説明 - Linux コマンド集 一覧表
http://kazmax.zpp.jp/cmd/s/stat.2.html