public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: sendfile(2) behaviour has changed?
@ 2002-10-20  9:50 Dan Maas
  2002-10-24 22:37 ` Jamie Lokier
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Maas @ 2002-10-20  9:50 UTC (permalink / raw)
  To: davem; +Cc: linux-kernel

>> It really needs a new interface for recvfile/copyfile/whatever
>> anyway, as you can only specify an off_t for the from fd at
>> present.
>   
> Ummm, you can use lseek() on the 'to' fd perhaps?

Wouldn't that be non-atomic and therefore likely to cause problems
with concurrent writes?

Regards,
Dan

^ permalink raw reply	[flat|nested] 9+ messages in thread
* sendfile(2) behaviour has changed ?
@ 2002-10-16  8:49 Zilvinas Valinskas
  2002-10-16  9:10 ` Matti Aarnio
  0 siblings, 1 reply; 9+ messages in thread
From: Zilvinas Valinskas @ 2002-10-16  8:49 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

This sample code copies a file using sendfile(2) call works just fine on 
2.2.x and 2.4.x kernels. On 2.5.x kernels (not sure starting which
version) it stopped working. Program terminates with EINVAL error. 

$ ./sendfile
sendfile: Invalid argument

Is this expected behaviour ? that sendfile(2) on 2.5.4x linux kernel requires
socket as an output fd paramter ? 

Was it ever legal to copy file(s) on filesystem using sendfile(2) ?
(which was kindda nice feature ... )

[-- Attachment #2: sendfile.c --]
[-- Type: text/x-csrc, Size: 642 bytes --]

#include <sys/sendfile.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main() 
{
	int fd_in  = 0;
	int fd_out = 0;
	struct stat stat_buf;
	off_t  offset = 0;
	ssize_t count = 0;

	if ((fd_in=open("sendfile.c",O_RDONLY))<0)
	{
		perror("open");
		exit(1);
	}
	if ((fd_out=open("sendfile.out",O_CREAT|O_TRUNC|O_WRONLY,S_IRWXU))<0)
	{
		perror("open");
		exit(1);
	}

	if (fstat(fd_in,&stat_buf)) {
		perror("fstat");
	}


	count = sendfile(fd_out,fd_in,&offset,stat_buf.st_size);

	if (count < 0)
		perror("sendfile");
	
	if (close(fd_in) < 0)
		perror("close");
	if (close(fd_out) < 0)
		perror("close");
	return 0;
}


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-10-24 22:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-20  9:50 sendfile(2) behaviour has changed? Dan Maas
2002-10-24 22:37 ` Jamie Lokier
  -- strict thread matches above, loose matches on Subject: below --
2002-10-16  8:49 sendfile(2) behaviour has changed ? Zilvinas Valinskas
2002-10-16  9:10 ` Matti Aarnio
2002-10-16  9:59   ` David S. Miller
2002-10-16 10:25     ` bert hubert
2002-10-17 20:51     ` James Antill
2002-10-17 22:41       ` David S. Miller
2002-10-17 23:23         ` James Antill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox