Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Mar 1999 17:10:01 -0800 (PST)
From:      John Plevyak <jplevyak@inktomi.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/8011: libc_r does not have pread() or pwrite() interfaces
Message-ID:  <199903050110.RAA49007@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/8011; it has been noted by GNATS.

From: John Plevyak <jplevyak@inktomi.com>
To: freebsd-gnats-submit@freebsd.org, info@highwind.com
Cc:  
Subject: Re: kern/8011: libc_r does not have pread() or pwrite() interfaces
Date: Fri, 05 Mar 1999 01:09:12 +0000

 pread and pwrite under FreeBSD  3.1+ also require patching vfs_vnops.c
 because
 vn_read/vn_write mess with fp->f_offset as well:
 
 Index: sys/kern/vfs_vnops.c
 ===================================================================
 RCS file: /usr/cvsroot/src/sys/kern/vfs_vnops.c,v
 retrieving revision 1.62
 diff -c -r1.62 vfs_vnops.c
 *** vfs_vnops.c 1999/01/20 14:49:11     1.62
 --- vfs_vnops.c 1999/03/04 16:09:40
 ***************
 *** 284,296 ****
 
         VOP_LEASE(vp, p, cred, LEASE_READ);
         vn_lock(vp, LK_SHARED | LK_NOPAUSE | LK_RETRY, p);
 !       if (uio->uio_offset == -1)
 !               uio->uio_offset = fp->f_offset;
 !       count = uio->uio_resid;
         flag = 0;
         if (fp->f_flag & FNONBLOCK)
                 flag |= IO_NDELAY;
 
         /*
          * Sequential read heuristic.
          * If we have been doing sequential input,
 --- 284,306 ----
 
         VOP_LEASE(vp, p, cred, LEASE_READ);
         vn_lock(vp, LK_SHARED | LK_NOPAUSE | LK_RETRY, p);
 !
         flag = 0;
         if (fp->f_flag & FNONBLOCK)
                 flag |= IO_NDELAY;
 
 +       if (uio->uio_offset != -1) {
 +               flag = 0;
 +               if (fp->f_flag & FNONBLOCK)
 +                       flag |= IO_NDELAY;
 +               error = VOP_READ(vp, uio, flag, cred);
 +               VOP_UNLOCK(vp, 0, p);
 +               return error;
 +       }
 +
 +       uio->uio_offset = fp->f_offset;
 +       count = uio->uio_resid;
 +
         /*
          * Sequential read heuristic.
          * If we have been doing sequential input,
 ***************
 *** 347,352 ****
 --- 357,367 ----
                 ioflag |= IO_SYNC;
         VOP_LEASE(vp, p, cred, LEASE_WRITE);
         vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
 +       if (uio->uio_offset != -1) {
 +               error = VOP_WRITE(vp, uio, ioflag, cred);
 +               VOP_UNLOCK(vp, 0, p);
 +               return error;
 +       }
         uio->uio_offset = fp->f_offset;
         count = uio->uio_resid;
         error = VOP_WRITE(vp, uio, ioflag, cred);
 
 
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199903050110.RAA49007>