00001
00002
00003
00004
00005
00006
00007 #include "ad_ntfs.h"
00008 #include "adio_extern.h"
00009
00010 void ADIOI_NTFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code)
00011 {
00012 DWORD err;
00013 LONG dwTemp;
00014 static char myname[] = "ADIOI_NTFS_FCNTL";
00015
00016 switch(flag)
00017 {
00018 case ADIO_FCNTL_GET_FSIZE:
00019 fcntl_struct->fsize = SetFilePointer(fd->fd_sys, 0, 0, FILE_END);
00020 if (fd->fp_sys_posn != -1)
00021 {
00022 dwTemp = DWORDHIGH(fd->fp_sys_posn);
00023 if (SetFilePointer(fd->fd_sys, DWORDLOW(fd->fp_sys_posn), &dwTemp, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
00024 {
00025 char errMsg[ADIOI_NTFS_ERR_MSG_MAX];
00026 err = GetLastError();
00027 ADIOI_NTFS_Strerror(err, errMsg, ADIOI_NTFS_ERR_MSG_MAX);
00028 if (err != NO_ERROR)
00029 {
00030 *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00031 myname, __LINE__, MPI_ERR_IO,
00032 "**io", "**io %s", errMsg);
00033 return;
00034 }
00035 }
00036 }
00037
00038 if (fcntl_struct->fsize == INVALID_SET_FILE_POINTER)
00039 {
00040 char errMsg[ADIOI_NTFS_ERR_MSG_MAX];
00041 dwTemp = GetLastError();
00042 ADIOI_NTFS_Strerror(dwTemp, errMsg, ADIOI_NTFS_ERR_MSG_MAX);
00043 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00044 MPIR_ERR_RECOVERABLE, myname,
00045 __LINE__, MPI_ERR_IO, "**io",
00046 "**io %s", errMsg);
00047 return;
00048 }
00049
00050 *error_code = MPI_SUCCESS;
00051 break;
00052
00053 case ADIO_FCNTL_SET_DISKSPACE:
00054 ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code);
00055 break;
00056
00057 case ADIO_FCNTL_SET_ATOMICITY:
00058 fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
00059 *error_code = MPI_SUCCESS;
00060
00061
00062
00063
00064 break;
00065
00066 default:
00067
00068 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00069 MPIR_ERR_RECOVERABLE,
00070 myname, __LINE__,
00071 MPI_ERR_ARG,
00072 "**flag", "**flag %d", flag);
00073 return;
00074
00075 }
00076 }