Ejemplo n.º 1
0
int com_dir(char * arg)
{
	if (!arg)
		arg = "";

	struct afp_file_info *filebase = NULL, *p;

	if (server==NULL) {
		printf("You're not connected yet to a volume\n");
		goto error;
	}

	if (strlen(url.volumename)==0) {
		char names[1024];
		afp_list_volnames(server,names,1024);
		printf("You're not connected to a volume, choose from %s\n",
			names);
		goto out;
	}
	
	if (ml_readdir(vol,curdir,&filebase)) goto error;

	if (filebase==NULL) goto out;
	for (p=filebase;p;p=p->next) {
		print_file_details(p);
	}
	afp_ml_filebase_free(&filebase);

out:
	
	return 0;
error:
	return -1;
}
Ejemplo n.º 2
0
static struct afp_volume * mount_volume(struct fuse_client * c,
	struct afp_server * server, char * volname, char * volpassword) 
{
	struct afp_volume * using_volume;

	using_volume = find_volume_by_name(server,volname);

	if (!using_volume) {
		log_for_client((void *) c,AFPFSD,LOG_ERR,
			"Volume %s does not exist on server %s.\n",volname,
			server->server_name_printable);
		if (server->num_volumes) {
			char names[1024];
			afp_list_volnames(server,names,1024);
			log_for_client((void *)c,AFPFSD,LOG_ERR,
				"Choose from: %s\n",names);
		}
		goto error;
	}

	if (using_volume->mounted==AFP_VOLUME_MOUNTED) {
		log_for_client((void *)c,AFPFSD,LOG_ERR,
			"Volume %s is already mounted on %s\n",volname,
			using_volume->mountpoint);
		goto error;
	}

	if (using_volume->flags & HasPassword) {
		bcopy(volpassword,using_volume->volpassword,AFP_VOLPASS_LEN);
		if (strlen(volpassword)<1) {
			log_for_client((void *) c,AFPFSD,LOG_ERR,"Volume password needed\n");
			goto error;
		}
	}  else memset(using_volume->volpassword,0,AFP_VOLPASS_LEN);

	using_volume->server=server;

	if (volopen(c,using_volume)) {
		log_for_client((void *) c,AFPFSD,LOG_ERR,"Could not mount volume %s\n",volname);
		goto error;
	}


	return using_volume;
error:
	return NULL;
}