2011-11-17 20:19:09 +01:00
|
|
|
#include <stdio.h>
|
2011-09-20 11:30:00 +02:00
|
|
|
#include <stdlib.h>
|
2011-09-20 22:37:47 +02:00
|
|
|
#include <string.h>
|
2011-09-20 11:30:00 +02:00
|
|
|
|
2011-10-10 08:20:39 +02:00
|
|
|
#include "buse.h"
|
2011-09-20 10:31:35 +02:00
|
|
|
|
2011-10-10 07:30:30 +02:00
|
|
|
static void *data;
|
|
|
|
|
2011-09-20 22:37:47 +02:00
|
|
|
static int xmp_read(void *buf, u_int32_t len, u_int64_t offset)
|
2011-09-20 10:31:35 +02:00
|
|
|
{
|
2011-11-15 23:44:38 +01:00
|
|
|
memcpy(buf, (char *)data + offset, len);
|
2011-09-20 22:37:47 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2011-09-20 12:32:13 +02:00
|
|
|
|
2011-10-10 07:30:30 +02:00
|
|
|
static int xmp_write(const void *buf, u_int32_t len, u_int64_t offset)
|
|
|
|
{
|
|
|
|
memcpy((char *)data + offset, buf, len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-17 20:19:09 +01:00
|
|
|
static int xmp_disc()
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Received a disconnect request.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-10 08:20:39 +02:00
|
|
|
static struct buse_operations aop = {
|
2011-09-20 22:37:47 +02:00
|
|
|
.read = xmp_read,
|
2011-10-10 07:30:30 +02:00
|
|
|
.write = xmp_write,
|
2011-11-17 20:19:09 +01:00
|
|
|
.disc = xmp_disc,
|
|
|
|
.size = 128 * 1024 * 1024,
|
2011-09-20 22:37:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2011-10-10 07:30:30 +02:00
|
|
|
data = malloc(aop.size);
|
|
|
|
|
2011-10-10 08:20:39 +02:00
|
|
|
return buse_main(argc, argv, &aop, NULL);
|
2011-09-20 10:31:35 +02:00
|
|
|
}
|