static int plooptool_clear(int argc, char **argv) { int i; int lfd; struct { char * device; } stopopts = { }; while ((i = getopt(argc, argv, "d:")) != EOF) { switch (i) { case 'd': stopopts.device = optarg; break; default: usage_clear(); return SYSEXIT_PARAM; } } argc -= optind; argv += optind; if (argc || !stopopts.device) { usage_clear(); return SYSEXIT_PARAM; } lfd = open(stopopts.device, O_RDONLY); if (lfd < 0) { perror("Can't open device"); return SYSEXIT_DEVICE; } if (ioctl(lfd, PLOOP_IOC_CLEAR, 0) < 0) { perror("PLOOP_IOC_CLEAR"); close(lfd); return SYSEXIT_DEVIOC; } close(lfd); return 0; }
static int pb_clear(int argc, char **argv) { int i, ret; int fd2; while ((i = getopt(argc, argv, "d:m:")) != EOF) { switch (i) { case 'd': device = optarg; break; case 'm': mount_point = optarg; break; default: usage_clear(); return SYSEXIT_PARAM; } } argc -= optind; argv += optind; GET_DD(argc, argv); if (argc != 0 || fill_opts()) { usage_clear(); return SYSEXIT_PARAM; } ret = get_balloon(mount_point, NULL, &fd2); if (ret) return ret; ret = ploop_balloon_clear_state(device); if (ret) return ret; fprintf(stdout, "Current state of in-kernel maintenance is OFF now\n"); return 0; }