Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/librumpuser Some systems don't provide preadv/pwritev (h...



details:   https://anonhg.NetBSD.org/src/rev/1b69d272ae0c
branches:  trunk
changeset: 786513:1b69d272ae0c
user:      pooka <pooka%NetBSD.org@localhost>
date:      Tue Apr 30 11:26:26 2013 +0000

description:
Some systems don't provide preadv/pwritev (hi Solaris!), so implement
that with lseek + readv/writev instead (and avoid rewinding the
pointer with soon-to-be documentation).

diffstat:

 lib/librumpuser/rumpuser.c |  34 ++++++++++++++++++++++++++--------
 1 files changed, 26 insertions(+), 8 deletions(-)

diffs (64 lines):

diff -r 65a1e9dfcf6a -r 1b69d272ae0c lib/librumpuser/rumpuser.c
--- a/lib/librumpuser/rumpuser.c        Tue Apr 30 10:16:25 2013 +0000
+++ b/lib/librumpuser/rumpuser.c        Tue Apr 30 11:26:26 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser.c,v 1.45 2013/04/30 00:03:52 pooka Exp $      */
+/*     $NetBSD: rumpuser.c,v 1.46 2013/04/30 11:26:26 pooka Exp $      */
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.45 2013/04/30 00:03:52 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.46 2013/04/30 11:26:26 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/ioctl.h>
@@ -340,10 +340,19 @@
        ssize_t nn;
        int rv;
 
-       if (off == RUMPUSER_IOV_NOSEEK)
+       if (off == RUMPUSER_IOV_NOSEEK) {
                KLOCK_WRAP(nn = readv(fd, iov, iovlen));
-       else
-               KLOCK_WRAP(nn = preadv(fd, iov, iovlen, off));
+       } else {
+               int nlocks;
+
+               rumpkern_unsched(&nlocks, NULL);
+               if (lseek(fd, off, SEEK_SET) == off) {
+                       nn = readv(fd, iov, iovlen);
+               } else {
+                       nn = -1;
+               }
+               rumpkern_sched(nlocks, NULL);
+       }
 
        if (nn == -1) {
                rv = errno;
@@ -363,10 +372,19 @@
        ssize_t nn;
        int rv;
 
-       if (off == RUMPUSER_IOV_NOSEEK)
+       if (off == RUMPUSER_IOV_NOSEEK) {
                KLOCK_WRAP(nn = writev(fd, iov, iovlen));
-       else 
-               KLOCK_WRAP(nn = pwritev(fd, iov, iovlen, off));
+       } else {
+               int nlocks;
+
+               rumpkern_unsched(&nlocks, NULL);
+               if (lseek(fd, off, SEEK_SET) == off) {
+                       nn = writev(fd, iov, iovlen);
+               } else {
+                       nn = -1;
+               }
+               rumpkern_sched(nlocks, NULL);
+       }
 
        if (nn == -1) {
                rv = errno;



Home | Main Index | Thread Index | Old Index