This source file includes following definitions.
- mca_fs_base_get_parent_dir
- mca_fs_base_get_fstype
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 #include "ompi_config.h"
  25 
  26 #include <stdio.h>
  27 
  28 #include "opal/mca/base/base.h"
  29 #include "opal/util/path.h"
  30 #include "opal/util/printf.h"
  31 #include "opal/util/string_copy.h"
  32 
  33 #include "ompi/mca/mca.h"
  34 #include "ompi/mca/fs/fs.h"
  35 #include "ompi/mca/fs/base/base.h"
  36 #include "ompi/mca/common/ompio/common_ompio.h"
  37 
  38 #ifdef HAVE_SYS_STATFS_H
  39 #include <sys/statfs.h> 
  40 #endif
  41 #ifdef HAVE_SYS_PARAM_H
  42 #include <sys/param.h>
  43 #endif
  44 #ifdef HAVE_SYS_MOUNT_H
  45 #include <sys/mount.h>
  46 #endif
  47 #ifdef HAVE_SYS_STAT_H
  48 #include <sys/stat.h>
  49 #endif
  50 #ifdef HAVE_UNISTD_H
  51 #include <unistd.h>
  52 #endif
  53 
  54 void mca_fs_base_get_parent_dir ( char *filename, char **dirnamep)
  55 {
  56     int err;
  57     char *dir = NULL, *slash;
  58     struct stat statbuf;
  59 
  60     if (strlen(filename) < 1) {
  61         opal_asprintf(dirnamep, ".%s", OPAL_PATH_SEP);
  62         return;
  63     }
  64 
  65     err = lstat(filename, &statbuf);
  66 
  67     if (err || (!S_ISLNK(statbuf.st_mode))) {
  68         
  69 
  70 
  71         dir = strdup(filename);
  72     }
  73     else {
  74         
  75 
  76 
  77 
  78 
  79         int namelen;
  80         char linkbuf[PATH_MAX+1];
  81 
  82         namelen = readlink(filename, linkbuf, PATH_MAX);
  83         if (namelen == -1) {
  84             
  85 
  86 
  87 
  88             dir = strdup(filename);
  89         }
  90         else {
  91             
  92             linkbuf[namelen] = '\0'; 
  93             dir = strdup(linkbuf);
  94         }
  95     }
  96 
  97     slash = strrchr(dir, '/');
  98     if (!slash) {
  99         
 100         
 101         opal_string_copy(dir, ".", 2);
 102     } else {
 103         if (slash == dir) {
 104             *(dir + 1) = '\0';
 105         } else {
 106             *slash = '\0';
 107         }
 108     }
 109 
 110     *dirnamep = dir;
 111     return;
 112 }
 113 
 114 int  mca_fs_base_get_fstype(char *fname )
 115 {
 116     int ompio_type = UFS;
 117     char *fstype=NULL;
 118     bool ret = opal_path_nfs ( fname, &fstype );
 119 
 120     if ( false == ret ) {
 121         char *dir;
 122         mca_fs_base_get_parent_dir (fname, &dir );
 123         ret = opal_path_nfs (dir, &fstype);
 124         free(dir);
 125         if ( false == ret ) {
 126             return ompio_type;
 127         }
 128     }
 129     if ( 0 == strncasecmp(fstype, "lustre", sizeof("lustre")) ) {
 130         ompio_type = LUSTRE;
 131     }
 132     else if ( 0 == strncasecmp(fstype, "pvfs2", sizeof("pvfs2"))) {
 133         ompio_type = PVFS2;
 134     }
 135     else if ( 0 == strncasecmp(fstype, "ime", sizeof("ime"))) {
 136         ompio_type = IME;
 137     }
 138 
 139     free (fstype);
 140     return ompio_type;
 141 }
 142