00001
00006 #include <fcntl.h>
00007 #include <stdio.h>
00008 #include <stdlib.h>
00009 #include <errno.h>
00010 #include <gfal_api.h>
00011 #define BLKLEN 65536
00012
00013 main(int argc, char **argv)
00014 {
00015 int fd;
00016 char ibuf[BLKLEN];
00017 int rc;
00018
00019 if (argc != 2) {
00020 fprintf (stderr, "usage: %s filename\n", argv[0]);
00021 exit (1);
00022 }
00023
00024 printf ("opening %s\n", argv[1]);
00025 if ((fd = gfal_open (argv[1], O_RDONLY, 0)) < 0) {
00026 gfal_posix_check_error();
00027 exit (1);
00028 }
00029 printf ("open successful, fd = %d (errno = %d)\n", fd, errno);
00030
00031 if ((rc = gfal_read (fd, ibuf, BLKLEN)) < 0) {
00032 gfal_posix_check_error();
00033 (void) gfal_close (fd);
00034 exit (1);
00035 }
00036 printf ("read successful (errno = %d)\n", errno);
00037
00038 if ((gfal_close (fd)) < 0) {
00039 gfal_posix_check_error();
00040 exit (1);
00041 }
00042 printf ("close successful\n");
00043 exit (0);
00044 }