1 #include "filesys-stub.h"
9 static struct lock lock;
12 filesys_stub_init (void)
14 lock_init (&lock, "filesys-stub");
18 filesys_stub_lock (void)
24 filesys_stub_unlock (void)
30 out_byte (uint8_t byte, void *aux UNUSED)
36 filesys_stub_put_bool (bool b)
38 backdoor_put_bool (b, out_byte, NULL);
42 filesys_stub_put_bytes (const void *buffer, size_t cnt)
44 backdoor_put_bytes (buffer, cnt, out_byte, NULL);
48 filesys_stub_put_file (struct file *file)
50 ASSERT (file != NULL);
51 filesys_stub_put_int32 ((int32_t) file - 1);
55 filesys_stub_put_int32 (int32_t value)
57 backdoor_put_int32 (value, out_byte, NULL);
61 filesys_stub_put_string (const char *string)
63 backdoor_put_string (string, out_byte, NULL);
67 filesys_stub_put_uint32 (uint32_t value)
69 backdoor_put_uint32 (value, out_byte, NULL);
73 in_byte (void *aux UNUSED)
79 filesys_stub_get_bool (void)
81 return backdoor_get_bool (in_byte, NULL);
85 filesys_stub_get_bytes (void *buffer, size_t size)
87 backdoor_get_bytes (buffer, size, in_byte, NULL);
91 filesys_stub_get_file (void)
93 int32_t fd = filesys_stub_get_int32 ();
94 return fd < 0 ? NULL : (struct file *) (fd + 1);
98 filesys_stub_get_int32 (void)
100 return backdoor_get_int32 (in_byte, NULL);
104 filesys_stub_match_string (const char *string)
106 if (backdoor_get_uint32 (in_byte, NULL) != strlen (string))
107 panic ("string match failed");
108 while (*string != '\0')
110 uint8_t c = *string++;
111 if (c != in_byte (NULL))
112 panic ("string match failed");
117 filesys_stub_get_uint32 (void)
119 return backdoor_get_uint32 (in_byte, NULL);