diff --git a/configure.ac b/configure.ac index 6b64488..81fab2f 100644 --- a/configure.ac +++ b/configure.ac @@ -32,7 +32,7 @@ PKG_CHECK_MODULES([FUSE], [fuse3 >= 3.2.1], [AC_DEFINE([HAVE_FUSE], 1, [Define i AC_FUNC_ERROR_AT_LINE AC_FUNC_MALLOC -AC_CHECK_FUNCS([memset strdup]) +AC_CHECK_FUNCS([open_by_handle_at error memset strdup]) AC_CONFIG_FILES([Makefile lib/Makefile]) AC_OUTPUT diff --git a/main.c b/main.c index 713cf4d..2fab283 100644 --- a/main.c +++ b/main.c @@ -36,7 +36,23 @@ #include #include #include -#include + +#ifdef HAVE_ERROR_H +# include +#else +# define error(status, errno, fmt, ...) do { \ + if (errno == 0) \ + fprintf (stderr, "crun: " fmt "\n", ##__VA_ARGS__); \ + else \ + { \ + fprintf (stderr, "crun: " fmt, ##__VA_ARGS__); \ + fprintf (stderr, ": %s\n", strerror (errno)); \ + } \ + if (status) \ + exit (status); \ + } while(0) +#endif + #include #include #include @@ -57,6 +73,32 @@ #include +#ifndef TEMP_FAILURE_RETRY +#define TEMP_FAILURE_RETRY(expression) \ + (__extension__ \ + ({ long int __result; \ + do __result = (long int) (expression); \ + while (__result == -1L && errno == EINTR); \ + __result; })) +#endif + + +#ifndef HAVE_OPEN_BY_HANDLE_AT +struct file_handle +{ + unsigned int handle_bytes; /* Size of f_handle [in, out] */ + int handle_type; /* Handle type [out] */ + unsigned char f_handle[0]; /* File identifier (sized by + caller) [out] */ +}; + +int +open_by_handle_at (int mount_fd, struct file_handle *handle, int flags) +{ + return syscall (SYS_open_by_handle_at, mount_fd, handle, flags); +} +#endif + #ifndef RENAME_EXCHANGE # define RENAME_EXCHANGE (1 << 1) # define RENAME_NOREPLACE (1 << 2)