Fri May 29 09:32:41 2009 UTC ()
Make getdirentries set a correct block read position for basep
argument.


(njoly)
diff -r1.35 -r1.36 src/sys/compat/osf1/osf1_file.c

cvs diff -r1.35 -r1.36 src/sys/compat/osf1/Attic/osf1_file.c (expand / switch to unified diff)

--- src/sys/compat/osf1/Attic/osf1_file.c 2009/05/28 15:21:26 1.35
+++ src/sys/compat/osf1/Attic/osf1_file.c 2009/05/29 09:32:41 1.36
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: osf1_file.c,v 1.35 2009/05/28 15:21:26 njoly Exp $ */ 1/* $NetBSD: osf1_file.c,v 1.36 2009/05/29 09:32:41 njoly Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved. 4 * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -48,27 +48,27 @@ @@ -48,27 +48,27 @@
48 * 48 *
49 * Carnegie Mellon requests users of this software to return to 49 * Carnegie Mellon requests users of this software to return to
50 * 50 *
51 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 51 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
52 * School of Computer Science 52 * School of Computer Science
53 * Carnegie Mellon University 53 * Carnegie Mellon University
54 * Pittsburgh PA 15213-3890 54 * Pittsburgh PA 15213-3890
55 * 55 *
56 * any improvements or extensions that they make and grant Carnegie the 56 * any improvements or extensions that they make and grant Carnegie the
57 * rights to redistribute these changes. 57 * rights to redistribute these changes.
58 */ 58 */
59 59
60#include <sys/cdefs.h> 60#include <sys/cdefs.h>
61__KERNEL_RCSID(0, "$NetBSD: osf1_file.c,v 1.35 2009/05/28 15:21:26 njoly Exp $"); 61__KERNEL_RCSID(0, "$NetBSD: osf1_file.c,v 1.36 2009/05/29 09:32:41 njoly Exp $");
62 62
63#if defined(_KERNEL_OPT) 63#if defined(_KERNEL_OPT)
64#include "opt_syscall_debug.h" 64#include "opt_syscall_debug.h"
65#endif 65#endif
66 66
67#include <sys/param.h> 67#include <sys/param.h>
68#include <sys/systm.h> 68#include <sys/systm.h>
69#include <sys/namei.h> 69#include <sys/namei.h>
70#include <sys/proc.h> 70#include <sys/proc.h>
71#include <sys/file.h> 71#include <sys/file.h>
72#include <sys/stat.h> 72#include <sys/stat.h>
73#include <sys/filedesc.h> 73#include <sys/filedesc.h>
74#include <sys/kernel.h> 74#include <sys/kernel.h>
@@ -132,49 +132,49 @@ osf1_sys_getdirentries(struct lwp *l, co @@ -132,49 +132,49 @@ osf1_sys_getdirentries(struct lwp *l, co
132 syscallarg(u_int) nbytes; 132 syscallarg(u_int) nbytes;
133 syscallarg(long *) basep; 133 syscallarg(long *) basep;
134 } */ 134 } */
135 struct dirent *bdp; 135 struct dirent *bdp;
136 struct vnode *vp; 136 struct vnode *vp;
137 char *inp, *buf; /* BSD-format */ 137 char *inp, *buf; /* BSD-format */
138 int len, reclen; /* BSD-format */ 138 int len, reclen; /* BSD-format */
139 char *outp; /* OSF1-format */ 139 char *outp; /* OSF1-format */
140 int resid, osf1_reclen; /* OSF1-format */ 140 int resid, osf1_reclen; /* OSF1-format */
141 struct file *fp; 141 struct file *fp;
142 struct uio auio; 142 struct uio auio;
143 struct iovec aiov; 143 struct iovec aiov;
144 struct osf1_dirent idb; 144 struct osf1_dirent idb;
145 off_t off; /* true file offset */ 145 off_t off, off1; /* true file offset */
146 int buflen, error, eofflag; 146 int buflen, error, eofflag;
147 off_t *cookiebuf = NULL, *cookie; 147 off_t *cookiebuf = NULL, *cookie;
148 int ncookies, fd; 148 int ncookies, fd;
149 149
150 fd = SCARG(uap, fd); 150 fd = SCARG(uap, fd);
151 if ((error = fd_getvnode(fd, &fp)) != 0) 151 if ((error = fd_getvnode(fd, &fp)) != 0)
152 return (error); 152 return (error);
153 if ((fp->f_flag & FREAD) == 0) { 153 if ((fp->f_flag & FREAD) == 0) {
154 error = EBADF; 154 error = EBADF;
155 goto out1; 155 goto out1;
156 } 156 }
157 157
158 vp = (struct vnode *)fp->f_data; 158 vp = (struct vnode *)fp->f_data;
159 if (vp->v_type != VDIR) { 159 if (vp->v_type != VDIR) {
160 error = EINVAL; 160 error = EINVAL;
161 goto out1; 161 goto out1;
162 } 162 }
163 163
164 buflen = min(MAXBSIZE, SCARG(uap, nbytes)); 164 buflen = min(MAXBSIZE, SCARG(uap, nbytes));
165 buf = malloc(buflen, M_TEMP, M_WAITOK); 165 buf = malloc(buflen, M_TEMP, M_WAITOK);
166 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); 166 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
167 off = fp->f_offset; 167 off = off1 = fp->f_offset;
168again: 168again:
169 aiov.iov_base = buf; 169 aiov.iov_base = buf;
170 aiov.iov_len = buflen; 170 aiov.iov_len = buflen;
171 auio.uio_iov = &aiov; 171 auio.uio_iov = &aiov;
172 auio.uio_iovcnt = 1; 172 auio.uio_iovcnt = 1;
173 auio.uio_rw = UIO_READ; 173 auio.uio_rw = UIO_READ;
174 auio.uio_resid = buflen; 174 auio.uio_resid = buflen;
175 auio.uio_offset = off; 175 auio.uio_offset = off;
176 UIO_SETUP_SYSSPACE(&auio); 176 UIO_SETUP_SYSSPACE(&auio);
177 /* 177 /*
178 * First we read into the malloc'ed buffer, then 178 * First we read into the malloc'ed buffer, then
179 * we massage it into user space, one record at a time. 179 * we massage it into user space, one record at a time.
180 */ 180 */
@@ -234,27 +234,27 @@ again: @@ -234,27 +234,27 @@ again:
234 /* if we squished out the whole block, try again */ 234 /* if we squished out the whole block, try again */
235 if (outp == (char *)SCARG(uap, buf)) 235 if (outp == (char *)SCARG(uap, buf))
236 goto again; 236 goto again;
237 fp->f_offset = off; /* update the vnode offset */ 237 fp->f_offset = off; /* update the vnode offset */
238 238
239eof: 239eof:
240 *retval = SCARG(uap, nbytes) - resid; 240 *retval = SCARG(uap, nbytes) - resid;
241out: 241out:
242 VOP_UNLOCK(vp, 0); 242 VOP_UNLOCK(vp, 0);
243 if (cookiebuf) 243 if (cookiebuf)
244 free(cookiebuf, M_TEMP); 244 free(cookiebuf, M_TEMP);
245 free(buf, M_TEMP); 245 free(buf, M_TEMP);
246 if (SCARG(uap, basep) != NULL) 246 if (SCARG(uap, basep) != NULL)
247 error = copyout(&eofflag, SCARG(uap, basep), sizeof(long)); 247 error = copyout(&off1, SCARG(uap, basep), sizeof(long));
248out1: 248out1:
249 fd_putfile(fd); 249 fd_putfile(fd);
250 return error; 250 return error;
251} 251}
252 252
253/* 253/*
254 * Get file status; this version does not follow links. 254 * Get file status; this version does not follow links.
255 */ 255 */
256/* ARGSUSED */ 256/* ARGSUSED */
257int 257int
258osf1_sys_lstat(struct lwp *l, const struct osf1_sys_lstat_args *uap, register_t *retval) 258osf1_sys_lstat(struct lwp *l, const struct osf1_sys_lstat_args *uap, register_t *retval)
259{ 259{
260 struct stat sb; 260 struct stat sb;