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

int main (int argc, char * argv[]) {
  int fd;
  struct stat info;
  if (argc!=2) {
      printf ("Usage testChmod pathname\n");
      return (-1); }
  fd = access(argv[1], F_OK); 
  if(fd == -1){ 
     printf("Error Number : %d\n", errno); 
     perror("Error Description"); 
     return (-2); } 
  else {
    stat(argv[1], &info);
    printf("Original file permissions were: %08o\n", 
           info.st_mode);
    if (chmod(argv[1], S_IRWXU|S_IRWXG) != 0)
      perror("chmod() error");
    else {
      stat(argv[1], &info);
      printf("After chmod(), file permissions are: %08o\n", 
             info.st_mode); }}
   return (0); }
 
 
 
    



