static int connect_volume(const char * volumename) { if (strlen(volumename)==0) goto error; /* Ah, we're not connected to a volume*/ unsigned int len=0; char mesg[1024]; if ((vol = find_volume_by_name(server,volumename))==NULL) { printf("Could not find a volume called %s\n",volumename); goto error; } vol->mapping= AFP_MAPPING_LOGINIDS; vol->extra_flags |= VOLUME_EXTRA_FLAGS_NO_LOCKING; if (afp_connect_volume(vol,server,mesg,&len,1024 )) { printf("Could not access volume %s\n", vol->volume_name); goto error; } printf("Connected to volume %s\n",vol->volume_name_printable); return 0; error: return -1; }
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; }