+/* Verifies that a deleted file may still be written to and read
+ from. */
+
#include <random.h>
#include <string.h>
#include <syscall.h>
void
test_main (void)
{
- const char *filename = "deleteme";
+ const char *file_name = "deleteme";
int fd;
- CHECK (create (filename, sizeof buf1), "create \"%s\"", filename);
- CHECK ((fd = open (filename)) > 1, "open \"%s\"", filename);
- CHECK (remove (filename), "remove \"%s\"", filename);
+ CHECK (create (file_name, sizeof buf1), "create \"%s\"", file_name);
+ CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
+ CHECK (remove (file_name), "remove \"%s\"", file_name);
random_bytes (buf1, sizeof buf1);
- CHECK (write (fd, buf1, sizeof buf1) > 0, "write \"%s\"", filename);
- msg ("seek \"%s\" to 0", filename);
+ CHECK (write (fd, buf1, sizeof buf1) > 0, "write \"%s\"", file_name);
+ msg ("seek \"%s\" to 0", file_name);
seek (fd, 0);
- CHECK (read (fd, buf2, sizeof buf2) > 0, "read \"%s\"", filename);
- compare_bytes (buf2, buf1, sizeof buf1, 0, filename);
- msg ("close \"%s\"", filename);
+ CHECK (read (fd, buf2, sizeof buf2) > 0, "read \"%s\"", file_name);
+ compare_bytes (buf2, buf1, sizeof buf1, 0, file_name);
+ msg ("close \"%s\"", file_name);
close (fd);
}