gfal_testchmod.c

This example show how to change the right on a file/directory ex : use case with SRM plugin : ./gfal_testdir srm://grid05.lal.in2p3.fr:8446/dpm/lal.in2p3.fr/home/dteam/test_obiwankenobi

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include "gfal_api.h"

int main(int argc, char **argv)
{
        int mode, error = 0;
        char *file;

        if (argc != 3) {
                fprintf (stderr, "usage: %s file mode\n", argv[0]);
                exit (1);
        }

        file = argv[1];
        mode = strtol (argv[2], NULL, 8);
        if (errno > 0) {
                perror ("strtol");
                exit (1);
        }

        printf ("Checking RW access to '%s'...\n",file);
        if (gfal_access (file, R_OK|W_OK) < 0) {
                error = 1;
                gfal_posix_check_error();
        }

        printf ("Changing mode of '%s' to %o...\n", file, mode);
        if (gfal_chmod (file, mode) < 0) {
                error = 1;
                gfal_posix_check_error();
        }

        if (error) exit (1);

        printf ("All is ok.\n");
        exit (0);
}

Generated on 28 Nov 2013 for GFAL2 by  doxygen 1.6.1