~ubuntu-branches/ubuntu/hardy/openmpi/hardy-updates

« back to all changes in this revision

Viewing changes to ompi/mca/io/romio/romio/adio/ad_ntfs/io_romio_ad_ntfs_fcntl.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2006-10-15 00:46:11 UTC
  • Revision ID: james.westby@ubuntu.com-20061015004611-uuhxnaxyjmuxfd5h
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; c-basic-offset:4 ; -*- */
 
2
/* 
 
3
 *   Copyright (C) 1997 University of Chicago. 
 
4
 *   See COPYRIGHT notice in top-level directory.
 
5
 */
 
6
 
 
7
#include "ad_ntfs.h"
 
8
#include "adio_extern.h"
 
9
 
 
10
void ADIOI_NTFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code)
 
11
{
 
12
    DWORD err;
 
13
    LONG dwTemp;
 
14
    static char myname[] = "ADIOI_NTFS_FCNTL";
 
15
 
 
16
    switch(flag)
 
17
    {
 
18
    case ADIO_FCNTL_GET_FSIZE:
 
19
        fcntl_struct->fsize = SetFilePointer(fd->fd_sys, 0, 0, FILE_END);
 
20
        if (fd->fp_sys_posn != -1) 
 
21
        {
 
22
            dwTemp = DWORDHIGH(fd->fp_sys_posn);
 
23
            if (SetFilePointer(fd->fd_sys, DWORDLOW(fd->fp_sys_posn), &dwTemp, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
 
24
            {
 
25
                err = GetLastError();
 
26
                if (err != NO_ERROR)
 
27
                {
 
28
                    *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
 
29
                        myname, __LINE__, MPI_ERR_IO,
 
30
                        "**io", "**io %s", ADIOI_NTFS_Strerror(err));
 
31
                    return;
 
32
                }
 
33
            }
 
34
        }
 
35
        /* --BEGIN ERROR HANDLING-- */
 
36
        if (fcntl_struct->fsize == INVALID_SET_FILE_POINTER)
 
37
        {
 
38
            dwTemp = GetLastError();
 
39
            *error_code = MPIO_Err_create_code(MPI_SUCCESS,
 
40
                                               MPIR_ERR_RECOVERABLE, myname,
 
41
                                               __LINE__, MPI_ERR_IO, "**io",
 
42
                                               "**io %s", ADIOI_NTFS_Strerror(dwTemp));
 
43
            return;
 
44
        }
 
45
        /* --END ERROR HANDLING-- */
 
46
        *error_code = MPI_SUCCESS;
 
47
        break;
 
48
 
 
49
    case ADIO_FCNTL_SET_DISKSPACE:
 
50
        ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code);
 
51
        break;
 
52
 
 
53
    case ADIO_FCNTL_SET_ATOMICITY:
 
54
        fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
 
55
        *error_code = MPI_SUCCESS;
 
56
        /*
 
57
        fd->atomicity = 0;
 
58
        *error_code = MPI_ERR_UNSUPPORTED_OPERATION;
 
59
        */
 
60
        break;
 
61
 
 
62
    default:
 
63
        /* --BEGIN ERROR HANDLING-- */
 
64
        *error_code = MPIO_Err_create_code(MPI_SUCCESS,
 
65
                                           MPIR_ERR_RECOVERABLE,
 
66
                                           myname, __LINE__,
 
67
                                           MPI_ERR_ARG,
 
68
                                           "**flag", "**flag %d", flag);
 
69
        return;
 
70
        /* --END ERROR HANDLING-- */
 
71
    }
 
72
}