X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=linux-tests%2Fwritebigsparse.c;h=9f95d2418d7c875e3cf5f25e19e8c8d6ee9b5913;hp=fab2d168727dd98a6ec0cdf789be019a5ee36205;hb=236044674b17ac4455b44cb4bdb0ea99107d9a99;hpb=0ed6086affa15e1537da1b16d2ab3af654713a15;ds=sidebyside diff --git a/linux-tests/writebigsparse.c b/linux-tests/writebigsparse.c index fab2d16..9f95d24 100644 --- a/linux-tests/writebigsparse.c +++ b/linux-tests/writebigsparse.c @@ -6,31 +6,31 @@ #include #include -int handle; -#define N_WRITES 8000 -#define STRIDE 1000 +#define N_WRITES 2000 +#define STRIDE 2000 -#define BUFFER_N 2000 -unsigned buffer[BUFFER_N]; +#define BUFFER_N 1100 +unsigned xxbuffer[BUFFER_N]; void set_buffer(int n) { int i; for(i = 0; i < BUFFER_N; i++) - buffer[i] = i + n; + xxbuffer[i] = i + n; } void write_big_sparse_file(int h) { int i; - off64_t offset = 0; - off64_t pos; - int n = sizeof(buffer); + loff_t offset = 0; + loff_t pos; + int n = sizeof(xxbuffer); int wrote; - - for(i = 0; i < 4000; i++) { + + for(i = 0; i < N_WRITES; i++) { + printf("writing at %lld\n", offset); set_buffer(i); pos = lseek64(h, offset, SEEK_SET); if(pos != offset) { @@ -39,43 +39,39 @@ void write_big_sparse_file(int h) perror("lseek64"); exit(1); } - wrote = write(h, buffer, n); - + wrote = write(h, xxbuffer, n); + if(wrote != n) { printf("mismatched write wrote %d n %d\n", wrote, n); exit(1); } - - offset += (STRIDE * sizeof(buffer)); - } -} - + offset += (STRIDE * sizeof(xxbuffer)); + } + ftruncate(h, offset); -void verify_big_sparse_file(int h) -{ } + int main(int argc, char *argv[]) { + int handle; if(argc < 2) { printf("Gimme a file name!\n"); exit(1); } - + handle = open(argv[1], O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE); - + if(handle < 0) { perror("opening file"); exit(1); } - + write_big_sparse_file(handle); - system("sudo echo 3 > /proc/sys/vm/drop_caches"); - verify_big_sparse_file(handle); - + printf("Job done\n"); return 0; }