The code is well commented, the compiler isn't pointing anything really great, so I'm kinda lost, it is an exercise on a book I'm reading...
Code:
/*check flags.c - display info on ext2 extended attributes*/
/* For each file name on the command line, display information on that
file's ext2 attributes */
#include<errno.h>
#include<fcntl.h>
#include<linux/ext2_fs.h>
#include<stdio.h>
#include<sys/ioctl.h>
#include<unistd.h>
int main(int argc, char **argv){
char **filename = argv + 1;
int fd;
int flags;
/*Iterate over each file name on the command line. The last pointer in argv[]
is NULL, so this while() loop is legal*/
while (*filename){
/*Unlike normal attributes, ext2 attributes can only be queried if
we have a file descriptor (a file name is not sufficient). We
dont need write acces to query the ext2 attributes, so O_RDONLY is ok*/
fd = open(*filename, O_RDONLY);
if (fd < 0) {
fprintf(stderr,"cannot open %s: %s\n", *filename,
strerror(errno));
return 1;
}
/*This gets the attributes, and puts them into flags*/
if (ioctl(fd, EXT2_IOC_GETFLAGS, &flags)){
fprintf(stderr,"ioctl failed on %s: %s\n", *filename,
strerror(errno));
return 1;
}
printf("%s:", *filename++);
/*Check for each attribute, and display a message for each one wich is returned
on*/
if (flags & EXT2_APPEND_FL) printf("Append");
if (flags & EXT2_IMMUTABLE_FL) printf("Immutable");
if (flags & EXT2_SYNC_FL) printf("Sync");
if (flags & EXT2_NODUMP_FL) printf("No dump");
printf("\n");
close(fd);
}
return 0;
}
The problem is simple, the program does nothing...