#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>

main(argc,argv)              /* Filestatus anzeigen */
int argc; char **argv;
{
  struct stat buf;

  if(stat(argv[1],&buf) == -1) { perror("stat"); exit(1);}
  printf("Filename: %s  \nUID: %ld\n",argv[1],buf.st_uid);
  printf("GID: %ld\n",buf.st_gid);
  if(buf.st_mode & S_IFDIR) printf("is dir\n"); /* klappt nur, wenn S_IFDIR genau 1 Bit belegt */
  if((buf.st_mode & S_IWUSR)==S_IWUSR) printf("owner write\n"); /* besser */
  if((buf.st_mode & S_IRGRP)==S_IRGRP) printf("group read\n");
  if((buf.st_mode & S_IXOTH)==S_IXOTH) printf("other execute\n");
}
