/* * Copyright (c) 1996 The University of Utah and * the Computer Systems Laboratory at the University of Utah (CSL). * * This file is part of Flick, the Flexible IDL Compiler Kit. * * Flick is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Flick is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Flick; see the file COPYING. If not, write to * the Free Software Foundation, 59 Temple Place #330, Boston, MA 02111, USA. */ #include "yfs.h" #include "ops.h" #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif extern int random(); extern int srandom(int); #ifdef __cplusplus } #endif #if defined(__svr4__) #define random rand #define srandom(x) srand(x) #endif /* Set to FSCK if you have a fs check routine called yfs_fsck() */ #define NOFSCK /* Set to RANDOMOFFSETS to do reads from random offsets */ #define NORANDOMOFFSETS /* Number of items to generate (~1/3 will be directories) */ #define MAXITEMS 50 /* Number of writes to perform during the writes phase */ #define NUMWRITES 250 /* Maximum write size */ #define BLOCKSIZ 1000 #define ISGONE 0 #define ISDIR 1 #define ISFILE 2 #define MAXSIZE 10240 struct thing { char *pn; int whatisit; int maxoffset; int children; int parent; int num; } genedpathname[MAXITEMS+1]; int getdiroffset(char *pn) { int i; for (i=strlen(pn);i>=0;i--) { if (pn[i]=='/') return i; } printf("Error: pathname is not absolute!"); return -1; } #define CREATE 0 /* #define DELETE 1 #define WRITE 2 */ #define ADIRECTORY 0 #define AFILE 1 void GenData(char *data, int num, int offset, int amount) { int data2[BLOCKSIZ/4+1]; int data2offset=(offset/4)*4; int i; for (i=0; iMAXSIZE) ? MAXSIZE-curbs : curoffset; printf(" Try to write %d bytes at offset %d\n", curbs,curoffset); GenData(buf,genedpathname[item].num,curoffset,curbs); if (do_op(genedpathname[item].pn,WRITE,AFILE,curoffset, buf,curbs,&actualbs)) { printf("failed with rc=%d\n", rc); } if ((actualbs>0) && (actualbs+curoffset>genedpathname[item].maxoffset)) { genedpathname[item].maxoffset=actualbs+curoffset; } if (actualbs!=curbs) { printf("ERROR: Actually wrote %d bytes\n", actualbs); } #ifdef FSCK if ((rc=yfs_fsck())) { printf("ERROR: yfs_fsck returned %d\n", rc); } #endif } printf("Now doing sequential reads on %d files with readsize=%d\n", MAXITEMS,BLOCKSIZ); for (item=0;item0)); } else { for (item=1; item<=MAXITEMS; item++) if (genedpathname[item].whatisit!=ISGONE && genedpathname[item].children==0) break; } /* Now we have a random item */ genedpathname[genedpathname[item].parent].children--; printf("Deleting #%d %s - '%s'\n", i, genedpathname[item].whatisit==ISDIR ? "DIR " : "FILE", genedpathname[item].pn); if (genedpathname[item].whatisit==ISDIR) { if (do_op(genedpathname[item].pn,DELETE,ADIRECTORY,0,0,0,0)) { printf("ERROR: Delete failed - check why!\n"); } } else { if (do_op(genedpathname[item].pn,DELETE,AFILE,0,0,0,0)) { printf("ERROR: Delete failed - check why!\n"); } } genedpathname[item].whatisit=ISGONE; ++i; #ifdef FSCK if ((rc=yfs_fsck())) { printf("ERROR: yfs_fsck returned %d\n", rc); } #endif } puts("Done"); exit(0); }