14 #define _XOPEN_SOURCE 700
23 #include <sys/types.h>
30 #if defined(_SION_BGQ)
31 #include <stdio_ext.h>
34 #if defined(_SION_BGP)
35 #include <stdio_ext.h>
40 #include "sion_error_handler.h"
47 #include "sion_hints.h"
56 int _sion_open(
const char *fname,
const char *file_mode,
int *ntasks,
int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize,
int **globalranks, FILE **fileptr)
59 int sid=SION_ID_UNDEF;
62 DPRINTFP((1,
"_sion_open", 0,
"enter open of file %s in %s mode\n", fname, file_mode));
65 if ( ! flags_store ) {
66 return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,
"_sion_open: could not parse file mode in %s, aborting ...\n", file_mode));
69 if (flags_store->mask&_SION_FMODE_WRITE) {
72 sid=
_sion_open_write(fname,flags_store->mask,ntasks,nfiles,chunksizes,fsblksize,globalranks,fileptr);
76 sid=
_sion_open_read(fname,flags_store->mask,_SION_READ_ALL_OF_MULTI_FILES,ntasks,nfiles,chunksizes,fsblksize,globalranks,fileptr);
80 _sion_flags_destroy_store(&flags_store);
82 DPRINTFP((1,
"_sion_open", 0,
"leave open of file %s in %s mode sid=%d\n", fname, file_mode,sid));
103 int _sion_open_write(
const char *fname, sion_int64 file_mode_flags,
int *ntasks,
int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize,
int **globalranks, FILE **fileptr)
108 sion_int64 new_fsblocksize, apiflag;
109 sion_int32 endianness = 0;
114 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: wrong number of tasks specific: ntasks=%d (<0), returning ...\n", *ntasks));
118 if ((chunksizes==NULL) || (*chunksizes==NULL)) {
119 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: chunksizes seems not to be a pointer to an array, returning ...\n"));
123 if ((globalranks==NULL) || (*globalranks==NULL)) {
124 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: globalranks seems not to be a pointer to an array, returning ...\n"));
129 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: write with nfiles > 1 currently not supported (nfiles=%d), returning ...\n",(
int) *nfiles));
134 if (sion_filedesc == NULL) {
135 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: cannot allocate filedescriptor structure of size %lu (sion_filedesc), aborting ...\n", (
unsigned long)
sizeof(sion_filedesc)));
138 sion_filedesc->
fname = strdup(fname);
142 sion_filedesc->
sid=sid;
150 DPRINTFP((1,
"sion_open", 0,
" it is a write operation #tasks=%d\n", *ntasks));
157 sion_filedesc->
ntasks = *ntasks;
158 sion_filedesc->
nfiles = 1;
160 sion_filedesc->
prefix = strdup(fname);
172 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: cannot open %s for reading, aborting ...\n", fname));
174 sion_filedesc->
fileptr = sion_fileptr;
179 if((new_fsblocksize<0) || (new_fsblocksize>SION_MAX_FSBLOCKSIZE)) new_fsblocksize=SION_DEFAULT_FSBLOCKSIZE;
180 *fsblksize = new_fsblocksize;
182 DPRINTFP((32,
"_sion_paropen_multi_generic", 0,
"setting fsblksize to %lld\n", new_fsblocksize));
186 for (i = 0; i < *ntasks; i++) {
192 _sion_keyval_check_env(sion_filedesc, file_mode_flags);
194 _sion_alloc_filedesc_all_keyvalptr(sion_filedesc);
197 _sion_calculate_startpointers(sion_filedesc);
208 for (i = 0; i < *ntasks; i++) {
216 sion_filedesc->
rank = 0;
227 *fileptr=sion_filedesc->
fileptr->fileptr;
258 int _sion_open_read(
const char *fname, sion_int64 file_mode_flags,
int read_all,
int *ntasks,
int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize,
int **globalranks, FILE **fileptr)
268 if (sion_filedesc == NULL) {
269 return(_sion_errorprint(SION_ID_UNDEF,SION_ID_UNDEF,
"sion_open: cannot allocate filedescriptor structure of size %lu (sion_filedesc), aborting ...\n", (
unsigned long)
sizeof(sion_filedesc)));
272 sion_filedesc->
fname = strdup(fname);
276 sion_filedesc->
sid=sid;
282 DPRINTFP((1,
"sion_open", 0,
" it is a read operation\n"));
287 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: cannot open %s for reading, aborting ...\n", fname));
289 sion_filedesc->
fileptr = sion_fileptr;
293 if (rc!=SION_SUCCESS) {
294 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: cannot read header from file %s, aborting ...\n", fname));
296 sion_filedesc->
rank = 0;
305 if (rc!=SION_SUCCESS) {
306 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: cannot read header (var part) from file %s, aborting ...\n", fname));
310 _sion_calculate_startpointers(sion_filedesc);
315 if (rc!=SION_SUCCESS) {
316 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: cannot read header (var part block sizes) from file %s, aborting ...\n", fname));
320 _sion_keyval_check_env(sion_filedesc, file_mode_flags);
322 _sion_alloc_filedesc_all_keyvalptr(sion_filedesc);
328 if(read_all==_SION_READ_ALL_OF_MULTI_FILES) {
329 sid=_sion_open_read_master(fname,file_mode_flags,ntasks,nfiles,chunksizes,fsblksize,globalranks,fileptr,sion_filedesc);
331 sid=_sion_open_read_single(fname,file_mode_flags,ntasks,nfiles,chunksizes,fsblksize,globalranks,fileptr,sion_filedesc);
335 for (rank = 0; rank < sion_filedesc->
mapping_size; rank++) {
336 DPRINTFP((2048,
"sion_open", 0,
" mapping[%d] = %d , %d \n", rank,sion_filedesc->
mapping[rank*2+0],sion_filedesc->
mapping[rank*2+1]));
343 sid=_sion_open_read_single(fname,file_mode_flags,ntasks,nfiles,chunksizes,fsblksize,globalranks,fileptr,sion_filedesc);
351 int _sion_open_read_single(
const char *fname, sion_int64 file_mode_flags,
int *ntasks,
int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize,
int **globalranks, FILE **fileptr,
_sion_filedesc *sion_filedesc)
357 sid=sion_filedesc->
sid;
363 for (blknum = 0; blknum <= sion_filedesc->
lastchunknr; blknum++) {
370 for (i = 0; i < sion_filedesc->
ntasks; i++) {
377 *ntasks = sion_filedesc->
ntasks;
378 *nfiles = sion_filedesc->
nfiles;
381 if (chunksizes != NULL) {
382 sion_int64 *helpptr = NULL;
383 if ((*chunksizes) == NULL) {
384 helpptr = (sion_int64 *) malloc(*ntasks *
sizeof(sion_int64));
385 if (helpptr == NULL) {
386 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"cannot allocate filedescriptor structure of size %lu (chunksizes), aborting ...\n", (
unsigned long)
sizeof(sion_int64)));
388 *chunksizes = helpptr;
390 helpptr = *chunksizes;
392 for (i = 0; i < *ntasks; i++) {
396 if (globalranks != NULL) {
398 if ((*globalranks) == NULL) {
399 helpptr = (
int *) malloc(*ntasks *
sizeof(
int));
400 if (helpptr == NULL) {
401 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: cannot allocate memory of size %lu (globalranks), aborting ...\n", (
unsigned long) (*ntasks) *
sizeof(int)));
403 *globalranks = helpptr;
405 helpptr = *globalranks;
407 for (i = 0; i < (*ntasks); i++) {
414 *fileptr=sion_filedesc->
fileptr->fileptr;
428 int _sion_open_read_master(
const char *fname, sion_int64 file_mode_flags,
int *ntasks,
int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize,
int **globalranks, FILE **fileptr,
_sion_filedesc *sion_filedesc)
432 int sid_master, subsid, lfile, lrank, filenr;
441 for (blknum = 0; blknum <= sion_filedesc->
lastchunknr; blknum++) {
448 for (i = 0; i < sion_filedesc->
ntasks; i++) {
456 for (rank = 0; rank < sion_filedesc->
mapping_size; rank++) {
457 DPRINTFP((32,
"sion_open", 0,
" mapping[%d] = %d , %d \n", rank,sion_filedesc->
mapping[rank*2+0],sion_filedesc->
mapping[rank*2+1]));
463 if (sion_filedesc_master == NULL) {
464 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: cannot allocate filedescriptor structure of size %lu (sion_filedesc_master), aborting ...\n",
465 (
unsigned long)
sizeof(sion_filedesc_master)));
468 sion_filedesc_master->
fname = strdup(fname);
474 sion_filedesc_master->
sid=sid_master;
478 if (sion_filedesc_master->
multifiles == NULL) {
479 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"cannot allocate filedescriptor structure vector of size %lu (sion_filedesc), aborting ...\n",
485 sion_filedesc_master->
multifiles[0]=sion_filedesc;
487 for(filenr=1;filenr<sion_filedesc->
nfiles;filenr++) {
488 int sub_ntasts, sub_nfiles;
489 sion_int32 sub_chunksize;
493 DPRINTFP((32,
"sion_open", 0,
"open now sub file = %d %s\n", filenr, multi_fname));
495 file_mode_flags, _SION_READ_ALL_OF_MULTI_FILES, &sub_ntasts, &sub_nfiles, NULL, &sub_chunksize, NULL, &sub_fileptr);
496 sion_filedesc_sub=_sion_get_filedesc(subsid);
497 sion_filedesc_master->
multifiles[filenr]=sion_filedesc_sub;
498 DPRINTFP((32,
"sion_open", 0,
"sub file = %d %s opened\n", filenr, multi_fname));
507 sion_filedesc_master->
rank = 0;
510 lfile=sion_filedesc_master->
mapping[sion_filedesc_master->
rank*2+0];
511 lrank=sion_filedesc_master->
mapping[sion_filedesc_master->
rank*2+1];
512 sion_filedesc_sub=sion_filedesc_master->
multifiles[lfile];
522 sion_filedesc_master->
nfiles = sion_filedesc_sub->
nfiles;
523 sion_filedesc_master->
flag1 = sion_filedesc_sub->
flag1;
524 sion_filedesc_master->
flag2 = sion_filedesc_sub->
flag2;
526 sion_filedesc_master->
prefix = strdup(sion_filedesc->
prefix);
541 for(filenr=1;filenr<sion_filedesc->
nfiles;filenr++)
546 for (blknum = 0; blknum < sion_filedesc_sub->
all_blockcount[lrank]; blknum++) {
554 sion_filedesc = sion_filedesc_master;
562 *ntasks = sion_filedesc->
ntasks;
563 *nfiles = sion_filedesc->
nfiles;
565 if (chunksizes != NULL) {
566 sion_int64 *helpptr = NULL;
567 if ((*chunksizes) == NULL) {
568 helpptr = (sion_int64 *) malloc(*ntasks *
sizeof(sion_int64));
569 if (helpptr == NULL) {
570 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"cannot allocate filedescriptor structure of size %lu (chunksizes), aborting ...\n", (
unsigned long)
sizeof(sion_int64)));
572 *chunksizes = helpptr;
574 helpptr = *chunksizes;
576 for (i = 0; i < *ntasks; i++) {
577 lfile=sion_filedesc_master->
mapping[i*2+0]; lrank=sion_filedesc_master->
mapping[i*2+1];
581 if (globalranks != NULL) {
583 if ((*globalranks) == NULL) {
584 helpptr = (
int *) malloc(*ntasks *
sizeof(
int));
585 if (helpptr == NULL) {
586 return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,
"sion_open: cannot allocate memory of size %lu (globalranks), aborting ...\n", (
unsigned long) (*ntasks) *
sizeof(int)));
588 *globalranks = helpptr;
591 helpptr = *globalranks;
593 for (i = 0; i < (*ntasks); i++) {
594 lfile=sion_filedesc_master->
mapping[i*2+0]; lrank=sion_filedesc_master->
mapping[i*2+1];
601 *fileptr=sion_filedesc->
fileptr->fileptr;
614 int _sion_open_rank(
const char *fname,
const char *file_mode, sion_int64 *chunksize, sion_int32 *fsblksize,
int *rank, FILE **fileptr)
617 int rc=SION_NOT_SUCCESS, sid=SION_ID_UNDEF;
618 int mapping_filenr, mapping_lrank;
625 DPRINTFTS(*rank,
"before open rank");
626 DPRINTFP((1,
"_sion_open_rank", *rank,
"enter open of file %s in %s mode\n", fname, file_mode));
630 if (sion_filedesc == NULL) {
631 return(_sion_errorprint_on_rank(SION_ID_UNDEF,_SION_ERROR_RETURN,*rank,
"_sion_open_rank: cannot allocate filedescriptor structure of size %lu (sion_filedesc), aborting ...", (
unsigned long)
sizeof(sion_filedesc)));
634 sion_filedesc->
fname = strdup(fname);
638 sion_filedesc->
sid=sid;
641 if ( ! flags_store ) {
642 return(_sion_errorprint_on_rank(SION_ID_UNDEF,_SION_ERROR_RETURN,*rank,
"sion_paropen_mpi: could not parse file mode in %s, aborting ...", file_mode));
649 if (flags_store->mask&_SION_FMODE_WRITE) {
652 DPRINTFP((1,
"_sion_open_rank", *rank,
" it is a write operation\n"));
654 _sion_flags_destroy_store(&flags_store);
655 return(_sion_errorprint_on_rank(SION_ID_UNDEF,_SION_ERROR_RETURN,*rank,
"_sion_open_rank: %s for writing currently not supported, aborting ...", fname));
658 _sion_flags_destroy_store(&flags_store);
661 DPRINTFTS(*rank,
"start open read");
662 DPRINTFP((1,
"_sion_open_rank", *rank,
" it is a read operation rank=%d\n",*rank));
667 return(_sion_errorprint_on_rank(SION_ID_UNDEF,_SION_ERROR_RETURN,*rank,
"_sion_open_rank: cannot open %s for reading, aborting ...", fname));
669 sion_filedesc->
fileptr = sion_fileptr;
670 DPRINTFTS(*rank,
"start after open file 1");
672 DPRINTFTS(*rank,
"start after read header fix part 1");
673 if (rc==SION_NOT_SUCCESS) {
674 return(_sion_errorprint_on_rank(SION_ID_UNDEF,_SION_ERROR_RETURN,*rank,
"_sion_open_rank: cannot read header from file %s, aborting ...", fname));
676 sion_filedesc->
rank = *rank;
685 DPRINTFTS(*rank,
"start after read header var part 1");
686 if (rc==SION_NOT_SUCCESS) {
687 return(_sion_errorprint_on_rank(SION_ID_UNDEF,_SION_ERROR_RETURN,*rank,
"_sion_open_rank: cannot read var part header from file %s, aborting ...", fname));
690 DPRINTFP((1,
"_sion_open_rank", *rank,
"found number of files %d in %s rank=%d\n", sion_filedesc->
nfiles,sion_filedesc->
fname,*rank));
691 if(sion_filedesc->
nfiles>1) {
694 DPRINTFTS(*rank,
"start after read mapping rank 1");
695 if (rc==SION_NOT_SUCCESS) {
696 return(_sion_errorprint_on_rank(SION_ID_UNDEF,_SION_ERROR_RETURN,*rank,
"cannot read var part mapping header from file %s, aborting ...", fname));
698 mapping_filenr = sion_filedesc->
mapping[0];
699 mapping_lrank = sion_filedesc->
mapping[1];
700 DPRINTFP((1,
"_sion_open_rank", *rank,
"data for rank %d is in file %d (lrank=%d)\n", *rank, mapping_filenr,mapping_lrank));
701 DPRINTFTS(*rank,
"start after read mapping 1");
704 if(mapping_filenr>0) {
710 DPRINTFTS(*rank,
"start after close file 1");
715 DPRINTFP((1,
"_sion_open_rank", *rank,
"open file sion_filedesc->fname=%s fname=%s rank=%d\n", sion_filedesc->
fname,fname,*rank));
719 return(_sion_errorprint_on_rank(SION_ID_UNDEF,_SION_ERROR_RETURN,*rank,
"_sion_open_rank: cannot open %s for reading, aborting ...", fname));
721 sion_filedesc->
fileptr = sion_fileptr;
722 DPRINTFTS(*rank,
"start after open file i");
725 if (rc==SION_NOT_SUCCESS) {
726 return(_sion_errorprint_on_rank(SION_ID_UNDEF,_SION_ERROR_RETURN,*rank,
"sion_open: cannot read header from file %s, aborting ...", fname));
728 DPRINTFTS(*rank,
"start after read header fix part i");
731 if (rc==SION_NOT_SUCCESS) {
732 return(_sion_errorprint_on_rank(SION_ID_UNDEF,_SION_ERROR_RETURN,*rank,
"cannot var mapping data from file %s, aborting ...", fname));
734 DPRINTFTS(*rank,
"start after read header var part i");
737 sion_filedesc->
fname = strdup(fname);
743 DPRINTFP((1,
"_sion_open_rank", *rank,
"max blocks=%d\n", sion_filedesc->
maxusedchunks));
746 sion_filedesc->
prefix = strdup(&prefix);
748 _sion_calculate_startpointers(sion_filedesc);
750 sion_filedesc->
rank = mapping_lrank;
753 if (rc==SION_NOT_SUCCESS) {
754 return(_sion_errorprint_on_rank(SION_ID_UNDEF,_SION_ERROR_RETURN,sion_filedesc->
rank,
"cannot read header from file %s, aborting ...", fname));
756 DPRINTFTS(*rank,
"start after read header blocksizes i");
774 *fileptr=sion_filedesc->
fileptr->fileptr;
784 DPRINTFP((1,
"_sion_open_rank", 0,
"leave open of file %s in %s mode\n", fname, file_mode));
785 DPRINTFTS(*rank,
"after open rank");
795 int rc = SION_SUCCESS;
796 int blknum, rank, currentrank, mapping_size;
797 #ifdef SION_SERIAL_MASTER
803 DPRINTFP((1,
"_sion_close", -1,
"enter close sid=%d currentpos=%15lld\n", sion_filedesc->
sid, sion_filedesc->
currentpos));
811 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
"_sion_close: invalid file open state (!SEROPEN), aborting %d ...", sion_filedesc->
sid));
817 DPRINTFP((1,
"_sion_close", -1,
" file was opened in write mode sid=%d setpos to %lld\n", sion_filedesc->
sid, sion_filedesc->
end_of_header));
821 DPRINTFP((1,
"_sion_close", -1,
" after flush block sid=%d fileptr is at position %14lld\n", sion_filedesc->
sid,
_sion_file_get_position(sion_filedesc->
fileptr)));
828 currentrank = sion_filedesc->
rank;
832 for (blknum = 0; blknum <= sion_filedesc->
lastchunknr; blknum++) {
838 for (blknum = 0; blknum < sion_filedesc->
ntasks; blknum++)
849 for (blknum = 0; blknum < sion_filedesc->
maxusedchunks; blknum++) {
850 for (rank = 0; rank < sion_filedesc->
ntasks; rank++) {
854 DPRINTFP((1,
"_sion_close", -1,
855 " blocksize rank %2d blk %2d -> %lld\n",
877 #ifdef SION_SERIAL_MASTER
881 for(filenr=1;filenr<sion_filedesc->
nfiles;filenr++) {
882 _sion_close(sion_filedesc->
multifiles[filenr]);
884 _sion_free_filedesc(sion_filedesc->
multifiles[filenr]);
894 #ifdef SION_SERIAL_MASTER
899 DPRINTFP((1,
"_sion_close", -1,
"leave close sid=%d\n", sion_filedesc->
sid));
915 newfname = malloc(SION_FILENAME_LENGTH);
916 if (newfname == NULL) {
917 _sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,
"_sion_get_multi_filename: Cannot allocate string newfname\n");
921 if(strlen(fname)<SION_FILENAME_LENGTH-7) {
922 sprintf(newfname,
"%s.%06d", fname, filenumber);
924 _sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,
"_sion_get_multi_filename: filename too long\n");
929 strcpy(newfname, fname);
944 int rc = SION_SUCCESS;
948 return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,
"_sion_flush_file: invalid sion_filedesc, aborting %d ...\n", sid));
950 DPRINTFP((32,
"_sion_flush_file", sion_filedesc->
rank,
"flush sid=%d\n", sid));
968 int rc = SION_SUCCESS;
970 DPRINTFP((2,
"_sion_update_fileposition", sion_filedesc->
rank,
"enter\n"));
988 DPRINTFP((2,
"_sion_update_fileposition", sion_filedesc->
rank,
"leave pos=%lld usecoll=%d collector=%d rank\n",
1000 int rc = SION_SUCCESS;
1034 int rc = SION_SUCCESS;
1035 sion_int64 byteswritten;
1037 DPRINTFP((2,
"_sion_flush_block", sion_filedesc->
rank,
"enter fileposition=%lld\n", sion_filedesc->
currentpos));
1041 DPRINTFP((2,
"_sion_flush_block", sion_filedesc->
rank,
"after update fileposition=%lld\n", sion_filedesc->
currentpos));
1047 if (byteswritten > 0) {
1050 DPRINTFP((2,
"_sion_flush_block", sion_filedesc->
rank,
1051 "flushed lastchunknr->%d currentblocknr=%d byteswritten=%lld fileposition=%lld startpos=%lld (%lld)\n",
1055 rc = SION_NOT_SUCCESS;
1056 DPRINTFP((2,
"_sion_flush_block", sion_filedesc->
rank,
"not flushed lastchunknr->%d byteswritten=%lld fileposition=%lld startpos=%lld (%lld)\n",
1060 DPRINTFP((2,
"_sion_flush_block", sion_filedesc->
rank,
"leave\n"));
1073 int rc = SION_SUCCESS;
1075 DPRINTFP((2,
"_sion_create_new_block", _SION_DEFAULT_RANK,
"enter alloc \n"));
1084 _sion_apply_hints(sion_filedesc,SION_HINTS_FREE_TYPE_CHUNK);
1090 rc = _sion_apply_hints(sion_filedesc,SION_HINTS_ACCESS_TYPE_CHUNK);
1098 DPRINTFP((2,
"_sion_create_new_block", _SION_DEFAULT_RANK,
"skip to next already allocated block currentblocknr=%d lastchunknr->%d currentpos=%lld\n",
1113 _sion_apply_hints(sion_filedesc,SION_HINTS_FREE_TYPE_CHUNK);
1121 rc = _sion_apply_hints(sion_filedesc,SION_HINTS_ACCESS_TYPE_CHUNK);
1128 DPRINTFP((2,
"_sion_create_new_block", _SION_DEFAULT_RANK,
"skip to new allocated block currentblocknr=%d lastchunknr->%d currentpos=%lld\n",
1141 sion_int32 endianness = 0;
1143 DPRINTFP((2,
"_sion_get_endianness_flags", -1,
"enter with flags 0x%x\n", flags));
1148 endianness |= endianness << 24;
1149 if (flags & _SION_FMODE_ENDIANNESS_SET) {
1151 if (flags & _SION_FMODE_ENDIANNESS_BIG) {
1152 endianness |= 0x0101 << 8;
1155 else if (endianness & 1) {
1157 endianness |= 0x0101 << 8;
1160 DPRINTFP((2,
"_sion_get_endianness_flags", -1,
"leave with endianness 0x%x\n", endianness));
1165 #define DFUNCTION "_sion_getenv"
1170 char *name_with_prefix = NULL;
1171 char *getenv_result = NULL;
1172 const int full_len = strlen(name) + strlen(SION_LVERSION_PREFIX) + 1;
1174 DPRINTFP((2, DFUNCTION, -1,
"enter: name = %s\n", name));
1176 name_with_prefix = (
char *)malloc(full_len);
1177 sprintf(name_with_prefix,
"%s%s", SION_LVERSION_PREFIX, name);
1179 getenv_result = getenv(name_with_prefix);
1180 free(name_with_prefix);
1182 DPRINTFP((2, DFUNCTION, -1,
"leave: getenv_result = %s\n", getenv_result));
1184 return getenv_result;
1200 _sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,
"_sion_alloc_io_info: cannot allocate memory of size %lu (p_fn), aborting ...\n",
1208 p->names = (
const char **) malloc(p_nf *
sizeof(
char *));
1209 if (p->names == NULL) {
1210 _sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,
"_sion_alloc_io_info: cannot allocate memory of size %lu (names), aborting ...\n",
1211 (
unsigned long) p_nf *
sizeof(
char *));
1216 p->sizes = (
size_t *) malloc(p_nf *
sizeof(
size_t));
1217 if (p->sizes == NULL) {
1218 _sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,
"_sion_alloc_io_info: cannot allocate memory of size %lu (sizes), aborting ...\n",
1219 (
unsigned long) p_nf *
sizeof(
size_t));
1225 p->roles = (
int *) malloc(p_nf *
sizeof(
int));
1226 if (p->roles == NULL) {
1227 _sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,
"_sion_alloc_io_info: cannot allocate memory of size %lu (roles), aborting ...\n",
1228 (
unsigned long) p_nf *
sizeof(
int));
1235 for(i=0;i<p_nf;i++) {
1238 p->roles[i]=SION_ROLE_NONE;
1250 int rc=SION_SUCCESS;
1252 if(p->names!=NULL) free(p->names);
1253 if(p->sizes!=NULL) free(p->sizes);
1254 if(p->roles!=NULL) free(p->roles);