Module Name: src Committed By: jdolecek Date: Thu Mar 30 16:50:33 UTC 2017
Modified Files: src/sys/dev: ccd.c Log Message: support DIOCGCACHE - result is intersection of flags returned by underlying devices; devices can't be added or removed, so the feature flags remain static add support for DIOCGSTRATEGY while here, mainly to make dkctl(8) output neater To generate a diff of this commit: cvs rdiff -u -r1.169 -r1.170 src/sys/dev/ccd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/ccd.c diff -u src/sys/dev/ccd.c:1.169 src/sys/dev/ccd.c:1.170 --- src/sys/dev/ccd.c:1.169 Sun Mar 5 23:07:12 2017 +++ src/sys/dev/ccd.c Thu Mar 30 16:50:32 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ccd.c,v 1.169 2017/03/05 23:07:12 mlelstv Exp $ */ +/* $NetBSD: ccd.c,v 1.170 2017/03/30 16:50:32 jdolecek Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc. @@ -88,7 +88,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.169 2017/03/05 23:07:12 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.170 2017/03/30 16:50:32 jdolecek Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -1182,6 +1182,8 @@ ccdioctl(dev_t dev, u_long cmd, void *da switch (cmd) { case CCDIOCCLR: case DIOCGDINFO: + case DIOCGSTRATEGY: + case DIOCGCACHE: case DIOCCACHESYNC: case DIOCAWEDGE: case DIOCDWEDGE: @@ -1393,6 +1395,50 @@ ccdioctl(dev_t dev, u_long cmd, void *da /* Don't break, otherwise cs is read again. */ return 0; + case DIOCGSTRATEGY: + { + struct disk_strategy *dks = (void *)data; + + mutex_enter(cs->sc_iolock); + if (cs->sc_bufq != NULL) + strlcpy(dks->dks_name, + bufq_getstrategyname(cs->sc_bufq), + sizeof(dks->dks_name)); + else + error = EINVAL; + mutex_exit(cs->sc_iolock); + dks->dks_paramlen = 0; + break; + } + + case DIOCGCACHE: + { + int dkcache = 0; + + /* + * We pass this call down to all components and report + * intersection of the flags returned by the components. + * If any errors out, we return error. CCD components + * can not change unless the device is unconfigured, so + * device feature flags will remain static. RCE/WCE can change + * of course, if set directly on underlying device. + */ + for (error = 0, i = 0; i < cs->sc_nccdisks; i++) { + error = VOP_IOCTL(cs->sc_cinfo[i].ci_vp, cmd, &j, + flag, uc); + if (error) + break; + + if (i == 0) + dkcache = j; + else + dkcache &= j; + } + + *((int *)data) = dkcache; + break; + } + case DIOCCACHESYNC: /* * We pass this call down to all components and report