Beispiel #1
0
static int
xp_file_copy(Xpcopy *c)
{
	Xpfile *f;

	for(f = c->cfile; f!=NULL && f->perm&Dmdir; f = f->next)
		;

	c->cfile = f;
	if (!f) {
		if (c->finish)
			(*c->finish)(c, c->finishaux);
		return 0;
	}

	f->spcfd = spcfd_add(f->fid, xp_file_notify, c, 0);
	if (!f->spcfd) {
		if (c->finish)
			(*c->finish)(c, c->finishaux);
		return -1;
	}

	xp_file_notify(f->spcfd, c);
	return 0;
}
int
main(int argc, char **argv)
{
	int c;
	char *addr;
	char *uname, *path;
	Spuser *user;
	Spcfsys *fs;
	Spcfid *fid;

	user = sp_uid2user(geteuid());
	if (!user) {
		fprintf(stderr, "cannot retrieve user %d\n", geteuid());
		exit(1);
	}

	uname = user->uname;
	while ((c = getopt(argc, argv, "dp:")) != -1) {
		switch (c) {
		case 'd':
			spc_chatty = 1;
			break;

		case 'u':
			uname = optarg;
			break;

		default:
			usage();
		}
	}

	

	if (argc - optind < 2)
		usage();

	addr = argv[optind];
	path = argv[optind+1];

	fs = spc_netmount(addr, uname, 564);
	fid = spc_open(fs, path, Oread);
	if (!fid) {
		fprintf(stderr, "cannot open\n");
		exit(1);
	}

	ispcfd = spcfd_add(fid, in_notify, fid);
	spcfd_start_loop();
	spc_close(fid);
	spc_umount(fs);

	exit(0);
}