Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/dev/ccd.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/dev/ccd.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.175 retrieving revision 1.175.2.9 diff -u -p -r1.175 -r1.175.2.9 --- src/sys/dev/ccd.c 2018/01/23 22:42:29 1.175 +++ src/sys/dev/ccd.c 2019/01/13 10:49:50 1.175.2.9 @@ -1,4 +1,4 @@ -/* $NetBSD: ccd.c,v 1.175 2018/01/23 22:42:29 pgoyette Exp $ */ +/* $NetBSD: ccd.c,v 1.175.2.9 2019/01/13 10:49:50 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc. @@ -88,7 +88,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.175 2018/01/23 22:42:29 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.175.2.9 2019/01/13 10:49:50 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -119,6 +119,7 @@ __KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.17 #include #include #include +#include #include @@ -1055,6 +1056,19 @@ ccdread(dev_t dev, struct uio *uio, int return (physio(ccdstrategy, NULL, dev, B_READ, minphys, uio)); } +/* Hook the compat_60 ioctl code + * + * This looks ugly, since we pass the "real" ioctl function as an + * argument to the compat_xxx function. + */ +MODULE_CALL_HOOK_DECL(ccd_ioctl_60_hook, (dev_t dev, u_long cmd, void *data, + int flag, struct lwp *l, int (*ff)(dev_t, u_long, void *, int, + struct lwp *))); +MODULE_CALL_HOOK(ccd_ioctl_60_hook, (dev_t dev, u_long cmd, void *data, + int flag, struct lwp *l, int (*ff)(dev_t, u_long, void *, int, + struct lwp *)), + (dev, cmd, data, flag, l, ccdioctl), enosys()); + /* ARGSUSED */ static int ccdwrite(dev_t dev, struct uio *uio, int flags) @@ -1093,14 +1107,15 @@ ccdioctl(dev_t dev, u_long cmd, void *da #endif switch (cmd) { -#if defined(COMPAT_60) && !defined(_LP64) - case CCDIOCSET_60: -#endif case CCDIOCSET: make = 1; break; default: - make = 0; + if (ccd_ioctl_60_hook_call(0, cmd, NULL, 0, NULL, NULL) + == 0) + make = 1; + else + make = 0; break; } @@ -1108,45 +1123,9 @@ ccdioctl(dev_t dev, u_long cmd, void *da return ENOENT; uc = kauth_cred_get(); -/* - * Compat code must not be called if on a platform where - * sizeof (size_t) == sizeof (uint64_t) as CCDIOCSET will - * be the same as CCDIOCSET_60 - */ -#if defined(COMPAT_60) && !defined(_LP64) - switch (cmd) { - case CCDIOCSET_60: { - struct ccd_ioctl ccionew; - struct ccd_ioctl_60 *ccio60 = - (struct ccd_ioctl_60 *)data; - ccionew.ccio_disks = ccio->ccio_disks; - ccionew.ccio_ndisks = ccio->ccio_ndisks; - ccionew.ccio_ileave = ccio->ccio_ileave; - ccionew.ccio_flags = ccio->ccio_flags; - ccionew.ccio_unit = ccio->ccio_unit; - error = ccdioctl(dev, CCDIOCSET, &ccionew, flag, l); - if (!error) { - /* Copy data back, adjust types if necessary */ - ccio60->ccio_disks = ccionew.ccio_disks; - ccio60->ccio_ndisks = ccionew.ccio_ndisks; - ccio60->ccio_ileave = ccionew.ccio_ileave; - ccio60->ccio_flags = ccionew.ccio_flags; - ccio60->ccio_unit = ccionew.ccio_unit; - ccio60->ccio_size = (size_t)ccionew.ccio_size; - } + error = ccd_ioctl_60_hook_call(dev, cmd, data, flag, l, ccdioctl); + if (error != ENOSYS) return error; - } - break; - - case CCDIOCCLR_60: - /* - * ccio_size member not used, so existing struct OK - * drop through to existing non-compat version - */ - cmd = CCDIOCCLR; - break; - } -#endif /* COMPAT_60 && !_LP64*/ /* Must be open for writes for these commands... */ switch (cmd) {