+ off_t off;
+#ifdef HAVE_LINUX_SENDFILE
+ off_t size;
+#endif
+
+ off = slot->keylen + 1;
+
+#ifdef HAVE_LINUX_SENDFILE
+ size = slot->cache_st.st_size;
+
+ do {
+ ssize_t ret;
+ ret = sendfile(STDOUT_FILENO, slot->cache_fd, &off, size - off);
+ if (ret < 0) {
+ if (errno == EAGAIN || errno == EINTR)
+ continue;
+ /* Fall back to read/write on EINVAL or ENOSYS */
+ if (errno == EINVAL || errno == ENOSYS)
+ break;
+ return errno;
+ }
+ if (off == size)
+ return 0;
+ } while (1);
+#endif