Subject: ccdioctl in no context
To: None <tech-kern@netbsd.org>
From: Jed Davis <jdev@panix.com>
List: tech-kern
Date: 04/23/2006 19:03:52
--=-=-=
I notice that ccdioctl no longer works without a context, as it does
"curlwp->l_proc" at the top. The Xen disk backend driver does
DIOGCPART on the underlying device to get its size, and xbd-on-ccd
used to work.
I've attached a change that attempts to make it do the right thing,
based on what it was sort of doing before, and now xbd-on-ccd works
again. But I'm not hugely familiar with this area of things yet, so I
invite comment.
--
(let ((C call-with-current-continuation)) (apply (lambda (x y) (x y)) (map
((lambda (r) ((C C) (lambda (s) (r (lambda l (apply (s s) l)))))) (lambda
(f) (lambda (l) (if (null? l) C (lambda (k) (display (car l)) ((f (cdr l))
(C k))))))) '((#\J #\d #\D #\v #\s) (#\e #\space #\a #\i #\newline)))))
--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=ccd-nocontext.diff
Index: ccd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ccd.c,v
retrieving revision 1.108
diff -u -p -r1.108 ccd.c
--- ccd.c 16 Feb 2006 23:25:18 -0000 1.108
+++ ccd.c 23 Apr 2006 20:54:46 -0000
@@ -988,10 +988,10 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t
int part, pmask;
struct ccd_softc *cs;
struct ccd_ioctl *ccio = (struct ccd_ioctl *)data;
+ struct proc *p;
struct ucred *uc;
char **cpp;
struct vnode **vpp;
- struct proc *p = l->l_proc;
#ifdef __HAVE_OLD_DISKLABEL
struct disklabel newlabel;
#endif
@@ -1000,6 +1000,9 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t
return (ENXIO);
cs = &ccd_softc[unit];
+ p = (l != NULL) ? l->l_proc : NULL;
+ uc = (p != NULL) ? p->p_ucred : NOCRED;
+
/* Must be open for writes for these commands... */
switch (cmd) {
case CCDIOCSET:
@@ -1097,7 +1100,7 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t
if ((error = ccdlookup(cpp[i], l, &vpp[i])) != 0) {
for (j = 0; j < lookedup; ++j)
(void)vn_close(vpp[j], FREAD|FWRITE,
- p->p_ucred, l);
+ uc, l);
free(vpp, M_DEVBUF);
free(cpp, M_DEVBUF);
goto out;
@@ -1111,7 +1114,7 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t
if ((error = ccdinit(cs, cpp, vpp, l)) != 0) {
for (j = 0; j < lookedup; ++j)
(void)vn_close(vpp[j], FREAD|FWRITE,
- p->p_ucred, l);
+ uc, l);
free(vpp, M_DEVBUF);
free(cpp, M_DEVBUF);
goto out;
@@ -1179,7 +1182,7 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t
cs->sc_cinfo[i].ci_vp);
#endif
(void)vn_close(cs->sc_cinfo[i].ci_vp, FREAD|FWRITE,
- p->p_ucred, l);
+ uc, l);
free(cs->sc_cinfo[i].ci_path, M_DEVBUF);
}
@@ -1226,7 +1229,6 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t
* We pass this call down to all components and report
* the first error we encounter.
*/
- uc = (p != NULL) ? p->p_ucred : NOCRED;
for (error = 0, i = 0; i < cs->sc_nccdisks; i++) {
j = VOP_IOCTL(cs->sc_cinfo[i].ci_vp, cmd, data,
flag, uc, l);
--=-=-=--