00001
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007 #include <unistd.h>
00008 #include <errno.h>
00009 #include "gfal_api.h"
00010
00011 main(int argc, char **argv)
00012 {
00013 int mode, error = 0;
00014 char *file;
00015
00016 if (argc != 3) {
00017 fprintf (stderr, "usage: %s file mode\n", argv[0]);
00018 exit (1);
00019 }
00020
00021 file = argv[1];
00022 mode = strtol (argv[2], NULL, 8);
00023 if (errno > 0) {
00024 perror ("strtol");
00025 exit (1);
00026 }
00027
00028 printf ("Checking RW access to '%s'...\n",file);
00029 if (gfal_access (file, R_OK|W_OK) < 0) {
00030 error = 1;
00031 gfal_posix_check_error();
00032 }
00033
00034 printf ("Changing mode of '%s' to %o...\n", file, mode);
00035 if (gfal_chmod (file, mode) < 0) {
00036 error = 1;
00037 gfal_posix_check_error();
00038 }
00039
00040 if (error) exit (1);
00041
00042 printf ("All is ok.\n");
00043 exit (0);
00044 }