1414 * Copyright (c) 2012-2013 Los Alamos National Security, LLC.
1515 * All rights reserved.
1616 * Copyright (c) 2014 Intel, Inc. All rights reserved.
17+ * Copyright (c) 2016 University of Houston. All rights reserved.
1718 * $COPYRIGHT$
1819 *
1920 * Additional copyrights may follow
@@ -444,8 +445,9 @@ static char *opal_check_mtab(char *dev_path)
444445 * If the file is not created, the parent directory is checked.
445446 * This allows checking for NFS prior to opening the file.
446447 *
447- * @param[in] fname File name to check
448- *
448+ * @fname[in] File name to check
449+ * @fstype[out] File system type if retval is true
450+ *
449451 * @retval true If fname is on NFS, Lustre, Panasas or GPFS
450452 * @retval false otherwise
451453 *
@@ -493,11 +495,14 @@ static char *opal_check_mtab(char *dev_path)
493495#ifndef AUTOFS_SUPER_MAGIC
494496#define AUTOFS_SUPER_MAGIC 0x0187
495497#endif
498+ #ifndef PVFS2_SUPER_MAGIC
499+ #define PVFS2_SUPER_MAGIC 0x20030528
500+ #endif
496501
497502#define MASK2 0xffff
498503#define MASK4 0xffffffff
499504
500- bool opal_path_nfs (char * fname )
505+ bool opal_path_nfs (char * fname , char * * ret_fstype )
501506{
502507 int i ;
503508 int fsrc = -1 ;
@@ -523,7 +528,8 @@ bool opal_path_nfs(char *fname)
523528 {NFS_SUPER_MAGIC , MASK2 , "nfs" },
524529 {AUTOFS_SUPER_MAGIC , MASK2 , "autofs" },
525530 {PAN_KERNEL_FS_CLIENT_SUPER_MAGIC , MASK4 , "panfs" },
526- {GPFS_SUPER_MAGIC , MASK4 , "gpfs" }
531+ {GPFS_SUPER_MAGIC , MASK4 , "gpfs" },
532+ {PVFS2_SUPER_MAGIC , MASK4 , "pvfs2" }
527533 };
528534#define FS_TYPES_NUM (int)(sizeof (fs_types)/sizeof (fs_types[0]))
529535
@@ -555,6 +561,9 @@ bool opal_path_nfs(char *fname)
555561 fname , errno , file ));
556562 if (EPERM == errno ) {
557563 free (file );
564+ if ( NULL != ret_fstype ) {
565+ * ret_fstype = NULL ;
566+ }
558567 return false;
559568 }
560569
@@ -563,6 +572,9 @@ bool opal_path_nfs(char *fname)
563572 if (NULL == last_sep || (1 == strlen (last_sep ) &&
564573 OPAL_PATH_SEP [0 ] == * last_sep )) {
565574 free (file );
575+ if ( NULL != ret_fstype ) {
576+ * ret_fstype = NULL ;
577+ }
566578 return false;
567579 }
568580 * last_sep = '\0' ;
@@ -609,6 +621,9 @@ bool opal_path_nfs(char *fname)
609621 }
610622
611623 free (file );
624+ if ( NULL != ret_fstype ) {
625+ * ret_fstype = NULL ;
626+ }
612627 return false;
613628
614629found :
@@ -625,16 +640,25 @@ bool opal_path_nfs(char *fname)
625640 if (0 == strcasecmp (fs_types [x ].f_fsname , fs_type )) {
626641 OPAL_OUTPUT_VERBOSE ((10 , 0 , "opal_path_nfs: file:%s on fs:%s\n" , fname , fs_type ));
627642 free (fs_type );
643+ if ( NULL != ret_fstype ) {
644+ * ret_fstype = strdup (fs_types [x ].f_fsname );
645+ }
628646 return true;
629647 }
630648 }
631649 free (fs_type );
650+ if ( NULL != ret_fstype ) {
651+ * ret_fstype = NULL ;
652+ }
632653 return false;
633654 }
634655 }
635656
636657 OPAL_OUTPUT_VERBOSE ((10 , 0 , "opal_path_nfs: file:%s on fs:%s\n" ,
637658 fname , fs_types [i ].f_fsname ));
659+ if ( NULL != ret_fstype ) {
660+ * ret_fstype = strdup (fs_types [i ].f_fsname );
661+ }
638662 return true;
639663
640664#undef FS_TYPES_NUM
0 commit comments