mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-05 05:12:00 +00:00
These tests perform common FS operations in various ways: - open/close - read/write - create/delete - read/change size - seek/tell - memory-mapped read/write - copy directory in different ways Tests use both direct syscalls and stdio wrappers (FILE). To run, call `make test` in `LibOS/shim/test/fs`.
22 lines
568 B
C
22 lines
568 B
C
#include "common.h"
|
|
|
|
void copy_data(int fi, int fo, const char* input_path, const char* output_path, size_t size) {
|
|
size_t max_step = 16;
|
|
if (size > 65536)
|
|
max_step = 256;
|
|
|
|
void* data = alloc_buffer(max_step);
|
|
ssize_t offset = 0;
|
|
ssize_t step;
|
|
while (offset < size) {
|
|
if (offset + max_step <= size)
|
|
step = rand() % max_step + 1;
|
|
else
|
|
step = size - offset;
|
|
read_fd(input_path, fi, data, step);
|
|
write_fd(output_path, fo, data, step);
|
|
offset += step;
|
|
}
|
|
free(data);
|
|
}
|