Skip to contentSkip to conversation

OT: why no file copy() libc/syscall ??

DISCUSSION Andi Kleen 7 participants 8 messages Nov 18, 2003 – Nov 19, 2003 8 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 20031111085323.M8854@devserv.devel.redhat.com.suse.lists.linux.kernel

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#8 lore raw
Quoted 10 lines · H. Peter Anvin
Quoted 7 lines · Andrea Arcangeli
Quoted 2 lines · H. Peter Anvin

... or we could put in checks into the kernel for signal pending, and return EINTR.

that would be even better indeed.

s/EINTR/short count/, of course :)

That would be buggy because existing users of sendfile don't know about this and would silently only copy part of the file when a signal happens.

-Andi

#9 lore raw
Quoted 5 lines · Andi Kleen
Quoted 1 line

s/EINTR/short count/, of course :)

That would be buggy because existing users of sendfile don't know about this and would silently only copy part of the file when a signal happens.

That doesn't make sense. There aren't any existing users of sendfile to copy files.

-- Jamie

author
#10 lore raw
Quoted 9 lines · On Tue, 18 Nov 2003 15:49:21 +0000 Jamie Lokier <[email protected]> wrote:
Quoted 5 lines · Andi Kleen
Quoted 1 line

s/EINTR/short count/, of course :)

That would be buggy because existing users of sendfile don't know about this and would silently only copy part of the file when a signal happens.

That doesn't make sense. There aren't any existing users of sendfile to copy files.

[ignore the mail, it was an stuck mail queue]

But note that arbitary changes in the signal handling would affect all users of sendfile, not just those that attempt to copy files or do other things that should be done in user space.

-Andi

#11 lore raw
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

" " == Andi Kleen <[email protected]> writes:

That would be buggy because existing users of sendfile don't know about this and would silently only copy part of the file when a signal happens.

That doesn't make sense. There aren't any existing users of sendfile to copy files.

> [ignore the mail, it was an stuck mail queue]

> But note that arbitary changes in the signal handling would > affect all users of sendfile, not just those that attempt to > copy files or do other things that should be done in user > space.

That 'change' is already in effect for people who mount their NFS partitions with the "intr" or "soft" flags.

See the return value of generic_file_sendfile(): it already has the read()/write-like semantics of returning number of bytes written if non-zero, or the value of desc.error if not.

Cheers,
Trond

#12 lore raw
In reply to Jamie Lokier
Quoted 9 lines · Jamie Lokier
Quoted 5 lines · Andi Kleen
Quoted 1 line

s/EINTR/short count/, of course :)

That would be buggy because existing users of sendfile don't know about this and would silently only copy part of the file when a signal happens.

That doesn't make sense. There aren't any existing users of sendfile to copy files.

True. It also doesn't address the issue of what to do when the file copy is being done on a remote server and not by something local. Synchronizing a remote interrupt could really be nasty.

#13 lore raw
In reply to Andi Kleen
Quoted 5 lines · Andi Kleen

That would be buggy because existing users of sendfile don't know about this and would silently only copy part of the file when a signal happens.

It would be consistent with the documented semantics for other file operations. Obviously, return zero only on EOF.

-hpa

#14 lore raw
In reply to Andi Kleen
Quoted 4 lines · Andi Kleen

That would be buggy because existing users of sendfile don't know about this and would silently only copy part of the file when a signal happens.

Don't be silly.

Existing sendfile users had _better_ accept short writes.

They happen all the time. If the destination is the network, it _will_ be interruptible.

Linus

#15 lore raw
In reply to Andi Kleen
Quoted 5 lines · Andi Kleen
Quoted 1 line · H. Peter Anvin

s/EINTR/short count/, of course :)

That would be buggy because existing users of sendfile don't know about this and would silently only copy part of the file when a signal happens.

Tru64 5.1B sendfile(2) page includes:

[EINTR]
A signal interrupted sendfile before any data was
transmitted. If some data was transmitted, the func-
tion returns the number of bytes sent before the interrupt and does not set errno to [EINTR].

There are quite a few more documented return values under Tru64, although TCP sockets are the only supported destination. See

http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN2/0024____.HTM

Signature · 3 lines
Chris Adams <[email protected]>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.