projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added some comments to dtest.c
[yaffs2.git]
/
linux-tests
/
writebigsparse.c
diff --git
a/linux-tests/writebigsparse.c
b/linux-tests/writebigsparse.c
index fab2d168727dd98a6ec0cdf789be019a5ee36205..aeb2535551b379ee96dd5e0dcf4a5c3892bcbc44 100644
(file)
--- a/
linux-tests/writebigsparse.c
+++ b/
linux-tests/writebigsparse.c
@@
-6,31
+6,31
@@
#include <unistd.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdlib.h>
-int handle;
-#define N_WRITES
8000
-#define STRIDE
1
000
+#define N_WRITES
16
+#define STRIDE
250
000
-#define BUFFER_N
20
00
-unsigned buffer[BUFFER_N];
+#define BUFFER_N
11
00
+unsigned
xx
buffer[BUFFER_N];
void set_buffer(int n)
{
int i;
for(i = 0; i < BUFFER_N; i++)
void set_buffer(int n)
{
int i;
for(i = 0; i < BUFFER_N; i++)
- buffer[i] = i + n;
+
xx
buffer[i] = i + n;
}
void write_big_sparse_file(int h)
{
int i;
}
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(
xx
buffer);
int wrote;
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) {
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);
}
perror("lseek64");
exit(1);
}
- wrote = write(h, buffer, n);
-
+ wrote = write(h,
xx
buffer, n);
+
if(wrote != n) {
printf("mismatched write wrote %d n %d\n", wrote, n);
exit(1);
}
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 main(int argc, char *argv[])
{
+ int handle;
if(argc < 2) {
printf("Gimme a file name!\n");
exit(1);
}
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);
handle = open(argv[1], O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
-
+
if(handle < 0) {
perror("opening file");
exit(1);
}
if(handle < 0) {
perror("opening file");
exit(1);
}
-
+
write_big_sparse_file(handle);
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;
}
printf("Job done\n");
return 0;
}