From e19390ca1cefc49247b8a25945c8acc14f8af3bc Mon Sep 17 00:00:00 2001 From: Rafal Wojtczuk Date: Fri, 11 Mar 2011 11:47:20 +0100 Subject: [PATCH] Moved ioall.c file to "common" --- {qrexec => common}/ioall.c | 6 ------ common/ioall.h | 2 ++ qrexec/Makefile | 15 ++++++++------- qrexec/glue.h | 3 --- qrexec/qrexec_agent.c | 6 ++++++ qrexec/qrexec_client.c | 1 + qrexec/qrexec_daemon.c | 7 +++++++ 7 files changed, 24 insertions(+), 16 deletions(-) rename {qrexec => common}/ioall.c (93%) create mode 100644 common/ioall.h diff --git a/qrexec/ioall.c b/common/ioall.c similarity index 93% rename from qrexec/ioall.c rename to common/ioall.c index 9e8d7a3c..ce550c7e 100644 --- a/qrexec/ioall.c +++ b/common/ioall.c @@ -59,9 +59,3 @@ int read_all(int fd, void *buf, int size) // fprintf(stderr, "read %d bytes\n", size); return 1; } - -void set_nonblock(int fd) -{ - int fl = fcntl(fd, F_GETFL, 0); - fcntl(fd, F_SETFL, fl | O_NONBLOCK); -} diff --git a/common/ioall.h b/common/ioall.h new file mode 100644 index 00000000..1e76353e --- /dev/null +++ b/common/ioall.h @@ -0,0 +1,2 @@ +int write_all(int fd, void *buf, int size); +int read_all(int fd, void *buf, int size); diff --git a/qrexec/Makefile b/qrexec/Makefile index b87b09d6..d4a5c857 100644 --- a/qrexec/Makefile +++ b/qrexec/Makefile @@ -1,13 +1,14 @@ CC=gcc -CFLAGS+=-g -Wall -I../vchan +CFLAGS+=-g -Wall -I../vchan -I../common XENLIBS=-lvchan -lxenstore -lxenctrl +COMMONIOALL=../common/ioall.o all: qrexec_daemon qrexec_agent qrexec_client -qrexec_daemon: qrexec_daemon.o unix_server.o ioall.o txrx-vchan.o buffer.o write_stdin.o - $(CC) -g -o qrexec_daemon qrexec_daemon.o unix_server.o ioall.o txrx-vchan.o write_stdin.o buffer.o $(XENLIBS) -qrexec_agent: qrexec_agent.o ioall.o exec.o txrx-vchan.o write_stdin.o buffer.o - $(CC) -g -o qrexec_agent qrexec_agent.o ioall.o exec.o txrx-vchan.o write_stdin.o buffer.o $(XENLIBS) -qrexec_client: qrexec_client.o ioall.o exec.o - $(CC) -g -o qrexec_client qrexec_client.o ioall.o exec.o +qrexec_daemon: qrexec_daemon.o unix_server.o $(COMMONIOALL) txrx-vchan.o buffer.o write_stdin.o + $(CC) -g -o qrexec_daemon qrexec_daemon.o unix_server.o $(COMMONIOALL) txrx-vchan.o write_stdin.o buffer.o $(XENLIBS) +qrexec_agent: qrexec_agent.o exec.o txrx-vchan.o write_stdin.o buffer.o + $(CC) -g -o qrexec_agent qrexec_agent.o exec.o txrx-vchan.o write_stdin.o buffer.o $(XENLIBS) +qrexec_client: qrexec_client.o $(COMMONIOALL) exec.o + $(CC) -g -o qrexec_client qrexec_client.o $(COMMONIOALL) exec.o clean: rm -f *.o *~ qrexec_daemon qrexec_agent qrexec_client diff --git a/qrexec/glue.h b/qrexec/glue.h index 228b6866..abcad649 100644 --- a/qrexec/glue.h +++ b/qrexec/glue.h @@ -23,8 +23,6 @@ void do_fork_exec(char *cmdline, int *pid, int *stdin_fd, int *stdout_fd, int *stderr_fd); -int write_all(int fd, void *buf, int size); -int read_all(int fd, void *buf, int size); int peer_server_init(int port); char *peer_client_init(int dom, int port); void wait_for_vchan_or_argfd(int max, fd_set * rdset, fd_set * wrset); @@ -36,7 +34,6 @@ void fix_fds(int fdin, int fdout, int fderr); int get_server_socket(int domid); int do_accept(int s); -void set_nonblock(int fd); enum { WRITE_STDIN_OK = 0x200, diff --git a/qrexec/qrexec_agent.c b/qrexec/qrexec_agent.c index ef02ddb1..94cab149 100644 --- a/qrexec/qrexec_agent.c +++ b/qrexec/qrexec_agent.c @@ -142,6 +142,12 @@ void handle_just_exec(int clid, int len) fprintf(stderr, "executed (nowait) %s pid %d\n", buf, pid); } +void set_nonblock(int fd) +{ + int fl = fcntl(fd, F_GETFL, 0); + fcntl(fd, F_SETFL, fl | O_NONBLOCK); +} + void handle_exec(int clid, int len) { char buf[len]; diff --git a/qrexec/qrexec_client.c b/qrexec/qrexec_client.c index e2878480..38271cf8 100644 --- a/qrexec/qrexec_client.c +++ b/qrexec/qrexec_client.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "qrexec.h" #include "buffer.h" #include "glue.h" diff --git a/qrexec/qrexec_daemon.c b/qrexec/qrexec_daemon.c index 9f801983..54077185 100644 --- a/qrexec/qrexec_daemon.c +++ b/qrexec/qrexec_daemon.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "qrexec.h" #include "buffer.h" #include "glue.h" @@ -145,6 +146,12 @@ void pass_to_agent(int fd, struct server_header *s_hdr) write_all_vchan_ext(buf, len); } +void set_nonblock(int fd) +{ + int fl = fcntl(fd, F_GETFL, 0); + fcntl(fd, F_SETFL, fl | O_NONBLOCK); +} + void handle_client_cmdline(int fd) { struct client_header hdr;