computing-offload/qtfs/demo/cfifo_w.c
Yikun Jiang a68570b5d9 Add computing offloading code
1. Add computing offloading code
2. Add script.md
3. Add virsh_demo.xml

Change-Id: Id9ef883e2f0eb727eb5448b9d1c47767f46b1021
Signed-off-by: Yikun Jiang <yikunkero@gmail.com>
2023-10-23 19:29:57 +08:00

31 lines
501 B
C

#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#define BUF_MAX 256
int main(int argc, char *argv[])
{
char buf[BUF_MAX];
char *fifo = argv[1];
int wfd = open(fifo, O_WRONLY);
if (wfd < 0) {
printf("open file %s failed.\n", fifo);
return 0;
}
do {
int ret;
int len;
memset(buf, 0, BUF_MAX);
fgets(buf, BUF_MAX, stdin);
len = strlen(buf);
ret = write(wfd, buf, BUF_MAX);
if (ret == -1) {
break;
}
} while (strcmp(buf, "exit") != 0);
close(wfd);
return 0;
}