src/mca/filem/base/filem_base_receive.c
/*
 * This function is responsible for:
 * - Constructing the remote absolute path for the specified file/dir
 * - Verify the existence of the file/dir
 * - Determine if the specified file/dir is in fact a file or dir or unknown if not found.
 */
This function is responsible for:
- Constructing the remote absolute path for the specified file/dir
- Verify the existence of the file/dir
- Determine if the specified file/dir is in fact a file or dir or unknown if not found.
This function is responsible for : - Constructing the remote absolute path for the specified file / dir - Verify the existence of the file / dir - Determine if the specified file / dir is in fact a file or dir or unknown if not found .
static void filem_base_process_get_remote_path_cmd(pmix_proc_t *sender, pmix_data_buffer_t *buffer)
{
    pmix_data_buffer_t *answer;
    int32_t count;
    char *filename = NULL;
    char *tmp_name = NULL;
    char cwd[PRTE_PATH_MAX];
    int file_type = PRTE_FILEM_TYPE_UNKNOWN;
    struct stat file_status;
    int rc;
    count = 1;
    rc = PMIx_Data_unpack(PRTE_PROC_MY_NAME, buffer, &filename, &count, PMIX_STRING);
    if (PMIX_SUCCESS != rc) {
        PMIX_ERROR_LOG(rc);
        PRTE_ACTIVATE_JOB_STATE(NULL, PRTE_JOB_STATE_FORCED_EXIT);
        goto CLEANUP;
    }
    if (filename[0] != '/') { 
        if (NULL == getcwd(cwd, sizeof(cwd))) {
            return;
        }
        prte_asprintf(&tmp_name, "%s/%s", cwd, filename);
    } else {
        tmp_name = strdup(filename);
    }
    prte_output_verbose(10, prte_filem_base_framework.framework_output,
                        "filem:base: process_get_remote_path_cmd: %s -> %s: Filename Requested "
                        "(%s) translated to (%s)",
                        PRTE_NAME_PRINT(PRTE_PROC_MY_NAME), PRTE_NAME_PRINT(sender), filename,
                        tmp_name);
    if (0 != (rc = stat(tmp_name, &file_status))) {
        file_type = PRTE_FILEM_TYPE_UNKNOWN;
    } else {
        if (S_ISDIR(file_status.st_mode)) {
            file_type = PRTE_FILEM_TYPE_DIR;
        } else if (S_ISREG(file_status.st_mode)) {
            file_type = PRTE_FILEM_TYPE_FILE;
        }
    }
    PMIX_DATA_BUFFER_CREATE(answer);
    rc = PMIx_Data_pack(PRTE_PROC_MY_NAME, answer, &tmp_name, 1, PMIX_STRING);
    if (PMIX_SUCCESS != rc) {
        PMIX_ERROR_LOG(rc);
        PRTE_ACTIVATE_JOB_STATE(NULL, PRTE_JOB_STATE_FORCED_EXIT);
        PMIX_DATA_BUFFER_RELEASE(answer);
        goto CLEANUP;
    }
    rc = PMIx_Data_pack(PRTE_PROC_MY_NAME, answer, &file_type, 1, PMIX_INT);
    if (PMIX_SUCCESS != rc) {
        PMIX_ERROR_LOG(rc);
        PRTE_ACTIVATE_JOB_STATE(NULL, PRTE_JOB_STATE_FORCED_EXIT);
        PMIX_DATA_BUFFER_RELEASE(answer);
        goto CLEANUP;
    }
    if (0 > (rc = prte_rml.send_buffer_nb(sender, answer, PRTE_RML_TAG_FILEM_BASE_RESP,
                                          prte_rml_send_callback, NULL))) {
        PRTE_ERROR_LOG(rc);
        PRTE_ACTIVATE_JOB_STATE(NULL, PRTE_JOB_STATE_FORCED_EXIT);
        PMIX_DATA_BUFFER_RELEASE(answer);
    }
CLEANUP:
    if (NULL != filename) {
        free(filename);
        filename = NULL;
    }
    if (NULL != tmp_name) {
        free(tmp_name);
        tmp_name = NULL;
    }
}
static void filem_base_process_get_remote_path_cmd ( pmix_proc_t * sender , pmix_data_buffer_t * buffer ) { pmix_data_buffer_t * answer ; int32_t count ; char * filename = NULL ; char * tmp_name = NULL ; char cwd [ PRTE_PATH_MAX ] ; int file_type = PRTE_FILEM_TYPE_UNKNOWN ; struct stat file_status ; int rc ; count = 1 ; rc = PMIx_Data_unpack ( PRTE_PROC_MY_NAME , buffer , & filename , & count , PMIX_STRING ) ; if ( PMIX_SUCCESS != rc ) { PMIX_ERROR_LOG ( rc ) ; PRTE_ACTIVATE_JOB_STATE ( NULL , PRTE_JOB_STATE_FORCED_EXIT ) ; goto CLEANUP ; } if ( filename [ 0 ] != ' ' ) { if ( NULL == getcwd ( cwd , sizeof ( cwd ) ) ) { return ; } prte_asprintf ( & tmp_name , " " , cwd , filename ) ; } else { tmp_name = strdup ( filename ) ; } prte_output_verbose ( 10 , prte_filem_base_framework . framework_output , " " " " , PRTE_NAME_PRINT ( PRTE_PROC_MY_NAME ) , PRTE_NAME_PRINT ( sender ) , filename , tmp_name ) ; if ( 0 != ( rc = stat ( tmp_name , & file_status ) ) ) { file_type = PRTE_FILEM_TYPE_UNKNOWN ; } else { if ( S_ISDIR ( file_status . st_mode ) ) { file_type = PRTE_FILEM_TYPE_DIR ; } else if ( S_ISREG ( file_status . st_mode ) ) { file_type = PRTE_FILEM_TYPE_FILE ; } } PMIX_DATA_BUFFER_CREATE ( answer ) ; rc = PMIx_Data_pack ( PRTE_PROC_MY_NAME , answer , & tmp_name , 1 , PMIX_STRING ) ; if ( PMIX_SUCCESS != rc ) { PMIX_ERROR_LOG ( rc ) ; PRTE_ACTIVATE_JOB_STATE ( NULL , PRTE_JOB_STATE_FORCED_EXIT ) ; PMIX_DATA_BUFFER_RELEASE ( answer ) ; goto CLEANUP ; } rc = PMIx_Data_pack ( PRTE_PROC_MY_NAME , answer , & file_type , 1 , PMIX_INT ) ; if ( PMIX_SUCCESS != rc ) { PMIX_ERROR_LOG ( rc ) ; PRTE_ACTIVATE_JOB_STATE ( NULL , PRTE_JOB_STATE_FORCED_EXIT ) ; PMIX_DATA_BUFFER_RELEASE ( answer ) ; goto CLEANUP ; } if ( 0 > ( rc = prte_rml . send_buffer_nb ( sender , answer , PRTE_RML_TAG_FILEM_BASE_RESP , prte_rml_send_callback , NULL ) ) ) { PRTE_ERROR_LOG ( rc ) ; PRTE_ACTIVATE_JOB_STATE ( NULL , PRTE_JOB_STATE_FORCED_EXIT ) ; PMIX_DATA_BUFFER_RELEASE ( answer ) ; } CLEANUP : if ( NULL != filename ) { free ( filename ) ; filename = NULL ; } if ( NULL != tmp_name ) { free ( tmp_name ) ; tmp_name = NULL ; } }
This function is responsible for:
 - Constructing the remote absolute path for the specified file/dir
 - Verify the existence of the file/dir
 - Determine if the specified file/dir is in fact a file or dir or unknown if not found.
This function is responsible for : - Constructing the remote absolute path for the specified file / dir - Verify the existence of the file / dir - Determine if the specified file / dir is in fact a file or dir or unknown if not found .
/*
     * Determine the absolute path of the file
     */ /* if it is not an absolute path already */ /*
     * Determine if the file/dir exists at that absolute path
     * Determine if the file/dir is a file or a directory
     */ /* Is it a directory? */ /*
     * Pack up the response
     * Send back the reference type
     * - PRTE_FILEM_TYPE_FILE    = File
     * - PRTE_FILEM_TYPE_DIR     = Directory
     * - PRTE_FILEM_TYPE_UNKNOWN = Could not be determined, or does not exist
     */