121121static void ADIO_FileSysType_parentdir (const char * filename , char * * dirnamep );
122122#endif
123123#endif
124- static void ADIO_FileSysType_prefix (const char * filename , int * fstype , int * error_code );
124+ static void ADIO_FileSysType_prefix (const char * filename , int * fstype ,
125+ ADIOI_Fns * * ops , int * error_code );
125126static void ADIO_FileSysType_fncall (const char * filename , int * fstype , int * error_code );
127+ struct ADIO_FSTypes {
128+ ADIOI_Fns * fileops ; /* function table */
129+ int fstype ; /* ADIO_xxx constant */
130+ const char * prefix ; /* file prefix */
131+ const char * name ; /* name of ADIO driver (returned in filehint) */
132+ };
133+
134+ /*
135+ * To add an ADIO
136+ * - add to the table below
137+ * - add a constant for your ADIO in include/adio.h
138+ * - add a guarded include in include/adioi_fs_proto.h
139+ */
140+ static struct ADIO_FSTypes fstypes [] = {
141+ #ifdef ROMIO_UFS
142+ {& ADIO_UFS_operations , ADIO_UFS , "ufs:" },
143+ #endif
144+ #ifdef ROMIO_NFS
145+ {& ADIO_NFS_operations , ADIO_NFS , "nfs:" },
146+ #endif
147+ #ifdef ROMIO_XFS
148+ {& ADIO_XFS_operations , ADIO_XFS , "xfs:" },
149+ #endif
150+ #ifdef ROMIO_PVFS2
151+ {& ADIO_PVFS2_operations , ADIO_PVFS2 , "pvfs2:" },
152+ #endif
153+ #ifdef ROMIO_GPFS
154+ {& ADIO_GPFS_operations , ADIO_GPFS , "gpfs:" },
155+ #endif
156+ #ifdef ROMIO_PANFS
157+ {& ADIO_PANFS_operations , ADIO_PANFS , "panfs:" },
158+ #endif
159+ #ifdef ROMIO_LUSTRE
160+ {& ADIO_LUSTRE_operations , ADIO_LUSTRE , "lustre:" },
161+ #endif
162+ #ifdef ROMIO_TESTFS
163+ {& ADIO_TESTFS_operations , ADIO_TESTFS , "testfs:" },
164+ #endif
165+ #ifdef ROMIO_IME
166+ {& ADIO_IME_operations , ADIO_IME , "ime:" },
167+ #endif
168+ #ifdef ROMIO_LOGFS
169+ {& ADIO_LOGFS_operations , ADIO_LOGFS , "logfs:" },
170+ #endif
171+ {0 , 0 , 0 , 0 } /* guard entry */
172+ };
173+
126174
127175/*
128176 ADIO_FileSysType_parentdir - determines a string pathname for the
@@ -522,32 +570,30 @@ Output Parameters:
522570 is considered an error. Except for on Windows systems where the default is NTFS.
523571
524572 */
525- static void ADIO_FileSysType_prefix (const char * filename , int * fstype , int * error_code )
573+ static void ADIO_FileSysType_prefix (const char * filename , int * fstype ,
574+ ADIOI_Fns * * ops , int * error_code )
526575{
527- static char myname [] = "ADIO_RESOLVEFILETYPE_PREFIX" ;
576+ char * cpy = 0 ;
577+ int i ;
578+
528579 * error_code = MPI_SUCCESS ;
580+ * fstype = -1 ;
581+
582+ /* search table for prefix */
583+ cpy = ADIOI_Strdup (filename );
584+ ADIOI_Strlower (cpy );
585+
586+ i = 0 ;
587+ while (fstypes [i ].fileops ) {
588+ if (!strncmp (fstypes [i ].prefix , cpy , strlen (fstypes [i ].prefix ))) {
589+ * fstype = fstypes [i ].fstype ;
590+ * ops = fstypes [i ].fileops ;
591+ break ;
592+ }
593+ ++ i ;
594+ }
529595
530- if (!strncmp (filename , "ufs:" , 4 ) || !strncmp (filename , "UFS:" , 4 )) {
531- * fstype = ADIO_UFS ;
532- } else if (!strncmp (filename , "nfs:" , 4 ) || !strncmp (filename , "NFS:" , 4 )) {
533- * fstype = ADIO_NFS ;
534- } else if (!strncmp (filename , "panfs:" , 6 ) || !strncmp (filename , "PANFS:" , 6 )) {
535- * fstype = ADIO_PANFS ;
536- } else if (!strncmp (filename , "xfs:" , 4 ) || !strncmp (filename , "XFS:" , 4 )) {
537- * fstype = ADIO_XFS ;
538- } else if (!strncmp (filename , "pvfs2:" , 6 ) || !strncmp (filename , "PVFS2:" , 6 )) {
539- * fstype = ADIO_PVFS2 ;
540- } else if (!strncmp (filename , "ime:" , 4 ) || !strncmp (filename , "IME:" , 4 )) {
541- * fstype = ADIO_IME ;
542- } else if (!strncmp (filename , "testfs:" , 7 )
543- || !strncmp (filename , "TESTFS:" , 7 )) {
544- * fstype = ADIO_TESTFS ;
545- } else if (!strncmp (filename , "lustre:" , 7 )
546- || !strncmp (filename , "LUSTRE:" , 7 )) {
547- * fstype = ADIO_LUSTRE ;
548- } else if (!strncmp (filename , "gpfs:" , 5 ) || !strncmp (filename , "GPFS:" , 5 )) {
549- * fstype = ADIO_GPFS ;
550- } else {
596+ if (-1 == * fstype ) {
551597 * fstype = 0 ;
552598 /* --BEGIN ERROR HANDLING-- */
553599 * error_code = MPIO_Err_create_code (MPI_SUCCESS , MPIR_ERR_RECOVERABLE ,
@@ -556,6 +602,7 @@ static void ADIO_FileSysType_prefix(const char *filename, int *fstype, int *erro
556602 "*iofstypeunsupported %s" , filename );
557603 /* --END ERROR HANDLING-- */
558604 }
605+ ADIOI_Free (cpy );
559606}
560607
561608/*@
@@ -584,6 +631,7 @@ void ADIO_ResolveFileType(MPI_Comm comm, const char *filename, int *fstype,
584631 char * tmp ;
585632 static char myname [] = "ADIO_RESOLVEFILETYPE" ;
586633 char * p ;
634+ * ops = 0 ;
587635
588636 file_system = -1 ;
589637 if (filename == NULL ) {
@@ -651,7 +699,7 @@ void ADIO_ResolveFileType(MPI_Comm comm, const char *filename, int *fstype,
651699 *
652700 * perhaps we should have this code go through the allreduce as well?
653701 */
654- ADIO_FileSysType_prefix (filename , & file_system , & myerrcode );
702+ ADIO_FileSysType_prefix (filename , & file_system , ops , & myerrcode );
655703 if (myerrcode != MPI_SUCCESS ) {
656704 * error_code = myerrcode ;
657705 return ;
@@ -667,106 +715,12 @@ void ADIO_ResolveFileType(MPI_Comm comm, const char *filename, int *fstype,
667715 * including the colon! */
668716 p = getenv ("ROMIO_FSTYPE_FORCE" );
669717 if (p != NULL ) {
670- ADIO_FileSysType_prefix (p , & file_system , & myerrcode );
718+ ADIO_FileSysType_prefix (p , & file_system , ops , & myerrcode );
671719 if (myerrcode != MPI_SUCCESS ) {
672720 * error_code = myerrcode ;
673721 return ;
674722 }
675723 }
676-
677- /* verify that we support this file system type and set ops pointer */
678- if (file_system == ADIO_UFS ) {
679- #ifndef ROMIO_UFS
680- * error_code = MPIO_Err_create_code (MPI_SUCCESS , MPIR_ERR_RECOVERABLE ,
681- myname , __LINE__ , MPI_ERR_IO ,
682- "**iofstypeunsupported" , 0 );
683- return ;
684- #else
685- * ops = & ADIO_UFS_operations ;
686- #endif
687- }
688- if (file_system == ADIO_NFS ) {
689- #ifndef ROMIO_NFS
690- * error_code = MPIO_Err_create_code (MPI_SUCCESS , MPIR_ERR_RECOVERABLE ,
691- myname , __LINE__ , MPI_ERR_IO ,
692- "**iofstypeunsupported" , 0 );
693- return ;
694- #else
695- * ops = & ADIO_NFS_operations ;
696- #endif
697- }
698- if (file_system == ADIO_PANFS ) {
699- #ifndef ROMIO_PANFS
700- * error_code = MPIO_Err_create_code (MPI_SUCCESS , MPIR_ERR_RECOVERABLE ,
701- myname , __LINE__ , MPI_ERR_IO ,
702- "**iofstypeunsupported" , 0 );
703- return ;
704- #else
705- * ops = & ADIO_PANFS_operations ;
706- #endif
707- }
708- if (file_system == ADIO_XFS ) {
709- #ifndef ROMIO_XFS
710- * error_code = MPIO_Err_create_code (MPI_SUCCESS , MPIR_ERR_RECOVERABLE ,
711- myname , __LINE__ , MPI_ERR_IO ,
712- "**iofstypeunsupported" , 0 );
713- return ;
714- #else
715- * ops = & ADIO_XFS_operations ;
716- #endif
717- }
718- if (file_system == ADIO_PVFS2 ) {
719- #ifndef ROMIO_PVFS2
720- * error_code = MPIO_Err_create_code (MPI_SUCCESS , MPIR_ERR_RECOVERABLE ,
721- myname , __LINE__ , MPI_ERR_IO ,
722- "**iofstypeunsupported" , 0 );
723- return ;
724- #else
725- * ops = & ADIO_PVFS2_operations ;
726- #endif
727- }
728- if (file_system == ADIO_TESTFS ) {
729- #ifndef ROMIO_TESTFS
730- * error_code = MPIO_Err_create_code (MPI_SUCCESS , MPIR_ERR_RECOVERABLE ,
731- myname , __LINE__ , MPI_ERR_IO ,
732- "**iofstypeunsupported" , 0 );
733- return ;
734- #else
735- * ops = & ADIO_TESTFS_operations ;
736- #endif
737- }
738-
739- if (file_system == ADIO_GPFS ) {
740- #ifndef ROMIO_GPFS
741- * error_code = MPIO_Err_create_code (MPI_SUCCESS , MPIR_ERR_RECOVERABLE ,
742- myname , __LINE__ , MPI_ERR_IO ,
743- "**iofstypeunsupported" , 0 );
744- return ;
745- #else
746- * ops = & ADIO_GPFS_operations ;
747- #endif
748- }
749-
750- if (file_system == ADIO_LUSTRE ) {
751- #ifndef ROMIO_LUSTRE
752- * error_code =
753- MPIO_Err_create_code (MPI_SUCCESS , MPIR_ERR_RECOVERABLE , myname , __LINE__ , MPI_ERR_IO ,
754- "**iofstypeunsupported" , 0 );
755- return ;
756- #else
757- * ops = & ADIO_LUSTRE_operations ;
758- #endif
759- }
760- if (file_system == ADIO_IME ) {
761- #ifndef ROMIO_IME
762- * error_code = MPIO_Err_create_code (MPI_SUCCESS , MPIR_ERR_RECOVERABLE ,
763- myname , __LINE__ , MPI_ERR_IO ,
764- "**iofstypeunsupported" , 0 );
765- return ;
766- #else
767- * ops = & ADIO_IME_operations ;
768- #endif
769- }
770724 * error_code = MPI_SUCCESS ;
771725 * fstype = file_system ;
772726 return ;
0 commit comments