lkml.org 
[lkml]   [2003]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: OT: why no file copy() libc/syscall ??
    On Tue, Nov 11, 2003 at 02:38:59PM +0100, Rogier Wolff wrote:
    > On Mon, Nov 10, 2003 at 08:05:11PM -0500, Albert Cahalan wrote:
    > > So open the file, change context, and then:
    > >
    > > long copy_fd_to_file(int fd, const char *name, ...)
    > >
    > > (if you can no longer read from the OPEN fd,
    > > either we override that or we just don't care
    > > about such mostly-fictional cases)
    >
    >
    > Actually, I think we should have a:
    >
    > long copy_fd_to_fd (int src, int dst, int len)
    >
    > type of systemcall.

    We have one, sendfile(2).

    > It should do something like:
    >
    > while ((nbytes = read (src, buf, BUFSIZE)) >= 0) {
    > if (write (dst, buf, nbytes) < 0)
    > return totbytes;
    > totbytes += nbytes;
    > }
    >
    > but it allows kernel-space to optimize this whenever possible. Kernel
    > then becomes responsible for detecting and handling the optimizable
    > cases.
    >
    > The kernel then becomes something
    >
    > if (islocalfile (src) && issocket (dst))
    > /* Call the old sendfile */
    > return sendfile (....);
    >
    > if (isCIFS (src), isCIFS(dst))
    > /* Tell remote host to copy the file. */
    > return CIFS_copy_file (....);
    >
    > ...

    Can you explain why this cannot be in sys_sendfile?
    It doesn't make much sense to provide any default in the kernel,
    that's something the userland can handle equally well.
    But e.g. the CIFS copy can be done as sendfile hook.

    Jakub
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:58    [W:0.041 / U:2.944 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site