1
/* @(#)ben_write.c 19.1 (ES0-DMD) 02/25/03 14:35:21 */
2
/*===========================================================================
3
Copyright (C) 1995 European Southern Observatory (ESO)
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License as
7
published by the Free Software Foundation; either version 2 of
8
the License, or (at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public
16
License along with this program; if not, write to the Free
17
Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
20
Corresponding concerning ESO-MIDAS should be addressed as follows:
21
Internet e-mail: midas@eso.org
22
Postal address: European Southern Observatory
23
Data Management Division
24
Karl-Schwarzschild-Strasse 2
25
D 85748 Garching bei Muenchen
27
===========================================================================*/
29
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33
.AUTHOR CARLOS GUIRAO- IPG-ESO Garching
34
.CATEGORY OS benchmarks. Disk write benchmark.
35
.COMMENTS This benchmark checks the disk write time through
38
.REMARKS This benchmark must run before running the ben_dread
40
.REMARKS This benchmarck is included in the shell script: "brun".
41
.REMARKS Use the "make" command to update the benchmark.
42
.VERSION 1.0 10-Feb-1988 Implementation CGS
43
------------------------------------------------------------*/
53
/* #define BLOCKS 256 */
56
/* Size File: BLOCKS*BLKSIZE 10000*2048 = 20MBytes */
59
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
60
.PURPOSE Write data on disc.
61
.RETURNS Upon succesful execution of the command 0 status is
62
returned, or 1 in case of error.
63
.REMARKS This benchmark must run before running the ben_rread
64
o ben_sread benchmark.
65
.REMARKS System dependencies:
66
OS: osfcreate(), osdopen(), osdclose(), osdwrite();
67
------------------------------------------------------------------*/
71
int osfcreate(), osdopen(), osdclose();
79
printf("Usage: %s filename\n",argv[0]);
83
if (osfcreate(argv[1], sizeof(buffer)*BLOCKS, 0640) < 0) {
84
printf("OSFCREATE FAILED.\n");
88
if ((fildes = osdopen(argv[1],READ_WRITE)) < 0) {
89
printf("OSDOPEN FAILED.\n");
94
for (i=0 ; i<BLOCKS; i++) {
95
if (osdwrite(fildes, buffer, sizeof(buffer)) < 0) {
96
printf("OSDWRITE FAILED BLOCK %d\n",i);
101
if (fsync(fildes) < 0) {
102
printf("FSYNC FAILED.\n");
106
if (osdclose(fildes) < 0) {
107
printf("OSDCLOSE FAILED.\n");