2004-05-27 20:26:36 +04:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*
|
|
|
|
* $Id: tmpdir.c $
|
|
|
|
*
|
|
|
|
* Function: -
|
|
|
|
*/
|
2004-08-19 03:15:48 +04:00
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2004-05-27 20:26:36 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <pwd.h>
|
2004-08-08 06:24:00 +04:00
|
|
|
#include <stddef.h>
|
2004-05-27 20:26:36 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2004-08-08 06:24:00 +04:00
|
|
|
#include <libgen.h>
|
2004-05-27 20:26:36 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2004-08-29 06:46:31 +04:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <dirent.h>
|
2004-08-08 06:24:00 +04:00
|
|
|
|
2004-05-27 20:26:36 +04:00
|
|
|
/*
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netdb.h> MAXHOSTNAMELEN in Solaris
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include <ompi_debug.h>
|
|
|
|
#include <ompi_internal.h>
|
2004-05-27 20:26:36 +04:00
|
|
|
#include <terror.h>
|
|
|
|
#include <typical.h>
|
|
|
|
#include <etc_misc.h>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "include/constants.h"
|
|
|
|
|
|
|
|
#include "util/sys_info.h"
|
2004-06-29 08:50:40 +04:00
|
|
|
#include "util/proc_info.h"
|
2004-08-29 10:50:00 +04:00
|
|
|
#include "util/output.h"
|
2004-05-27 20:26:36 +04:00
|
|
|
#include "util/os_path.h"
|
|
|
|
#include "util/os_create_dirpath.h"
|
2004-09-13 23:02:43 +04:00
|
|
|
|
|
|
|
#include "runtime/runtime.h"
|
|
|
|
|
2004-06-29 08:50:40 +04:00
|
|
|
#include "util/session_dir.h"
|
2004-05-27 20:26:36 +04:00
|
|
|
|
2004-09-13 23:02:43 +04:00
|
|
|
static int ompi_check_dir(bool create, char *directory);
|
2004-05-27 20:26:36 +04:00
|
|
|
|
2004-09-13 23:02:43 +04:00
|
|
|
static void ompi_dir_empty(char *pathname);
|
2004-08-29 20:37:02 +04:00
|
|
|
|
2004-09-13 23:02:43 +04:00
|
|
|
static bool ompi_is_empty(char *pathname);
|
2004-08-29 20:37:02 +04:00
|
|
|
|
|
|
|
|
2004-05-27 20:26:36 +04:00
|
|
|
#define OMPI_DEFAULT_TMPDIR "tmp"
|
|
|
|
|
2004-09-13 23:02:43 +04:00
|
|
|
static int ompi_check_dir(bool create, char *directory)
|
2004-05-27 20:26:36 +04:00
|
|
|
{
|
|
|
|
struct stat buf;
|
|
|
|
mode_t my_mode = S_IRWXU; /* at the least, I need to be able to do anything */
|
|
|
|
|
|
|
|
if (0 == stat(directory, &buf)) { /* exists - check access */
|
|
|
|
if ((buf.st_mode & my_mode) == my_mode) { /* okay, I can work here */
|
2004-06-07 19:33:53 +04:00
|
|
|
return(OMPI_SUCCESS);
|
2004-05-27 20:26:36 +04:00
|
|
|
}
|
|
|
|
}
|
2004-06-01 22:40:16 +04:00
|
|
|
if (create) {
|
2004-06-17 07:26:28 +04:00
|
|
|
return(ompi_os_create_dirpath(directory, my_mode)); /* try to create it with proper mode */
|
2004-06-01 22:40:16 +04:00
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
return(OMPI_ERROR); /* couldn't find it, or don't have access rights, and not asked to create it */
|
2004-05-27 20:26:36 +04:00
|
|
|
}
|
|
|
|
|
2004-08-29 20:37:02 +04:00
|
|
|
int ompi_session_dir(bool create, char *prfx, char *usr, char *hostid,
|
|
|
|
char *batchid, char *univ, char *job, char *proc)
|
2004-05-27 20:26:36 +04:00
|
|
|
{
|
2004-08-08 06:24:00 +04:00
|
|
|
char *fulldirpath=NULL, *tmp=NULL, *hostname=NULL, *batchname=NULL;
|
2004-08-29 20:37:02 +04:00
|
|
|
char *sessions=NULL, *frontend=NULL, *user=NULL, *universe=NULL;
|
2004-09-14 07:59:17 +04:00
|
|
|
char *prefix=NULL, *sav=NULL;
|
2004-08-08 06:24:00 +04:00
|
|
|
int return_code;
|
2004-05-27 20:26:36 +04:00
|
|
|
|
2004-08-29 20:37:02 +04:00
|
|
|
/* ensure that system info is set */
|
|
|
|
ompi_sys_info();
|
|
|
|
|
|
|
|
if (NULL == usr) { /* check if user set elsewhere */
|
|
|
|
if (NULL == ompi_system_info.user) { /* error condition */
|
|
|
|
return OMPI_ERROR;
|
|
|
|
} else {
|
|
|
|
user = strdup(ompi_system_info.user);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
user = strdup(usr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL == univ) { /* see if universe set elsewhere */
|
|
|
|
if (NULL == ompi_process_info.my_universe) { /* error condition */
|
|
|
|
return OMPI_ERROR;
|
|
|
|
} else {
|
|
|
|
universe = strdup(ompi_process_info.my_universe);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
universe = strdup(univ);
|
2004-06-29 08:50:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL == job && NULL != proc) { /* can't give a proc without a job */
|
2004-08-08 06:24:00 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL == hostid) { /* check if hostname set elsewhere */
|
|
|
|
if (NULL == ompi_system_info.nodename) { /* don't have a hostname anywhere - error */
|
|
|
|
return_code = OMPI_ERROR;
|
|
|
|
goto CLEANUP;
|
|
|
|
} else {
|
|
|
|
hostname = strdup(ompi_system_info.nodename);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
hostname = strdup(hostid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL == batchid) {
|
|
|
|
batchname = strdup("0");
|
|
|
|
} else {
|
|
|
|
batchname = batchid;
|
|
|
|
}
|
|
|
|
|
2004-08-29 20:37:02 +04:00
|
|
|
if (NULL == ompi_process_info.top_session_dir) {
|
|
|
|
if (0 > asprintf(&frontend, "openmpi-sessions-%s@%s:%s", user, hostname, batchname)) {
|
|
|
|
return_code = OMPI_ERROR;
|
|
|
|
goto CLEANUP;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
frontend = strdup(ompi_process_info.top_session_dir);
|
2004-06-29 08:50:40 +04:00
|
|
|
}
|
|
|
|
|
2004-08-29 20:37:02 +04:00
|
|
|
|
2004-06-29 08:50:40 +04:00
|
|
|
if (NULL != proc) {
|
2004-08-08 06:24:00 +04:00
|
|
|
if (0 > asprintf(&sessions, "%s%s%s%s%s%s%s", frontend,
|
|
|
|
ompi_system_info.path_sep, universe,
|
|
|
|
ompi_system_info.path_sep, job,
|
|
|
|
ompi_system_info.path_sep, proc)) {
|
|
|
|
return_code = OMPI_ERROR;
|
|
|
|
goto CLEANUP;
|
|
|
|
}
|
2004-06-29 08:50:40 +04:00
|
|
|
} else if (NULL != job) {
|
2004-08-08 06:24:00 +04:00
|
|
|
if (0 > asprintf(&sessions, "%s%s%s%s%s", frontend,
|
|
|
|
ompi_system_info.path_sep, universe,
|
|
|
|
ompi_system_info.path_sep, job)) {
|
|
|
|
return_code = OMPI_ERROR;
|
|
|
|
goto CLEANUP;
|
|
|
|
}
|
2004-06-29 08:50:40 +04:00
|
|
|
} else {
|
2004-08-08 06:24:00 +04:00
|
|
|
if (0 > asprintf(&sessions, "%s%s%s", frontend, ompi_system_info.path_sep, universe)) {
|
|
|
|
return_code = OMPI_ERROR;
|
|
|
|
goto CLEANUP;
|
|
|
|
}
|
2004-06-29 08:50:40 +04:00
|
|
|
}
|
2004-05-27 20:26:36 +04:00
|
|
|
|
2004-08-29 20:37:02 +04:00
|
|
|
|
2004-08-24 01:39:22 +04:00
|
|
|
if (NULL != prefix) { /* if a prefix is specified, start looking here */
|
|
|
|
tmp = strdup(prefix);
|
|
|
|
fulldirpath = strdup(ompi_os_path(false, tmp, sessions, NULL)); /* make sure it's an absolute pathname */
|
2004-08-08 06:24:00 +04:00
|
|
|
if (OMPI_SUCCESS == ompi_check_dir(create, fulldirpath)) { /* check for existence and access, or create it */
|
|
|
|
return_code = OMPI_SUCCESS;
|
|
|
|
goto COMPLETE;
|
2004-05-27 20:26:36 +04:00
|
|
|
}
|
2004-08-24 01:39:22 +04:00
|
|
|
}
|
2004-05-27 20:26:36 +04:00
|
|
|
|
2004-08-08 06:24:00 +04:00
|
|
|
/* no prefix was specified, so check other options in order */
|
2004-08-29 20:37:02 +04:00
|
|
|
if (NULL != ompi_process_info.tmpdir_base) { /* stored value previously */
|
2004-09-17 01:42:48 +04:00
|
|
|
tmp = strdup(ompi_process_info.tmpdir_base);
|
|
|
|
fulldirpath = strdup(ompi_os_path(false, tmp, sessions, NULL));
|
2004-08-29 20:37:02 +04:00
|
|
|
if (OMPI_SUCCESS == ompi_check_dir(create, fulldirpath)) { /* check for existence and access, or create it */
|
|
|
|
return_code = OMPI_SUCCESS;
|
|
|
|
goto COMPLETE;
|
|
|
|
}
|
|
|
|
} else if (NULL != getenv("OMPI_PREFIX_ENV")) { /* we have prefix enviro var - try that next */
|
2004-06-07 19:33:53 +04:00
|
|
|
tmp = strdup(getenv("OMPI_PREFIX_ENV"));
|
2004-08-24 01:39:22 +04:00
|
|
|
fulldirpath = strdup(ompi_os_path(false, tmp, sessions, NULL));
|
|
|
|
if (OMPI_SUCCESS == ompi_check_dir(create, fulldirpath)) { /* check for existence and access, or create it */
|
|
|
|
return_code = OMPI_SUCCESS;
|
|
|
|
goto COMPLETE;
|
|
|
|
}
|
2004-08-08 06:24:00 +04:00
|
|
|
} else if (NULL != getenv("TMPDIR")) {
|
|
|
|
tmp = strdup(getenv("TMPDIR"));
|
2004-08-24 01:39:22 +04:00
|
|
|
fulldirpath = strdup(ompi_os_path(false, tmp, sessions, NULL));
|
|
|
|
if (OMPI_SUCCESS == ompi_check_dir(create, fulldirpath)) { /* check for existence and access, or create it */
|
|
|
|
return_code = OMPI_SUCCESS;
|
|
|
|
goto COMPLETE;
|
|
|
|
}
|
2004-08-08 06:24:00 +04:00
|
|
|
} else if (NULL != getenv("TMP")) {
|
|
|
|
tmp = strdup(getenv("TMP"));
|
2004-08-24 01:39:22 +04:00
|
|
|
fulldirpath = strdup(ompi_os_path(false, tmp, sessions, NULL));
|
|
|
|
if (OMPI_SUCCESS == ompi_check_dir(create, fulldirpath)) { /* check for existence and access, or create it */
|
|
|
|
return_code = OMPI_SUCCESS;
|
|
|
|
goto COMPLETE;
|
|
|
|
}
|
2004-08-08 06:24:00 +04:00
|
|
|
} else {
|
|
|
|
tmp = strdup(OMPI_DEFAULT_TMPDIR);
|
2004-08-24 01:39:22 +04:00
|
|
|
fulldirpath = strdup(ompi_os_path(false, tmp, sessions, NULL));
|
|
|
|
if (OMPI_SUCCESS == ompi_check_dir(create, fulldirpath)) { /* check for existence and access, or create it */
|
|
|
|
return_code = OMPI_SUCCESS;
|
|
|
|
goto COMPLETE;
|
2004-08-29 20:37:02 +04:00
|
|
|
}
|
|
|
|
}
|
2004-05-27 20:26:36 +04:00
|
|
|
|
2004-08-08 06:24:00 +04:00
|
|
|
fulldirpath = strdup(ompi_os_path(false, tmp, sessions, NULL));
|
|
|
|
if (OMPI_SUCCESS == ompi_check_dir(create, fulldirpath)) { /* check for existence and access, or create it */
|
|
|
|
return_code = OMPI_SUCCESS;
|
|
|
|
goto COMPLETE;
|
|
|
|
} else {
|
|
|
|
return_code = OMPI_ERROR;
|
|
|
|
goto CLEANUP;
|
2004-05-27 20:26:36 +04:00
|
|
|
}
|
2004-08-08 06:24:00 +04:00
|
|
|
|
|
|
|
COMPLETE:
|
2004-09-17 01:42:48 +04:00
|
|
|
if (create) { /* if creating the dir tree, overwrite the fields */
|
|
|
|
if (NULL != ompi_process_info.tmpdir_base) {
|
|
|
|
free(ompi_process_info.tmpdir_base);
|
|
|
|
ompi_process_info.tmpdir_base = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != ompi_process_info.top_session_dir) {
|
|
|
|
free(ompi_process_info.top_session_dir);
|
|
|
|
ompi_process_info.top_session_dir = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-29 20:37:02 +04:00
|
|
|
if (NULL == ompi_process_info.tmpdir_base) {
|
2004-09-17 01:42:48 +04:00
|
|
|
ompi_process_info.tmpdir_base = strdup(tmp); /* fill in if empty */
|
2004-08-29 20:37:02 +04:00
|
|
|
}
|
2004-09-17 01:42:48 +04:00
|
|
|
|
2004-08-29 20:37:02 +04:00
|
|
|
if (NULL == ompi_process_info.top_session_dir) {
|
2004-09-17 01:42:48 +04:00
|
|
|
ompi_process_info.top_session_dir = strdup(frontend);
|
2004-08-29 20:37:02 +04:00
|
|
|
}
|
2004-08-24 01:39:22 +04:00
|
|
|
|
2004-09-17 01:42:48 +04:00
|
|
|
if (NULL != proc) {
|
|
|
|
if (create) { /* overwrite if creating */
|
|
|
|
if (NULL != ompi_process_info.proc_session_dir) {
|
|
|
|
free(ompi_process_info.proc_session_dir);
|
|
|
|
ompi_process_info.proc_session_dir = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (NULL == ompi_process_info.proc_session_dir) {
|
|
|
|
ompi_process_info.proc_session_dir = strdup(fulldirpath);
|
|
|
|
}
|
2004-09-14 07:59:17 +04:00
|
|
|
sav = strdup(fulldirpath);
|
2004-08-29 20:37:02 +04:00
|
|
|
free(fulldirpath);
|
2004-09-14 07:59:17 +04:00
|
|
|
fulldirpath = strdup(dirname(sav));
|
|
|
|
free(sav);
|
2004-08-29 20:37:02 +04:00
|
|
|
}
|
|
|
|
|
2004-09-17 01:42:48 +04:00
|
|
|
if (NULL != job) {
|
|
|
|
if (create) { /* overwrite if creating */
|
|
|
|
if (NULL != ompi_process_info.job_session_dir) {
|
|
|
|
free(ompi_process_info.job_session_dir);
|
|
|
|
ompi_process_info.job_session_dir = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (NULL == ompi_process_info.job_session_dir) {
|
|
|
|
ompi_process_info.job_session_dir = strdup(fulldirpath);
|
|
|
|
}
|
2004-09-14 07:59:17 +04:00
|
|
|
sav = strdup(fulldirpath);
|
2004-08-29 20:37:02 +04:00
|
|
|
free(fulldirpath);
|
2004-09-14 07:59:17 +04:00
|
|
|
fulldirpath = strdup(dirname(sav));
|
|
|
|
free(sav);
|
2004-08-29 20:37:02 +04:00
|
|
|
}
|
2004-08-24 01:39:22 +04:00
|
|
|
|
2004-09-17 01:42:48 +04:00
|
|
|
if (create) { /* overwrite if creating */
|
|
|
|
if (NULL != ompi_process_info.universe_session_dir) {
|
|
|
|
free(ompi_process_info.universe_session_dir);
|
|
|
|
ompi_process_info.universe_session_dir = NULL;
|
|
|
|
}
|
|
|
|
}
|
2004-08-29 20:37:02 +04:00
|
|
|
if (NULL == ompi_process_info.universe_session_dir) {
|
2004-08-11 20:24:00 +04:00
|
|
|
ompi_process_info.universe_session_dir = strdup(fulldirpath);
|
|
|
|
}
|
2004-05-27 20:26:36 +04:00
|
|
|
|
2004-09-13 23:02:43 +04:00
|
|
|
if (ompi_rte_debug_flag) {
|
|
|
|
ompi_output(0, "procdir: %s", ompi_process_info.proc_session_dir);
|
|
|
|
ompi_output(0, "jobdir: %s", ompi_process_info.job_session_dir);
|
|
|
|
ompi_output(0, "unidir: %s", ompi_process_info.universe_session_dir);
|
|
|
|
ompi_output(0, "top: %s", ompi_process_info.top_session_dir);
|
|
|
|
ompi_output(0, "tmp: %s", ompi_process_info.tmpdir_base);
|
|
|
|
}
|
|
|
|
|
2004-08-08 06:24:00 +04:00
|
|
|
CLEANUP:
|
|
|
|
if (tmp) {
|
2004-05-27 20:26:36 +04:00
|
|
|
free(tmp);
|
|
|
|
}
|
2004-08-08 06:24:00 +04:00
|
|
|
if (fulldirpath) {
|
|
|
|
free(fulldirpath);
|
2004-05-27 20:26:36 +04:00
|
|
|
}
|
2004-08-08 06:24:00 +04:00
|
|
|
if (frontend) {
|
|
|
|
free(frontend);
|
2004-05-27 20:26:36 +04:00
|
|
|
}
|
2004-08-08 06:24:00 +04:00
|
|
|
if (batchname) {
|
|
|
|
free(batchname);
|
|
|
|
}
|
|
|
|
if (hostname) {
|
|
|
|
free(hostname);
|
2004-05-27 20:26:36 +04:00
|
|
|
}
|
2004-08-08 06:24:00 +04:00
|
|
|
if (sessions) {
|
|
|
|
free(sessions);
|
2004-05-27 20:26:36 +04:00
|
|
|
}
|
2004-08-08 06:24:00 +04:00
|
|
|
|
|
|
|
return return_code;
|
2004-05-27 20:26:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-10 20:05:22 +04:00
|
|
|
int
|
|
|
|
ompi_session_dir_finalize()
|
|
|
|
{
|
2004-09-13 23:02:43 +04:00
|
|
|
ompi_dir_empty(ompi_process_info.proc_session_dir);
|
|
|
|
ompi_dir_empty(ompi_process_info.job_session_dir);
|
|
|
|
ompi_dir_empty(ompi_process_info.universe_session_dir);
|
|
|
|
ompi_dir_empty(ompi_process_info.top_session_dir);
|
|
|
|
|
|
|
|
if (ompi_is_empty(ompi_process_info.proc_session_dir)) {
|
|
|
|
if (ompi_rte_debug_flag) {
|
|
|
|
ompi_output(0, "sess_dir_finalize: found proc session dir empty - deleting");
|
|
|
|
}
|
|
|
|
rmdir(ompi_process_info.proc_session_dir);
|
2004-08-29 20:37:02 +04:00
|
|
|
} else {
|
2004-09-13 23:02:43 +04:00
|
|
|
if (ompi_rte_debug_flag) {
|
|
|
|
ompi_output(0, "sess_dir_finalize: proc session dir not empty - leaving");
|
|
|
|
}
|
2004-08-29 20:37:02 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-08-29 06:46:31 +04:00
|
|
|
}
|
|
|
|
|
2004-09-13 23:02:43 +04:00
|
|
|
if (ompi_is_empty(ompi_process_info.job_session_dir)) {
|
|
|
|
if (ompi_rte_debug_flag) {
|
|
|
|
ompi_output(0, "sess_dir_finalize: found job session dir empty - deleting");
|
|
|
|
}
|
|
|
|
rmdir(ompi_process_info.job_session_dir);
|
2004-08-29 20:37:02 +04:00
|
|
|
} else {
|
2004-09-13 23:02:43 +04:00
|
|
|
if (ompi_rte_debug_flag) {
|
|
|
|
ompi_output(0, "sess_dir_finalize: job session dir not empty - leaving");
|
|
|
|
}
|
2004-08-29 20:37:02 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-08-29 06:46:31 +04:00
|
|
|
}
|
|
|
|
|
2004-09-13 23:02:43 +04:00
|
|
|
if (ompi_is_empty(ompi_process_info.universe_session_dir)) {
|
|
|
|
if (ompi_rte_debug_flag) {
|
|
|
|
ompi_output(0, "sess_dir_finalize: found univ session dir empty - deleting");
|
|
|
|
}
|
|
|
|
rmdir(ompi_process_info.universe_session_dir);
|
2004-08-29 20:37:02 +04:00
|
|
|
} else {
|
2004-09-13 23:02:43 +04:00
|
|
|
if (ompi_rte_debug_flag) {
|
|
|
|
ompi_output(0, "sess_dir_finalize: univ session dir not empty - leaving");
|
|
|
|
}
|
2004-08-29 06:46:31 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-09-13 23:02:43 +04:00
|
|
|
if (ompi_is_empty(ompi_process_info.top_session_dir)) {
|
|
|
|
if (ompi_rte_debug_flag) {
|
|
|
|
ompi_output(0, "sess_dir_finalize: found top session dir empty - deleting");
|
|
|
|
}
|
|
|
|
rmdir(ompi_process_info.top_session_dir);
|
|
|
|
} else {
|
|
|
|
if (ompi_rte_debug_flag) {
|
|
|
|
ompi_output(0, "sess_dir_finalize: top session dir not empty - leaving");
|
|
|
|
}
|
2004-08-29 20:37:02 +04:00
|
|
|
}
|
|
|
|
|
2004-08-10 20:05:22 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2004-08-29 06:46:31 +04:00
|
|
|
|
2004-09-13 23:02:43 +04:00
|
|
|
static void
|
2004-08-29 20:37:02 +04:00
|
|
|
ompi_dir_empty(char *pathname)
|
2004-08-29 06:46:31 +04:00
|
|
|
{
|
|
|
|
DIR *dp;
|
|
|
|
struct dirent *ep;
|
|
|
|
char *filenm;
|
2004-08-29 20:37:02 +04:00
|
|
|
bool empty;
|
|
|
|
|
|
|
|
empty = true;
|
2004-08-29 06:46:31 +04:00
|
|
|
|
|
|
|
if (NULL != pathname) { /* protect against error */
|
|
|
|
dp = opendir(pathname);
|
|
|
|
if (NULL != dp) {
|
|
|
|
while ((ep = readdir(dp))) {
|
|
|
|
if ((0 != strcmp(ep->d_name, ".")) &&
|
|
|
|
(0 != strcmp(ep->d_name, "..")) &&
|
2004-09-13 23:02:43 +04:00
|
|
|
(DT_DIR != ep->d_type) &&
|
2004-09-15 20:33:36 +04:00
|
|
|
(0 != strncmp(ep->d_name, "output-", strlen("output-"))) &&
|
|
|
|
(0 != strcmp(ep->d_name, "universe-setup.txt"))) {
|
2004-08-29 10:50:00 +04:00
|
|
|
filenm = ompi_os_path(false, pathname, ep->d_name, NULL);
|
|
|
|
unlink(filenm);
|
2004-08-29 06:46:31 +04:00
|
|
|
}
|
|
|
|
}
|
2004-08-29 10:50:00 +04:00
|
|
|
closedir(dp);
|
2004-08-29 06:46:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-08-29 20:37:02 +04:00
|
|
|
|
2004-09-13 23:02:43 +04:00
|
|
|
static bool ompi_is_empty(char *pathname)
|
2004-08-29 20:37:02 +04:00
|
|
|
{
|
|
|
|
DIR *dp;
|
|
|
|
struct dirent *ep;
|
|
|
|
|
|
|
|
if (NULL != pathname) { /* protect against error */
|
|
|
|
dp = opendir(pathname);
|
|
|
|
if (NULL != dp) {
|
|
|
|
while ((ep = readdir(dp))) {
|
|
|
|
if ((0 != strcmp(ep->d_name, ".")) &&
|
2004-09-13 23:02:43 +04:00
|
|
|
(0 != strcmp(ep->d_name, ".."))) {
|
2004-08-29 20:37:02 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dp);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|