diff options
author | Mattias Andrée <maandree@kth.se> | 2021-09-04 11:38:03 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-09-04 11:38:03 +0200 |
commit | f467f59897f330d2a493e919108e62dffaa1f736 (patch) | |
tree | a93237eb61591401b481e47b2aaa9dc92042be1a /common.h | |
parent | m (diff) | |
download | editasroot-f467f59897f330d2a493e919108e62dffaa1f736.tar.gz editasroot-f467f59897f330d2a493e919108e62dffaa1f736.tar.bz2 editasroot-f467f59897f330d2a493e919108e62dffaa1f736.tar.xz |
Communicate whether file transfers were completed
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/common.h b/common.h new file mode 100644 index 0000000..ac73c43 --- /dev/null +++ b/common.h @@ -0,0 +1,34 @@ +/* See LICENSE file for copyright and license details. */ +#include <sys/prctl.h> +#include <sys/socket.h> +#include <sys/wait.h> +#include <errno.h> +#include <fcntl.h> +#include <paths.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <termios.h> +#include <unistd.h> + +/* We need at least 2 bytes we are sending 1 addition byte in each chunk */ +#if BUFSIZ < 2 +# undef BUFSIZ +# define BUFSIZ 2 +#endif + +/* We impose a limit because PF_UNIX/SOCK_SEQPACKET can block if sending + * too much (I don't know the exact limit and it can change), without + * first setting up a socket options, which is overkill for this application, + * and there is also a hard limit just above 210000B for each EMSGSIZE will + * be thrown. */ +#if BUFSIZ > (8 << 10) +# undef BUFSIZ +# define BUFSIZ (8 << 10) +#endif + + +extern const char *argv0; + +void copy_file(int destfd, const char *destfname, int srcfd, const char *srcfname, int *okp); |