📄 ad_fstype.c
字号:
if (fsbuf.f_type == PVFS_SUPER_MAGIC) { *fstype = ADIO_PVFS; return; }# endif# ifdef PVFS2_SUPER_MAGIC if (fsbuf.f_type == PVFS2_SUPER_MAGIC) { *fstype = ADIO_PVFS2; return; }# endif# ifdef ROMIO_UFS /* if UFS support is enabled, default to that */ *fstype = ADIO_UFS; return;# endif /* --BEGIN ERROR HANDLING-- */ *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_NO_SUCH_FILE, "**filename", "**filename %s", filename); /* --END ERROR HANDLING-- */#endif /* STATFS APPROACH */#ifdef ROMIO_HAVE_STRUCT_STAT_WITH_ST_FSTYPE do { err = stat(filename, &sbuf); } while (err && (errno == ESTALE)); if (err && (errno == ENOENT)) { ADIO_FileSysType_parentdir(filename, &dir); err = stat(dir, &sbuf); ADIOI_Free(dir); } if (err) { /* --BEGIN ERROR HANDLING-- */ *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_NO_SUCH_FILE, "**filename", "**filename %s", filename); /* --END ERROR HANDLING-- */ return; } else { if (!strcmp(sbuf.st_fstype, "nfs")) *fstype = ADIO_NFS; else *fstype = ADIO_SFS; /* assuming SX4 for now */ }#endif /* STAT APPROACH */#ifdef ROMIO_NTFS ADIOI_UNREFERENCED_ARG(filename); ADIOI_UNREFERENCED_ARG(error_code); *fstype = ADIO_NTFS; /* only supported FS on Windows */#elif defined(ROMIO_NFS) *fstype = ADIO_NFS;#elif defined(ROMIO_UFS) *fstype = ADIO_UFS;#else /* --BEGIN ERROR HANDLING-- */ *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_NO_SUCH_FILE, "**filename", "**filename %s", filename); /* --END ERROR HANDLING-- */#endif}/* ADIO_FileSysType_prefix - determines file system type for a file using a prefix on the file name. upper layer should have already determined that a prefix is present.Input Parameters:. filename - path to file, including prefix (xxx:)Output Parameters:. fstype - pointer to integer in which to store file system type (ADIO_XXX). error_code - pointer to integer in which to store error code Returns MPI_SUCCESS in error_code on success. Filename not having a prefix is considered an error. Except for on Windows systems where the default is NTFS. */static void ADIO_FileSysType_prefix(char *filename, int *fstype, int *error_code){ static char myname[] = "ADIO_RESOLVEFILETYPE_PREFIX"; *error_code = MPI_SUCCESS; if (!strncmp(filename, "pfs:", 4) || !strncmp(filename, "PFS:", 4)) { *fstype = ADIO_PFS; } else if (!strncmp(filename, "piofs:", 6) || !strncmp(filename, "PIOFS:", 6)) { *fstype = ADIO_PIOFS; } else if (!strncmp(filename, "ufs:", 4) || !strncmp(filename, "UFS:", 4)) { *fstype = ADIO_UFS; } else if (!strncmp(filename, "nfs:", 4) || !strncmp(filename, "NFS:", 4)) { *fstype = ADIO_NFS; } else if (!strncmp(filename, "panfs:", 6) || !strncmp(filename, "PANFS:", 6)) { *fstype = ADIO_PANFS; } else if (!strncmp(filename, "hfs:", 4) || !strncmp(filename, "HFS:", 4)) { *fstype = ADIO_HFS; } else if (!strncmp(filename, "xfs:", 4) || !strncmp(filename, "XFS:", 4)) { *fstype = ADIO_XFS; } else if (!strncmp(filename, "sfs:", 4) || !strncmp(filename, "SFS:", 4)) { *fstype = ADIO_SFS; } else if (!strncmp(filename, "pvfs:", 5) || !strncmp(filename, "PVFS:", 5)) { *fstype = ADIO_PVFS; } else if (!strncmp(filename, "pvfs2:", 6)||!strncmp(filename, "PVFS2:", 6)) { *fstype = ADIO_PVFS2; } else if (!strncmp(filename, "testfs:", 7) || !strncmp(filename, "TESTFS:", 7)) { *fstype = ADIO_TESTFS; } else if (!strncmp(filename, "ftp:", 4) || !strncmp(filename, "gsiftp:", 7)) { *fstype = ADIO_GRIDFTP; } else {#ifdef ROMIO_NTFS *fstype = ADIO_NTFS;#else *fstype = 0; /* --BEGIN ERROR HANDLING-- */ *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_NO_SUCH_FILE, "**filename", "**filename %s", filename); /* --END ERROR HANDLING-- */#endif }}/*@ ADIO_ResolveFileType - determines file system type and operations from file name string; this is a collective callInput Parameters:. comm - communicator across which collective open is performed. filename - name of file (string)Output Parameters:. fstype - (pointer to) int holding file system type. ops - (address of) pointer to table of valid file operations. error_code - (pointer to) int holding error codeNotes:This code used to be in MPI_File_open(), but it has been moved into here in order to clean things up. The goal is to separate all this "did we compilefor this fs type" code from the MPI layer and also to introduce the ADIOI_Fnstables in a reasonable way. -- Rob, 06/06/2001@*/void ADIO_ResolveFileType(MPI_Comm comm, char *filename, int *fstype, ADIOI_Fns **ops, int *error_code){ int myerrcode, file_system, min_code; char *tmp; static char myname[] = "ADIO_RESOLVEFILETYPE"; file_system = -1; tmp = strchr(filename, ':'); if (!tmp) { /* no prefix; use system-dependent function call to determine type */ ADIO_FileSysType_fncall(filename, &file_system, &myerrcode); if (myerrcode != MPI_SUCCESS) { *error_code = myerrcode; return; } /* ensure that everyone came up with the same file system type */ MPI_Allreduce(&file_system, &min_code, 1, MPI_INT, MPI_MIN, comm); if (min_code == ADIO_NFS) file_system = ADIO_NFS; } else { /* prefix specified; just match via prefix and assume everyone got * the same thing. * * perhaps we should have this code go through the allreduce as well? */ ADIO_FileSysType_prefix(filename, &file_system, &myerrcode); if (myerrcode != MPI_SUCCESS) { *error_code = myerrcode; return; } } /* verify that we support this file system type and set ops pointer */ if (file_system == ADIO_PFS) {#ifndef ROMIO_PFS *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_PFS_operations;#endif } if (file_system == ADIO_PIOFS) {#ifndef ROMIO_PIOFS *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_PIOFS_operations;#endif } if (file_system == ADIO_UFS) {#ifndef ROMIO_UFS *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_UFS_operations;#endif } if (file_system == ADIO_NFS) {#ifndef ROMIO_NFS *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_NFS_operations;#endif } if (file_system == ADIO_PANFS) {#ifndef ROMIO_PANFS *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_PANFS_operations;#endif } if (file_system == ADIO_HFS) {#ifndef ROMIO_HFS *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_HFS_operations;#endif } if (file_system == ADIO_XFS) {#ifndef ROMIO_XFS *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_XFS_operations;#endif } if (file_system == ADIO_SFS) {#ifndef ROMIO_SFS *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_SFS_operations;#endif } if (file_system == ADIO_PVFS) {#ifndef ROMIO_PVFS *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_PVFS_operations;#endif } if (file_system == ADIO_PVFS2) {#ifndef ROMIO_PVFS2 *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_PVFS2_operations;#endif } if (file_system == ADIO_NTFS) {#ifndef ROMIO_NTFS *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_NTFS_operations;#endif } if (file_system == ADIO_TESTFS) {#ifndef ROMIO_TESTFS *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_TESTFS_operations;#endif } if (file_system == ADIO_GRIDFTP) {#ifndef ROMIO_GRIDFTP *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_GRIDFTP_operations;#endif } *error_code = MPI_SUCCESS; *fstype = file_system; return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -