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