this code lets userland check and change the caches on disks using the new ioctl i just put into the tree.
id be extremely happy if someone would take the functionality here and fit it into bioctl. /* * Copyright (c) 2010 David Gwynne <d...@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/dkio.h> __dead void usage(void); __dead void usage(void) { extern char *__progname; fprintf(stderr, "usage: %s [-rRwW] disk\n", __progname); exit(1); } int main(int argc, char *argv[]) { struct dk_cache dkc; int fd; char *disk = NULL; long cmd = 0; int rdcache = -1, wrcache = -1; int set = 0; int ch; while ((ch = getopt(argc, argv, "rRwW")) != -1) { switch (ch) { case 'r': rdcache = 0; break; case 'R': rdcache = 1; break; case 'w': wrcache = 0; break; case 'W': wrcache = 1; break; default: usage(); /* NOTREACHED */ } } argc -= optind; argv += optind; if (argc != 1) usage(); disk = argv[0]; fd = open(disk, O_RDONLY); if (fd == -1) err(1, "open: %s", disk); if (ioctl(fd, DIOCGCACHE, &dkc) == -1) err(1, "ioctl DIOCGCACHE"); if (wrcache != -1) { dkc.wrcache = wrcache; set = 1; } if (rdcache != -1) { dkc.rdcache = rdcache; set = 1; } if (set) { if (ioctl(fd, DIOCSCACHE, &dkc) == -1) err(1, "ioctl DIOCSCACHE"); } printf("%s: write cache: %s, read cache: %s\n", disk, dkc.wrcache ? "enabled" : "disabled", dkc.rdcache ? "enabled" : "disabled"); return (0); }