From 6e8281d86cdb07644c827619b98c8beb5227a839 Mon Sep 17 00:00:00 2001 From: BlaCkinkGJ Date: Wed, 13 Apr 2022 00:04:12 +0900 Subject: [PATCH] support the library ftl --- server/Makefile | 5 +++-- server/usocket_cli.c | 2 +- server/usocket_srv.c | 21 +++++++++++---------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/server/Makefile b/server/Makefile index b82ea27..22b4d08 100644 --- a/server/Makefile +++ b/server/Makefile @@ -1,6 +1,7 @@ CC=gcc -LIBS = -lpthread +LIBS = -lpthread -lftl $(shell pkg-config --libs glib-2.0) +CFLAGS = $(shell pkg-config --cflags glib-2.0) -I/usr/local/include/ftl SERVER_OBJS=usocket_srv.o CLIENT_OBJS=usocket_cli.o @@ -11,7 +12,7 @@ CLIENT_TARGET=usocket_cli all: server client server: $(SERVER_OBJS) - $(CC) -o $(SERVER_TARGET) $(SERVER_OBJS) $(LIBS) + $(CC) $(CFLAGS) -o $(SERVER_TARGET) $(SERVER_OBJS) $(LIBS) client: $(CLIENT_OBJS) $(CC) -o $(CLIENT_TARGET) $(CLIENT_OBJS) diff --git a/server/usocket_cli.c b/server/usocket_cli.c index 80b313b..6a3faec 100644 --- a/server/usocket_cli.c +++ b/server/usocket_cli.c @@ -17,7 +17,7 @@ typedef unsigned short u16; #define READ 0 #define WRITE 1 -char *servip = "192.168.112.4"; +char *servip = "127.0.0.1"; typedef struct { unsigned int op; diff --git a/server/usocket_srv.c b/server/usocket_srv.c index 35eadc1..3ad4c76 100644 --- a/server/usocket_srv.c +++ b/server/usocket_srv.c @@ -9,16 +9,16 @@ #include #include -#define ALLOW_FTL 0 +#define ALLOW_FTL 1 #if ALLOW_FTL -#include "include/module.h" -#include "include/flash.h" -#include "include/page.h" -#include "include/device.h" +#include "module.h" +#include "flash.h" +#include "page.h" +#include "device.h" #endif -#define SERV_DEBUG 0 +#define SERV_DEBUG 1 typedef unsigned long long u64; typedef unsigned short u16; @@ -49,8 +49,9 @@ int recv_packet(int client_fd, packet_t *packet) int len; len = recv(client_fd, packet, sizeof(packet_t), MSG_WAITALL); - if (len != sizeof(packet_t)) - perror("recv failed"); + if (len != sizeof(packet_t)) { + perror("recv packet failed"); + } #if SERV_DEBUG printf("recv packet op(%d) offset(%lu) size(%llu) tag(%u)\n", @@ -139,7 +140,7 @@ void *handle_packet(void *data) goto out; } - fd = open("/mnt/nvme/data_file", O_CREAT | O_RDWR); + fd = open("data_file", O_CREAT | O_RDWR); if (fd < 0) { perror("open error"); free(buffer); @@ -245,7 +246,7 @@ int main() #if ALLOW_FTL module_init(PAGE_FTL_MODULE, &flash, RAMDISK_MODULE); - flash->f_op->open(flash, NULL); + flash->f_op->open(flash, NULL, O_CREAT | O_RDWR); #endif init_server();