Unix System Calls
// Unix system calls
// stat
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
void main(int argc, char **argv)
{
if(argc != 2)
printf("Usage error: Invalid number of arguments.");
struct stat fs;
if(stat(argv[1],&fs) < 0)
printf("Usage error: File / directory does not exist.");
printf("Information for %s\n",argv[1]);
printf("File
Size: \t\t%d bytes\n",fs.st_size);
printf("File
inode: \t\t%d\n",fs.st_ino);
printf("File
mode: \t\t%d\n",fs.st_mode);
printf("user
ID of file owner: \t%d\n",fs.st_uid);
printf("File
last access time: \t%d\n",fs.st_atime);
}
No comments:
Post a Comment
Don't be a silent reader...
Leave your comments...
Anu