tech-kern archive

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

Re: DIOCGDISKINFO support for vnd



On Tue, Mar 11, 2014 at 06:14:28PM +0200, Alan Barrett wrote:
> On Tue, 11 Mar 2014, Patrick Welche wrote:
> >     default:
> >-            return ENOTTY;
> >+            error = disk_ioctl(&vnd->sc_dkdev, cmd, data, flag, l);
> >+            if (error == EPASSTHROUGH)
> >+                    return ENOTTY;
> >+            else
> >+                    return error;
> 
> I think there's no need to translate EPASSTHROUGH to ENOTTY here; that
> translation will be done by sys_ioctl() before returning to userland.  Also,
> several other disk drivers have their ioctl handlers call disk_ioctl early
> (see fdioctl, wdioctl, sdioctl, dkioctl, raidioctl, among others), and it's
> not clear why vndioctl doesn't do that.

I went for "if vnd doesn't implement the ioctl, then try a generic one",
but there is no need for that...

Even simpler version 2 attached.

Cheers,

Patrick
Index: sys/dev/vnd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/vnd.c,v
retrieving revision 1.227
diff -u -r1.227 vnd.c
--- sys/dev/vnd.c       29 Dec 2013 08:09:44 -0000      1.227
+++ sys/dev/vnd.c       12 Mar 2014 11:01:08 -0000
@@ -1044,6 +1044,10 @@
                return ENXIO;
        vio = (struct vnd_ioctl *)data;
 
+       error = disk_ioctl(&vnd->sc_dkdev, cmd, data, flag, l);
+       if (error != EPASSTHROUGH)
+               return (error);
+
        /* Must be open for writes for these commands... */
        switch (cmd) {
        case VNDIOCSET:
@@ -2007,6 +2011,12 @@
        dg->dg_ntracks = vnd->sc_geom.vng_ntracks;
        dg->dg_ncylinders = vnd->sc_geom.vng_ncylinders;
 
+#ifdef DEBUG
+       if (vnddebug & VDB_LABEL) {
+               printf("dg->dg_secperunit: %" PRId64 "\n", dg->dg_secperunit);
+               printf("dg->dg_ncylinders: %u\n", dg->dg_ncylinders);
+       }
+#endif
        disk_set_info(vnd->sc_dev, &vnd->sc_dkdev, NULL);
 }
 


Home | Main Index | Thread Index | Old Index