2 exec nbdkit cc
"$0" "$@"
7 #define NBDKIT_API_VERSION 2
8 #include <nbdkit-plugin.h>
10 char data
[100*1024*1024];
12 #define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL
15 my_open (int readonly
)
17 return NBDKIT_HANDLE_NOT_NEEDED
;
21 my_get_size (void *handle
)
23 return (int64_t) sizeof (data
);
27 my_pread (void *handle
, void *buf
,
28 uint32_t count
, uint64_t offset
,
31 memcpy (buf
, data
+offset
, count
);
36 my_pwrite (void *handle
, const void *buf
,
37 uint32_t count
, uint64_t offset
,
40 memcpy (data
+offset
, buf
, count
);
44 static struct nbdkit_plugin plugin
= {
47 .get_size
= my_get_size
,
52 NBDKIT_REGISTER_PLUGIN(plugin
)