SIONlib  1.7.7
Scalable I/O library for parallel access to task-local files
sion_file.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2019 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** Copyright (c) 2019 **
8 ** DataDirect Networks **
9 ** **
10 ** See the file COPYRIGHT in the package base directory for details **
11 ****************************************************************************/
12 
17 #ifndef SION_SION_FILE_H
18 #define SION_SION_FILE_H
19 
20 #include <stdio.h>
21 
22 #include "sion_const.h"
23 #include "sion_datatypes.h"
24 
25 #define SION_FILE_FLAG_ANSI 1
26 #define SION_FILE_FLAG_SCNDANSI 2
27 #define SION_FILE_FLAG_POSIX 4
28 #define SION_FILE_FLAG_CREATE 8
29 #define SION_FILE_FLAG_WRITE 16
30 #define SION_FILE_FLAG_READ 32
31 #if defined(_SION_SIONFWD)
32 #define SION_FILE_FLAG_SIONFWD 64
33 #endif
34 
35 #ifdef _SION_IME_NATIVE
36 #define SION_FILE_FLAG_IME_NATIVE 128
37 #endif
38 
40  unsigned int flags;
41  FILE *fileptr;
42  FILE *second_fileptr;
43  int fd;
44 #if defined(_SION_SIONFWD)
45  sion_int64 position;
46 #endif
47 };
48 typedef struct _sion_fileptr_s _sion_fileptr;
49 
50 /* open/close */
51 _sion_fileptr *_sion_file_open(const char *fname, unsigned int flags, unsigned int addflags);
52 int _sion_file_close( _sion_fileptr *sion_fileptr );
53 
54 /* write/read */
55 sion_int64 _sion_file_write(const void *data, sion_int64 bytes, _sion_fileptr *sion_fileptr );
56 sion_int64 _sion_file_read(void *data, sion_int64 bytes, _sion_fileptr *sion_fileptr );
57 
58 /* utility */
59 int _sion_file_set_second_fileptr( _sion_fileptr *sion_fileptr, FILE* fileptr);
62 int _sion_file_stat_file(const char *fname);
63 int _sion_file_stat_file2(const char *fname, unsigned int apiflag);
64 
65 sion_int64 _sion_file_set_position(_sion_fileptr *fileptr, sion_int64 startpointer);
66 sion_int64 _sion_file_get_position(_sion_fileptr *fileptr);
67 
68 int _sion_file_flush(_sion_fileptr *fileptr);
69 int _sion_file_purge(_sion_fileptr *fileptr);
70 
71 int _sion_file_set_buffer(_sion_fileptr *fileptr, char *buffer, sion_int32 buffer_size);
72 int _sion_file_get_fd( _sion_fileptr *sion_fileptr);
73 
74 
75 /* ********************************************************************************************** */
76 /* *** Internal INTERFACE Functions (ANSI, POSIX) */
77 /* ********************************************************************************************** */
78 FILE *_sion_file_open_ansi_write_create(const char *fname, unsigned int addflags);
79 FILE *_sion_file_open_ansi_write_existing(const char *fname, unsigned int addflags);
80 FILE *_sion_file_open_ansi_read(const char *fname, unsigned int addflags);
81 int _sion_file_close_ansi(FILE *fileptr);
82 long _sion_file_get_opt_blksize_ansi( FILE *fileptr);
83 sion_int64 _sion_file_set_position_ansi(FILE *fileptr, sion_int64 startpointer);
84 sion_int64 _sion_file_get_position_ansi(FILE *fileptr);
85 int _sion_file_flush_ansi(FILE *fileptr);
86 int _sion_file_purge_ansi(FILE *fileptr);
87 int _sion_file_set_buffer_ansi(FILE *fileptr, char *buffer, sion_int32 buffer_size);
88 sion_int64 _sion_file_write_ansi(const void *data, sion_int64 bytes, FILE *fileptr );
89 sion_int64 _sion_file_read_ansi(void *data, sion_int64 bytes, FILE *fileptr );
90 
91 int _sion_file_open_posix_write_create(const char *fname, unsigned int addflags);
92 int _sion_file_open_posix_write_existing(const char *fname, unsigned int addflags);
93 int _sion_file_open_posix_read(const char *fname, unsigned int addflags);
94 int _sion_file_close_posix(int fd);
96 sion_int64 _sion_file_set_position_posix(int fd, sion_int64 startpointer);
97 sion_int64 _sion_file_get_position_posix(int fd);
98 int _sion_file_flush_posix(int fd);
99 int _sion_file_purge_posix(int fd);
100 int _sion_file_set_buffer_posix(int fd, char *buffer, sion_int32 buffer_size);
101 sion_int64 _sion_file_write_posix(const void *data, sion_int64 bytes, int fd );
102 sion_int64 _sion_file_read_posix(void *data, sion_int64 bytes, int fd );
103 
104 #if defined(_SION_SIONFWD)
105 int _sion_file_open_sionfwd_write_create(const char *fname, unsigned int addflags);
106 int _sion_file_open_sionfwd_write_existing(const char *fname, unsigned int addflags);
107 int _sion_file_open_sionfwd_read(const char *fname, unsigned int addflags);
108 int _sion_file_close_sionfwd(int fd);
109 long _sion_file_get_opt_blksize_sionfwd(int fd);
110 int _sion_file_flush_sionfwd(int fd);
111 int _sion_file_purge_sionfwd(int fd);
112 int _sion_file_set_buffer_sionfwd(int fd, char *buffer, sion_int32 buffer_size);
113 sion_int64 _sion_file_write_sionfwd(const void *data, sion_int64 bytes, int fd, sion_int64 *position);
114 sion_int64 _sion_file_read_sionfwd(void *data, sion_int64 bytes, int fd, sion_int64 *position);
115 #endif
116 
117 /* IME native API calls */
118 
119 #ifdef _SION_IME_NATIVE
120 int _sion_file_open_ime_native_write_create(const char *fname, unsigned int addflags);
121 int _sion_file_open_ime_native_write_existing(const char *fname, unsigned int addflags);
122 int _sion_file_open_ime_native_read(const char *fname, unsigned int addflags);
123 int _sion_file_close_ime_native(int fd);
124 long _sion_file_get_opt_blksize_ime_native(int fd);
125 sion_int64 _sion_file_set_position_ime_native(int fd, sion_int64 startpointer);
126 sion_int64 _sion_file_get_position_ime_native(int fd);
127 int _sion_file_flush_ime_native(int fd);
128 int _sion_file_set_buffer_ime_native(int fd, char *buffer, sion_int32 buffer_size);
129 sion_int64 _sion_file_write_ime_native(const void *data, sion_int64 bytes, int fd);
130 sion_int64 _sion_file_read_ime_native(void *data, sion_int64 bytes, int fd);
131 #endif
132 
133 /* ********************************************************************************************** */
134 /* *** Internal Utility Functions */
135 /* ********************************************************************************************** */
137 char* _sion_get_fileptr_desc(_sion_fileptr *sion_fileptr);
138 
139 
140 #endif
int _sion_file_stat_file2(const char *fname, unsigned int apiflag)
Check if file exists with appropriate low-level API.
Definition: sion_file.c:329
int _sion_file_unset_second_fileptr(_sion_fileptr *sion_fileptr)
Unset second fileptr for file if opened with ANSI.
Definition: sion_file.c:551
long _sion_file_get_opt_blksize(_sion_fileptr *fileptr)
Get optional file system block size for a file.
Definition: sion_file.c:289
sion_int64 _sion_file_read_posix(void *data, sion_int64 bytes, int fd)
POSIX: Read data from file.
Definition: sion_file.c:1145
int _sion_file_close(_sion_fileptr *sion_fileptr)
Close file and destroys fileptr structure.
Definition: sion_file.c:178
long _sion_file_get_opt_blksize_posix(int fd)
POSIX: Get optional file system block size for a file.
Definition: sion_file.c:965
int _sion_file_close_posix(int fd)
POSIX: Close a file.
Definition: sion_file.c:950
int _sion_file_flush(_sion_fileptr *fileptr)
Flush data to file.
Definition: sion_file.c:434
int _sion_file_open_posix_write_existing(const char *fname, unsigned int addflags)
POSIX: Open a new file for writing.
Definition: sion_file.c:899
sion_int64 _sion_file_get_position_posix(int fd)
POSIX: Get the current position in file.
Definition: sion_file.c:1025
int _sion_file_set_buffer_posix(int fd, char *buffer, sion_int32 buffer_size)
POSIX: set buffer of fd.
Definition: sion_file.c:1099
sion_int64 _sion_file_get_position(_sion_fileptr *fileptr)
Get new position in file.
Definition: sion_file.c:401
int _sion_file_get_fd(_sion_fileptr *sion_fileptr)
Utility function: Get POSIX fp.
Definition: sion_file.c:573
char * _sion_get_fileptr_desc(_sion_fileptr *sion_fileptr)
Definition: sion_file.c:1568
int _sion_file_open_posix_write_create(const char *fname, unsigned int addflags)
POSIX: Create and open a new file for writing.
Definition: sion_file.c:873
FILE * _sion_file_open_ansi_read(const char *fname, unsigned int addflags)
ANSI: Open a file for reading.
Definition: sion_file.c:653
sion_int64 _sion_file_write(const void *data, sion_int64 bytes, _sion_fileptr *sion_fileptr)
Write data to file.
Definition: sion_file.c:221
sion_int64 _sion_file_get_position_ansi(FILE *fileptr)
ANSI: Get the current position in file.
Definition: sion_file.c:762
_sion_fileptr * _sion_file_alloc_and_init_sion_fileptr(void)
Create and return _sion_fileptr.
Definition: sion_file.c:1526
sion_int64 _sion_file_set_position(_sion_fileptr *fileptr, sion_int64 startpointer)
Set new position in file.
Definition: sion_file.c:367
_sion_fileptr * _sion_file_open(const char *fname, unsigned int flags, unsigned int addflags)
Create and open a new file for writing.
Definition: sion_file.c:53
int _sion_file_close_ansi(FILE *fileptr)
ANSI: Close a file.
Definition: sion_file.c:671
int _sion_file_set_buffer_ansi(FILE *fileptr, char *buffer, sion_int32 buffer_size)
ANSI: set buffer of fp.
Definition: sion_file.c:827
sion_int64 _sion_file_read(void *data, sion_int64 bytes, _sion_fileptr *sion_fileptr)
Read data from file.
Definition: sion_file.c:257
int _sion_file_stat_file(const char *fname)
Check if file exists (LARGE_FILE support on BlueGene)
Definition: sion_file.c:318
sion_int64 _sion_file_write_posix(const void *data, sion_int64 bytes, int fd)
POSIX: Write data to file.
Definition: sion_file.c:1112
int _sion_file_set_buffer(_sion_fileptr *fileptr, char *buffer, sion_int32 buffer_size)
Set buffer of fp.
Definition: sion_file.c:495
int _sion_file_open_posix_read(const char *fname, unsigned int addflags)
POSIX: Open a file for reading.
Definition: sion_file.c:925
sion_int64 _sion_file_set_position_posix(int fd, sion_int64 startpointer)
POSIX: Set the start position for the current task.
Definition: sion_file.c:986
sion_int64 _sion_file_read_ansi(void *data, sion_int64 bytes, FILE *fileptr)
ANSI: Read data from file.
Definition: sion_file.c:854
FILE * _sion_file_open_ansi_write_existing(const char *fname, unsigned int addflags)
ANSI: Open a new file for writing.
Definition: sion_file.c:630
int _sion_file_flush_ansi(FILE *fileptr)
ANSI: Flush the data to the disk.
Definition: sion_file.c:805
int _sion_file_purge_ansi(FILE *fileptr)
ANSI: Purge the data to the disk.
Definition: sion_file.c:815
int _sion_file_purge_posix(int fd)
POSIX: Purge the data to the disk.
Definition: sion_file.c:1076
int _sion_file_purge(_sion_fileptr *fileptr)
Purge data to file.
Definition: sion_file.c:467
long _sion_file_get_opt_blksize_ansi(FILE *fileptr)
ANSI: Get optional file system block size for a file.
Definition: sion_file.c:686
sion_int64 _sion_file_set_position_ansi(FILE *fileptr, sion_int64 startpointer)
ANSI: Set the start position for the current task.
Definition: sion_file.c:708
int _sion_file_flush_posix(int fd)
POSIX: Flush the data to the disk.
Definition: sion_file.c:1053
sion_int64 _sion_file_write_ansi(const void *data, sion_int64 bytes, FILE *fileptr)
ANSI: Write data to file.
Definition: sion_file.c:840
FILE * _sion_file_open_ansi_write_create(const char *fname, unsigned int addflags)
ANSI: Create and open a new file for writing.
Definition: sion_file.c:611
int _sion_file_set_second_fileptr(_sion_fileptr *sion_fileptr, FILE *fileptr)
Set second fileptr for file if opened with ANSI.
Definition: sion_file.c:529