OPAL: add support for autofs magic type
Этот коммит содержится в:
родитель
3430714989
Коммит
42f3fa0d1e
@ -650,6 +650,7 @@ AC_CHECK_HEADERS([alloca.h aio.h arpa/inet.h dirent.h \
|
|||||||
sys/types.h sys/uio.h sys/un.h net/uio.h sys/utsname.h sys/vfs.h sys/wait.h syslog.h \
|
sys/types.h sys/uio.h sys/un.h net/uio.h sys/utsname.h sys/vfs.h sys/wait.h syslog.h \
|
||||||
time.h termios.h ulimit.h unistd.h util.h utmp.h malloc.h \
|
time.h termios.h ulimit.h unistd.h util.h utmp.h malloc.h \
|
||||||
ifaddrs.h crt_externs.h regex.h signal.h \
|
ifaddrs.h crt_externs.h regex.h signal.h \
|
||||||
|
mntent.h paths.h \
|
||||||
ioLib.h sockLib.h hostLib.h shlwapi.h sys/synch.h limits.h db.h ndbm.h])
|
ioLib.h sockLib.h hostLib.h shlwapi.h sys/synch.h limits.h db.h ndbm.h])
|
||||||
|
|
||||||
AC_CHECK_HEADERS([sys/mount.h], [], [],
|
AC_CHECK_HEADERS([sys/mount.h], [], [],
|
||||||
|
@ -55,6 +55,19 @@
|
|||||||
#ifdef HAVE_SYS_MOUNT_H
|
#ifdef HAVE_SYS_MOUNT_H
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_MNTENT_H
|
||||||
|
#include <mntent.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_PATHS_H
|
||||||
|
#include <paths.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _PATH_MOUNTED
|
||||||
|
#define MOUNTED_FILE _PATH_MOUNTED
|
||||||
|
#else
|
||||||
|
#define MOUNTED_FILE "/etc/mtab"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "opal_stdint.h"
|
#include "opal_stdint.h"
|
||||||
#include "opal/util/output.h"
|
#include "opal/util/output.h"
|
||||||
@ -392,6 +405,35 @@ char* opal_find_absolute_path( char* app_name )
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read real FS type from /etc/mtab, needed to translate autofs fs type into real fs type
|
||||||
|
* TODO: solaris? OSX?
|
||||||
|
* Limitations: autofs on solaris/osx will be assumed as "nfs" type
|
||||||
|
*/
|
||||||
|
|
||||||
|
static char *opal_check_mtab(char *dev_path)
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef HAVE_MNTENT_H
|
||||||
|
FILE * mtab = NULL;
|
||||||
|
struct mntent * part = NULL;
|
||||||
|
|
||||||
|
if ((mtab = setmntent(MOUNTED_FILE, "r")) != NULL) {
|
||||||
|
while (NULL != (part = getmntent(mtab))) {
|
||||||
|
if ((NULL != part->mnt_dir) &&
|
||||||
|
(NULL != part->mnt_type) &&
|
||||||
|
(0 == strcmp(part->mnt_dir, dev_path)))
|
||||||
|
{
|
||||||
|
endmntent(mtab);
|
||||||
|
return strdup(part->mnt_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endmntent(mtab);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Figure out, whether fname is on network file system
|
* @brief Figure out, whether fname is on network file system
|
||||||
@ -448,6 +490,9 @@ char* opal_find_absolute_path( char* app_name )
|
|||||||
#ifndef GPFS_SUPER_MAGIC
|
#ifndef GPFS_SUPER_MAGIC
|
||||||
#define GPFS_SUPER_MAGIC 0x47504653 /* Thats GPFS in ASCII */
|
#define GPFS_SUPER_MAGIC 0x47504653 /* Thats GPFS in ASCII */
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef AUTOFS_SUPER_MAGIC
|
||||||
|
#define AUTOFS_SUPER_MAGIC 0x0187
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MASK2 0xffff
|
#define MASK2 0xffff
|
||||||
#define MASK4 0xffffffff
|
#define MASK4 0xffffffff
|
||||||
@ -476,6 +521,7 @@ bool opal_path_nfs(char *fname)
|
|||||||
} fs_types[] = {
|
} fs_types[] = {
|
||||||
{LL_SUPER_MAGIC, MASK4, "lustre"},
|
{LL_SUPER_MAGIC, MASK4, "lustre"},
|
||||||
{NFS_SUPER_MAGIC, MASK2, "nfs"},
|
{NFS_SUPER_MAGIC, MASK2, "nfs"},
|
||||||
|
{AUTOFS_SUPER_MAGIC, MASK2, "autofs"},
|
||||||
{PAN_KERNEL_FS_CLIENT_SUPER_MAGIC, MASK4, "panfs"},
|
{PAN_KERNEL_FS_CLIENT_SUPER_MAGIC, MASK4, "panfs"},
|
||||||
{GPFS_SUPER_MAGIC, MASK4, "gpfs"}
|
{GPFS_SUPER_MAGIC, MASK4, "gpfs"}
|
||||||
};
|
};
|
||||||
@ -566,9 +612,26 @@ again:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
found:
|
found:
|
||||||
OPAL_OUTPUT_VERBOSE((10, 0, "opal_path_nfs: file:%s on fs:%s\n",
|
|
||||||
fname, fs_types[i].f_fsname));
|
|
||||||
free (file);
|
free (file);
|
||||||
|
if (AUTOFS_SUPER_MAGIC == fs_types[i].f_fsid) {
|
||||||
|
char *fs_type = opal_check_mtab(fname);
|
||||||
|
int x;
|
||||||
|
if (NULL != fs_type) {
|
||||||
|
for (x = 0; x < FS_TYPES_NUM; x++) {
|
||||||
|
if (0 == strcasecmp(fs_types[x].f_fsname, fs_type)) {
|
||||||
|
OPAL_OUTPUT_VERBOSE((10, 0, "opal_path_nfs: file:%s on fs:%s\n", fname, fs_type));
|
||||||
|
free(fs_type);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(fs_type);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OPAL_OUTPUT_VERBOSE((10, 0, "opal_path_nfs: file:%s on fs:%s\n",
|
||||||
|
fname, fs_types[i].f_fsname));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#undef FS_TYPES_NUM
|
#undef FS_TYPES_NUM
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user