+{
+ register struct file *fp;
+ int error;
+
+ if ((fp = holdfp(p->p_fd, uap->fd, FREAD)) == NULL)
+ return (EBADF);
+ error = dofileread(p, fp, uap->fd, uap->cbuf, uap->nbyte,
+ (off_t)-1, 0, retval);
+ frele(fp);
+ return(error);
+}
+
+/*
+ * Pread system call
+ */
+#ifndef _SYS_SYSPROTO_H_
+struct pread_args {
+ int fd;
+ void *buf;
+ size_t nbyte;
+#ifdef DOUBLE_ALIGN_PARAMS
+ int pad;
+#endif
+ off_t offset;
+};
+#endif
+int
+pread(p, uap, retval)
+ struct proc *p;
+ register struct pread_args *uap;
+ int *retval;
+{
+ register struct file *fp;
+ int error;
+
+ if ((fp = holdfp(p->p_fd, uap->fd, FREAD)) == NULL)
+ return (EBADF);
+ if (fp->f_type != DTYPE_VNODE) {
+ error = ESPIPE;
+ } else {
+ error = dofileread(p, fp, uap->fd, uap->buf, uap->nbyte,
+ uap->offset, FOF_OFFSET, retval);
+ }
+ frele(fp);
+ return(error);
+}
+
+/*
+ * Code common for read and pread
+ */
+int
+dofileread(p, fp, fd, buf, nbyte, offset, flags, retval)
+ struct proc *p;
+ struct file *fp;
+ int fd, flags;
+ void *buf;
+ size_t nbyte;
+ off_t offset;
+ int *retval;