1
1

Provide an updated version of sys_info that does a little more error checking. It returns LAM_ERROR if there is a problem, and LAM_SUCCESS if everything goes okay. Also, the system information has been extended to include the path separator character, usually either a '\' or '/', depending upon operating system.

This utility is planned to be called early (like perhaps in mpi_init) to fill the global variable with the relevant information. Since this info might change if the process migrates, we will update it with another call to ompi_sys_info as part of the migration process. If you want to call it yourself, however, there is no harm done - it will just update the global variable and merrily sail along.

This commit was SVN r1145.
Этот коммит содержится в:
Ralph Castain 2004-05-20 21:28:59 +00:00
родитель 48df884e40
Коммит 2e866b9d46
2 изменённых файлов: 47 добавлений и 5 удалений

Просмотреть файл

@ -1,14 +1,47 @@
/*
* $HEADER$
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <libgen.h>
#include "constants.h"
#include "util/sys_info.h"
ompi_sys_info_t ompi_system_info;
int ompi_sys_info(void)
{
struct utsname sys_info;
char *path_name;
return (uname(&ompi_system_info));
if (0 > uname(&sys_info)) { /* have an error - set values to indicate */
strcpy(ompi_system_info.sysname, "NULL");
strcpy(ompi_system_info.nodename, "NULL");
strcpy(ompi_system_info.release, "NULL");
strcpy(ompi_system_info.version, "NULL");
strcpy(ompi_system_info.machine, "NULL");
ompi_system_info.path_sep = NULL;
return(LAM_ERROR);
}
strcpy(ompi_system_info.sysname, sys_info.sysname);
strcpy(ompi_system_info.nodename, sys_info.nodename);
strcpy(ompi_system_info.release, sys_info.release);
strcpy(ompi_system_info.version, sys_info.version);
strcpy(ompi_system_info.machine, sys_info.machine);
if (NULL == (path_name = getcwd(NULL, 0))) {
ompi_system_info.path_sep = NULL;
return(LAM_ERROR);
}
if (strlen(path_name) > 1) {
ompi_system_info.path_sep = path_name[strlen(path_name)-strlen(basename(path_name))-1];
}
else {
ompi_system_info.path_sep = path_name[0];
}
return(LAM_SUCCESS);
}

Просмотреть файл

@ -18,14 +18,23 @@
*
* char nodename[] - the network node name of the host, same as that
* returned by gethostname()
*
* char path_sep - the character used to separate directories in the path,
* a value that is usually either a '\' or '/', depending
* upon the operating system
*/
#include <stdio.h>
#include <sys/utsname.h>
typedef struct utsname ompi_sys_info_t;
struct ompi_sys_info_t {
char sysname[_SYS_NAMELEN]; /* Name of OS */
char nodename[_SYS_NAMELEN]; /* Name of this network node */
char release[_SYS_NAMELEN]; /* Release level */
char version[_SYS_NAMELEN]; /* Version level */
char machine[_SYS_NAMELEN]; /* Hardware type */
char path_sep; /* path separation char */
};
typedef struct ompi_sys_info_t ompi_sys_info_t;
extern ompi_sys_info_t ompi_system_info;