Beispiel #1
0
static int bee_dep_remove(int argc, char *argv[])
{
    int i, c, help, print;
    struct hash *graph;
    char *pkg;
    struct option long_options[] = {
        {"help",  0, &help,  1},
        {"print", 0, &print, 1},
        {0, 0, 0, 0}
    };

    help = print = 0;

    while ((c = getopt_long(argc, argv, "", long_options, NULL)) != -1) {
        switch (c) {
            case '?':
                usage_remove();
                return 1;
        }
    }

    if (help) {
        usage_remove();
        return 0;
    }

    if (optind == argc) {
        fprintf(stderr, "bee-dep: pkgname needed\n");
        return 1;
    }

    graph = get_cache();

    for (i = optind; i < argc; i++) {
        pkg = argv[i];

        if (print && print_removable(graph, pkg)) {
            hash_free(graph);
            return 1;
        }

        if (remove_package(graph, pkg)) {
            hash_free(graph);
            return 1;
        }
    }

    if (save_cache(graph, cache_filename())) {
        hash_free(graph);
        return 1;
    }

    hash_free(graph);
    return 0;
}
Beispiel #2
0
int
cmd_remove(int argc, char *argv[])
{
	char *p;
	int ch;
	int flags = 0;
	gd_t gd;

	/* Get the remove options */
	while ((ch = getopt(argc, argv, "ab:i:s:t:")) != -1) {
		switch(ch) {
		case 'a':
			if (all > 0)
				usage_remove();
			all = 1;
			break;
		case 'b':
			if (block > 0)
				usage_remove();
			block = strtoll(optarg, &p, 10);
			if (*p != 0 || block < 1)
				usage_remove();
			break;
		case 'i':
			if (entry > 0)
				usage_remove();
			entry = strtol(optarg, &p, 10);
			if (*p != 0 || entry < 1)
				usage_remove();
			break;
		case 's':
			if (size > 0)
				usage_remove();
			size = strtoll(optarg, &p, 10);
			if (*p != 0 || size < 1)
				usage_remove();
			break;
		case 't':
			if (!uuid_is_nil(&type, NULL))
				usage_remove();
			if (parse_uuid(optarg, &type) != 0)
				usage_remove();
			break;
		default:
			usage_remove();
		}
	}

	if (!all ^
	    (block > 0 || entry > 0 || size > 0 || !uuid_is_nil(&type, NULL)))
		usage_remove();

	if (argc == optind)
		usage_remove();

	while (optind < argc) {
		gd = gpt_open(argv[optind++], flags);
		if (gd == NULL) {
			continue;
		}

		rem(gd);

		gpt_close(gd);
	}

	return (0);
}
Beispiel #3
0
int
cmd_remove(int argc, char *argv[])
{
	char *p;
	int ch, fd;

	/* Get the remove options */
	while ((ch = getopt(argc, argv, "ab:i:s:t:")) != -1) {
		switch(ch) {
		case 'a':
			if (all > 0)
				usage_remove();
			all = 1;
			break;
		case 'b':
			if (block > 0)
				usage_remove();
			block = strtoll(optarg, &p, 10);
			if (*p != 0 || block < 1)
				usage_remove();
			break;
		case 'i':
			if (entry != NOENTRY)
				usage_remove();
			entry = strtoul(optarg, &p, 10);
			if (*p != 0 || entry == NOENTRY)
				usage_remove();
			break;
		case 's':
			if (size > 0)
				usage_remove();
			size = strtoll(optarg, &p, 10);
			if (*p != 0 || size < 1)
				usage_remove();
			break;
		case 't':
			if (!uuid_is_nil(&type, NULL))
				usage_remove();
			if (parse_uuid(optarg, &type) != 0)
				usage_remove();
			break;
		default:
			usage_remove();
		}
	}

	if (!all ^
	    (block > 0 || entry != NOENTRY || size > 0 ||
	     !uuid_is_nil(&type, NULL)))
		usage_remove();

	if (argc == optind)
		usage_remove();

	while (optind < argc) {
		fd = gpt_open(argv[optind++]);
		if (fd == -1) {
			warn("unable to open device '%s'", device_name);
			continue;
		}

		rem(fd);

		gpt_close(fd);
	}

	return (0);
}