slip8&slip16
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
#include <time.h>
void displayFileProperties(const char* filename) {
struct stat fileStat;
if (stat(filename, &fileStat) == -1) {
perror("Error getting file information");
return;
}
printf("Inode number: %ld\n", fileStat.st_ino);
printf("Number of hard links: %ld\n", fileStat.st_nlink);
printf("File permissions: ");
printf((S_ISDIR(fileStat.st_mode)) ? "d" : "-");
printf((fileStat.st_mode & S_IRUSR) ? "r" : "-");
printf((fileStat.st_mode & S_IWUSR) ? "w" : "-");
printf((fileStat.st_mode & S_IXUSR) ? "x" : "-");
printf((fileStat.st_mode & S_IRGRP) ? "r" : "-");
printf((fileStat.st_mode & S_IWGRP) ? "w" : "-");
printf((fileStat.st_mode & S_IXGRP) ? "x" : "-");
printf((fileStat.st_mode & S_IROTH) ? "r" : "-");
printf((fileStat.st_mode & S_IWOTH) ? "w" : "-");
printf((fileStat.st_mode & S_IXOTH) ? "x" : "-");
printf("\n");
printf("File size: %ld bytes\n", fileStat.st_size);
printf("File access time: %s", ctime(&fileStat.st_atime));
printf("File modification time: %s", ctime(&fileStat.st_mtime));
struct passwd* user = getpwuid(fileStat.st_uid);
struct group* group = getgrgid(fileStat.st_gid);
if (user != NULL)
printf("Owner user: %s\n", user->pw_name);
if (group != NULL)
printf("Owner group: %s\n", group->gr_name);
}
int main() {
char filename[256];
printf("Enter the file name: ");
scanf("%s", filename);
displayFileProperties(filename);
return 0;
}