buse/busexmp.c

55 lines
1.0 KiB
C
Raw Normal View History

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "buse.h"
2011-09-20 10:31:35 +02:00
2011-10-10 07:30:30 +02:00
static void *data;
static int xmp_read(void *buf, u_int32_t len, u_int64_t offset)
2011-09-20 10:31:35 +02:00
{
2012-12-03 00:25:06 +01:00
fprintf(stderr, "R - %lu, %u\n", offset, len);
memcpy(buf, (char *)data + offset, len);
return 0;
}
2011-10-10 07:30:30 +02:00
static int xmp_write(const void *buf, u_int32_t len, u_int64_t offset)
{
2012-12-03 00:25:06 +01:00
fprintf(stderr, "W - %lu, %u\n", offset, len);
memcpy((char *)data + offset, buf, len);
return 0;
2011-10-10 07:30:30 +02:00
}
2012-12-01 17:08:13 +01:00
static void xmp_disc()
{
2012-12-03 00:25:06 +01:00
fprintf(stderr, "Received a disconnect request.\n");
2012-11-30 16:42:29 +01:00
}
static int xmp_flush()
{
fprintf(stderr, "Received a flush request.\n");
return 0;
}
2012-12-03 00:25:06 +01:00
static int xmp_trim(u_int64_t from, u_int32_t len){
fprintf(stderr, "T - %lu, %u\n", from, len);
return 0;
}
static struct buse_operations aop = {
2012-12-03 00:25:06 +01:00
.read = xmp_read,
.write = xmp_write,
.disc = xmp_disc,
.flush = xmp_flush,
2012-11-30 16:42:29 +01:00
.trim = xmp_trim,
2012-12-03 00:25:06 +01:00
.size = 128 * 1024 * 1024,
};
int main(int argc, char *argv[])
{
2012-12-03 00:25:06 +01:00
data = malloc(aop.size);
2011-10-10 07:30:30 +02:00
2012-12-03 00:25:06 +01:00
return buse_main(argc, argv, &aop, NULL);
2011-09-20 10:31:35 +02:00
}