Bug#480354: sendfile support missing in aufs
Package: linux-image-2.6.24-1-amd64
Severity: important
aufs no longer has the sendfile capability, which seems to be
because the kernel is missing a patch, that is needed for 2.6.23+ kernels.
( http://aufs.cvs.sourceforge.net/aufs/aufs/patch/splice-2.6.23.patch?view=markup )
The function returns with 'Invalid argument' if I try to use it
on an aufs filesystem. The last working kernel is 2.6.22-3.
Tests were made with lighttpd and a small test program (attached).
-- Package-specific info:
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.22-3-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
/*
* SENDFILE TEST
*
* mkdir -p /tmp/aufs /tmp/aufs1; echo "test" > /tmp/aufs1/test.txt; mount -t aufs none /tmp/aufs -o rw,br:/tmp/aufs1
*
* ./sendfile-test2 /tmp/aufs/test.txt
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/sendfile.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <netinet/in.h>
int main(int argc, char **argv)
{
int port = 54321, sock_srv, sock_clnt, fd, addrlen;
struct sockaddr_in addr; off_t offset = 0;
char buf[1];
if (argc!=2) { printf("Usage: %s <file-on-aufs>\n", argv[0]); }
if ( (sock_srv = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { fprintf(stderr, "server socket error: %s\n", strerror(errno)); exit(1); }
memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr("127.0.0.1"); addr.sin_port = htons(port);
if ( bind(sock_srv, (struct sockaddr *)&addr, sizeof(addr)) == -1 ) { fprintf(stderr, "server bind error: %s\n", strerror(errno)); exit(1); }
if ( (sock_clnt = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { fprintf(stderr, "client socket error: %s\n", strerror(errno)); exit(1); }
if ( connect(sock_clnt, (struct sockaddr *)&addr, sizeof(addr)) == -1 ) { fprintf(stderr, "client connect error: %s\n", strerror(errno)); exit(1); }
if ( (fd = open(argv[1], O_RDONLY)) == -1) { fprintf(stderr, "open error: %s\n", strerror(errno)); exit(1); }
offset = 0;
if ( sendfile (sock_clnt, fd, &offset, 1) == -1) { fprintf(stderr, "sendfile error: %s\n", strerror(errno)); exit(1); }
if ( read(sock_srv, buf, 1) < 1 ) { fprintf(stderr, "read error: %s\n", strerror(errno)); exit(1); }
printf("sendfile seems OK!\n");
close(fd); close(sock_srv); close(sock_clnt); return 0;
}
Reply to: