Пример #1
0
/// open device
static void fs_open(char* device)
{
    int open_flags;
    log_mesg(2, 0, 0, fs_opt.debug, "%s: nilfs_mount\n", __FILE__); 

    mnt_x = mount(device, mnt_path, "nilfs2", MS_MGC_VAL | MS_RDONLY | MS_NOSUID, "");
    open_flags = NILFS_OPEN_RDONLY | NILFS_OPEN_RAW;
    nilfs = nilfs_open(device, NULL, open_flags);
    if (nilfs == NULL) {
	umount(mnt_path);	
	log_mesg(0, 1, 1, fs_opt.debug, "%s: cannot open NILFS on %s: %m\n", __FILE__, device ? : "device");
    }
Пример #2
0
int main(int argc, char *argv[])
{
	struct nilfs *nilfs;
	struct nilfs_cpstat cpstat;
	char *dev, *progname;
	int c, mode, rvs, status, ret;
#ifdef _GNU_SOURCE
	int option_index;
#endif	/* _GNU_SOURCE */

	mode = NILFS_CHECKPOINT;
	rvs = 0;
	opterr = 0;	/* prevent error message */
	progname = strrchr(argv[0], '/');
	if (progname == NULL)
		progname = argv[0];
	else
		progname++;


#ifdef _GNU_SOURCE
	while ((c = getopt_long(argc, argv, "abgrsi:n:hV",
				long_option, &option_index)) >= 0) {
#else
	while ((c = getopt(argc, argv, "abgrsi:n:hV")) >= 0) {
#endif	/* _GNU_SOURCE */

		switch (c) {
		case 'a':
			show_all = 1;
			break;
		case 'b':
			show_block_count = 1;
			break;
		case 'g':
			show_block_count = 0;
			break;
		case 'r':
			rvs = 1;
			break;
		case 's':
			mode = NILFS_SNAPSHOT;
			break;
		case 'i':
			param_index = (__u64)atoll(optarg);
			break;
		case 'n':
			param_lines = (__u64)atoll(optarg);
			break;
		case 'h':
			fprintf(stderr, LSCP_USAGE, progname);
			exit(EXIT_SUCCESS);
		case 'V':
			printf("%s (%s %s)\n", progname, PACKAGE,
			       PACKAGE_VERSION);
			exit(EXIT_SUCCESS);
		default:
			fprintf(stderr, "%s: invalid option -- %c\n",
				progname, optopt);
			exit(EXIT_FAILURE);
		}
	}

	if (optind < argc - 1) {
		fprintf(stderr, "%s: too many arguments\n", progname);
		exit(1);
	} else if (optind == argc - 1) {
		dev = argv[optind++];
	} else {
		dev = NULL;
	}

	nilfs = nilfs_open(dev, NULL, NILFS_OPEN_RDONLY);
	if (nilfs == NULL) {
		fprintf(stderr, "%s: %s: cannot open NILFS\n",
			progname, dev);
		exit(EXIT_FAILURE);
	}

	status = EXIT_SUCCESS;

	ret = nilfs_get_cpstat(nilfs, &cpstat);
	if (ret < 0)
		goto out;

#ifdef CONFIG_PRINT_CPSTAT
	lscp_print_cpstat(&cpstat, mode);
#endif
	lscp_print_header();

	if (mode == NILFS_CHECKPOINT) {
		if (!rvs)
			ret = lscp_forward_cpinfo(nilfs, &cpstat);
		else
			ret = lscp_backward_cpinfo(nilfs, &cpstat);
	} else {
		if (!rvs)
			ret = lscp_forward_ssinfo(nilfs, &cpstat);
		else
			ret = lscp_backward_ssinfo(nilfs, &cpstat);
	}

 out:
	if (ret < 0) {
		status = EXIT_FAILURE;
		fprintf(stderr, "%s: %s\n", progname, strerror(errno));
	}
	nilfs_close(nilfs);
	exit(status);
}
Пример #3
0
int main(int argc, char *argv[])
{
	struct nilfs *nilfs;
	char *dev, *progname;
	int c, all, status;
#ifdef _GNU_SOURCE
	int option_index;
#endif	/* _GNU_SOURCE */

	all = 0;
	opterr = 0;
	progname = strrchr(argv[0], '/');
	if (progname == NULL)
		progname = argv[0];
	else
		progname++;

#ifdef _GNU_SOURCE
	while ((c = getopt_long(argc, argv, "ai:n:hV",
				long_option, &option_index)) >= 0) {
#else	/* !_GNU_SOURCE */
	while ((c = getopt(argc, argv, "ai:n:hV")) >= 0) {
#endif	/* _GNU_SOURCE */

		switch (c) {
		case 'a':
			all = 1;
			break;
		case 'i':
			param_index = (__u64)atoll(optarg);
			break;
		case 'n':
			param_lines = (__u64)atoll(optarg);
			break;
		case 'h':
			fprintf(stderr, LSSU_USAGE, progname);
			exit(0);
		case 'V':
			printf("%s (%s %s)\n", progname, PACKAGE,
			       PACKAGE_VERSION);
			exit(0);
		default:
			fprintf(stderr, "%s: invalid option -- %c\n",
				progname, optopt);
			exit(1);
		}
	}

	if (optind > argc - 1) {
		dev = NULL;
	} else if (optind == argc - 1) {
		dev = argv[optind++];
	} else {
		fprintf(stderr, "%s: too many arguments\n", progname);
		exit(1);
	}

	nilfs = nilfs_open(dev, NULL, NILFS_OPEN_RDONLY);
	if (nilfs == NULL) {
		fprintf(stderr, "%s: %s: cannot open NILFS\n",
			progname, dev);
		exit(1);
	}

	status = lssu_list_suinfo(nilfs, all);

	nilfs_close(nilfs);
	exit(status);
}