Skip to content

Commit

Permalink
Remove use of pmix_os_dirpath_access
Browse files Browse the repository at this point in the history
Unnecessary use of function that calls stat.

Signed-off-by: Ralph Castain <[email protected]>
  • Loading branch information
rhc54 committed Dec 13, 2023
1 parent acb1b12 commit 9fe2a98
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 78 deletions.
7 changes: 0 additions & 7 deletions src/hwloc/hwloc_base_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,13 +1113,6 @@ char *prte_hwloc_base_check_on_coprocessor(void)
FILE *fp;
char *t, *cptr, *e, *cp = NULL;

if (PRTE_SUCCESS != pmix_os_dirpath_access("/proc/elog", S_IRUSR)) {
/* if the file isn't there, or we don't have permission
* to read it, then we are not on a coprocessor so far
* as we can tell
*/
return NULL;
}
if (NULL == (fp = fopen("/proc/elog", "r"))) {
/* nothing we can do */
return NULL;
Expand Down
73 changes: 2 additions & 71 deletions src/util/session_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* Copyright (c) 2021-2023 Nanook Consulting All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -89,22 +89,7 @@ static int prte_create_dir(char *directory)
mode_t my_mode = S_IRWXU; /* I'm looking for full rights */
int ret;

/* Sanity check before creating the directory with the proper mode,
* Make sure it doesn't exist already */
if (PMIX_ERR_NOT_FOUND != (ret = pmix_os_dirpath_access(directory, my_mode))) {
/* Failure because pmix_os_dirpath_access() indicated that either:
* - The directory exists and we can access it (no need to create it again),
* return PRTE_SUCCESS, or
* - don't have access rights, return PRTE_ERROR
*/
if (PMIX_SUCCESS != ret) {
PMIX_ERROR_LOG(ret);
}
ret = prte_pmix_convert_status(ret);
return (ret);
}

/* Get here if the directory doesn't exist, so create it */
/* attempt to create it */
if (PMIX_SUCCESS != (ret = pmix_os_dirpath_create(directory, my_mode))) {
PMIX_ERROR_LOG(ret);
}
Expand Down Expand Up @@ -382,15 +367,6 @@ int prte_session_dir_cleanup(pmix_nspace_t jobid)
pmix_output(0, "sess_dir_cleanup: found jobfam session dir empty - deleting");
}
rmdir(prte_process_info.jobfam_session_dir);
} else {
if (prte_debug_flag) {
ret = pmix_os_dirpath_access(prte_process_info.job_session_dir, 0);
if (PMIX_ERR_NOT_FOUND == ret) {
pmix_output(0, "sess_dir_cleanup: job session dir does not exist");
} else {
pmix_output(0, "sess_dir_cleanup: job session dir not empty - leaving");
}
}
}

if (NULL != prte_process_info.top_session_dir) {
Expand All @@ -399,15 +375,6 @@ int prte_session_dir_cleanup(pmix_nspace_t jobid)
pmix_output(0, "sess_dir_cleanup: found top session dir empty - deleting");
}
rmdir(prte_process_info.top_session_dir);
} else {
if (prte_debug_flag) {
ret = pmix_os_dirpath_access(prte_process_info.top_session_dir, 0);
if (PMIX_ERR_NOT_FOUND == ret) {
pmix_output(0, "sess_dir_cleanup: top session dir does not exist");
} else {
pmix_output(0, "sess_dir_cleanup: top session dir not empty - leaving");
}
}
}
}

Expand Down Expand Up @@ -449,15 +416,6 @@ int prte_session_dir_finalize(pmix_proc_t *proc)
pmix_output(0, "sess_dir_finalize: found proc session dir empty - deleting");
}
rmdir(prte_process_info.proc_session_dir);
} else {
if (prte_debug_flag) {
ret = pmix_os_dirpath_access(prte_process_info.proc_session_dir, 0);
if (PMIX_ERR_NOT_FOUND == ret) {
pmix_output(0, "sess_dir_finalize: proc session dir does not exist");
} else {
pmix_output(0, "sess_dir_finalize: proc session dir not empty - leaving");
}
}
}

/* special case - if a daemon is colocated with mpirun,
Expand Down Expand Up @@ -485,31 +443,13 @@ int prte_session_dir_finalize(pmix_proc_t *proc)
pmix_output(0, "sess_dir_finalize: found job session dir empty - deleting");
}
rmdir(prte_process_info.job_session_dir);
} else {
if (prte_debug_flag) {
ret = pmix_os_dirpath_access(prte_process_info.job_session_dir, 0);
if (PMIX_ERR_NOT_FOUND == ret) {
pmix_output(0, "sess_dir_finalize: job session dir does not exist");
} else {
pmix_output(0, "sess_dir_finalize: job session dir not empty - leaving");
}
}
}

if (pmix_os_dirpath_is_empty(prte_process_info.jobfam_session_dir)) {
if (prte_debug_flag) {
pmix_output(0, "sess_dir_finalize: found jobfam session dir empty - deleting");
}
rmdir(prte_process_info.jobfam_session_dir);
} else {
if (prte_debug_flag) {
ret = pmix_os_dirpath_access(prte_process_info.jobfam_session_dir, 0);
if (PMIX_ERR_NOT_FOUND == ret) {
pmix_output(0, "sess_dir_finalize: jobfam session dir does not exist");
} else {
pmix_output(0, "sess_dir_finalize: jobfam session dir not empty - leaving");
}
}
}

if (NULL != prte_process_info.top_session_dir) {
Expand All @@ -518,15 +458,6 @@ int prte_session_dir_finalize(pmix_proc_t *proc)
pmix_output(0, "sess_dir_finalize: found top session dir empty - deleting");
}
rmdir(prte_process_info.top_session_dir);
} else {
if (prte_debug_flag) {
ret = pmix_os_dirpath_access(prte_process_info.top_session_dir, 0);
if (PMIX_ERR_NOT_FOUND == ret) {
pmix_output(0, "sess_dir_finalize: top session dir does not exist");
} else {
pmix_output(0, "sess_dir_finalize: top session dir not empty - leaving");
}
}
}
}

Expand Down

0 comments on commit 9fe2a98

Please sign in to comment.