1*21b926adSArne Jansen #include <stdio.h> 2*21b926adSArne Jansen #include <stdlib.h> 3*21b926adSArne Jansen #include <string.h> 4*21b926adSArne Jansen #include <errno.h> 5*21b926adSArne Jansen #include <sys/types.h> 6*21b926adSArne Jansen #include <sys/stat.h> 7*21b926adSArne Jansen #include <fcntl.h> 8*21b926adSArne Jansen #include <unistd.h> 9*21b926adSArne Jansen #include <sys/param.h> 10*21b926adSArne Jansen 11*21b926adSArne Jansen int g_arcfl; 12*21b926adSArne Jansen 13*21b926adSArne Jansen void 14*21b926adSArne Jansen flush_one(const char *ds) 15*21b926adSArne Jansen { 16*21b926adSArne Jansen int ret; 17*21b926adSArne Jansen char name[MAXPATHLEN + 1]; 18*21b926adSArne Jansen 19*21b926adSArne Jansen strcpy(name, ds); 20*21b926adSArne Jansen 21*21b926adSArne Jansen ret = ioctl(g_arcfl, 0xf10053, name); 22*21b926adSArne Jansen if (ret == -1) { 23*21b926adSArne Jansen printf("ioctl to arcflush device failed with %d=%s\n", 24*21b926adSArne Jansen errno, strerror(errno)); 25*21b926adSArne Jansen exit(1); 26*21b926adSArne Jansen } 27*21b926adSArne Jansen } 28*21b926adSArne Jansen 29*21b926adSArne Jansen void 30*21b926adSArne Jansen purge_one(const char *mntpnt) 31*21b926adSArne Jansen { 32*21b926adSArne Jansen int ret; 33*21b926adSArne Jansen char name[MAXPATHLEN + 1]; 34*21b926adSArne Jansen 35*21b926adSArne Jansen strcpy(name, mntpnt); 36*21b926adSArne Jansen 37*21b926adSArne Jansen ret = ioctl(g_arcfl, 0xf10054, name); 38*21b926adSArne Jansen if (ret == -1) { 39*21b926adSArne Jansen printf("ioctl to dnlc purge failed with %d=%s\n", 40*21b926adSArne Jansen errno, strerror(errno)); 41*21b926adSArne Jansen exit(1); 42*21b926adSArne Jansen } 43*21b926adSArne Jansen } 44*21b926adSArne Jansen 45*21b926adSArne Jansen int 46*21b926adSArne Jansen main(int argc, char **argv) 47*21b926adSArne Jansen { 48*21b926adSArne Jansen if (argc != 3) { 49*21b926adSArne Jansen printf("usage: arcflush <dataset> <mountpoint>\n"); 50*21b926adSArne Jansen exit(1); 51*21b926adSArne Jansen } 52*21b926adSArne Jansen 53*21b926adSArne Jansen g_arcfl = open("/devices/pseudo/arcflush@0:arcflush", O_RDWR); 54*21b926adSArne Jansen if (g_arcfl == -1) { 55*21b926adSArne Jansen printf("failed to open arcflush device: %s\n", 56*21b926adSArne Jansen strerror(errno)); 57*21b926adSArne Jansen exit(1); 58*21b926adSArne Jansen } 59*21b926adSArne Jansen flush_one(argv[1]); 60*21b926adSArne Jansen purge_one(argv[2]); 61*21b926adSArne Jansen 62*21b926adSArne Jansen close(g_arcfl); 63*21b926adSArne Jansen 64*21b926adSArne Jansen return (0); 65*21b926adSArne Jansen } 66