This source file includes following definitions.
- ADIOI_XFS_Fcntl
1
2
3
4
5
6
7
8 #include "ad_xfs.h"
9 #include "adio_extern.h"
10 #include <sys/ioctl.h>
11
12 #ifndef HAVE_LSEEK64
13 #define lseek64 lseek
14 #endif
15
16 void ADIOI_XFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code)
17 {
18 int i, err;
19 #if defined(LINUX) && defined(MPISGI)
20 struct xfs_flock64 fl;
21 #else
22 struct flock64 fl;
23 #endif
24 static char myname[] = "ADIOI_XFS_FCNTL";
25
26 switch(flag) {
27 case ADIO_FCNTL_GET_FSIZE:
28 fcntl_struct->fsize = lseek64(fd->fd_sys, 0, SEEK_END);
29 if (fcntl_struct->fsize == -1) {
30 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
31 MPIR_ERR_RECOVERABLE, myname,
32 __LINE__, MPI_ERR_IO, "**io",
33 "**io %s", strerror(errno));
34 }
35 else *error_code = MPI_SUCCESS;
36 break;
37
38 case ADIO_FCNTL_SET_DISKSPACE:
39 i = 0;
40 fl.l_start = 0;
41 fl.l_whence = SEEK_SET;
42 fl.l_len = fcntl_struct->diskspace;
43
44 #if defined(LINUX) && defined(MPISGI)
45 err = ioctl(fd->fd_sys, XFS_IOC_RESVSP64, &fl);
46 #else
47 err = fcntl(fd->fd_sys, F_RESVSP64, &fl);
48 #endif
49
50 if (err) i = 1;
51 if (fcntl_struct->diskspace > lseek64(fd->fd_sys, 0, SEEK_END)) {
52
53 err = ftruncate64(fd->fd_sys, fcntl_struct->diskspace);
54 if (err) i = 1;
55 }
56
57 if (i == 1) {
58 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
59 MPIR_ERR_RECOVERABLE, myname,
60 __LINE__, MPI_ERR_IO, "**io",
61 "**io %s", strerror(errno));
62 }
63 else *error_code = MPI_SUCCESS;
64 break;
65
66 case ADIO_FCNTL_SET_ATOMICITY:
67 fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
68 *error_code = MPI_SUCCESS;
69 break;
70
71 default:
72
73 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
74 MPIR_ERR_RECOVERABLE,
75 myname, __LINE__,
76 MPI_ERR_ARG,
77 "**flag", "**flag %d", flag);
78 return;
79
80 }
81 }