int afp_unmount_all_volumes(struct afp_server * server) { int i; for (i=0;i<server->num_volumes;i++) { if (server->volumes[i].mounted == AFP_VOLUME_MOUNTED) { if (afp_unmount_volume(&server->volumes[i])) return 1; } } return 0; }
static void afp_destroy(void * ignore) { struct afp_volume * volume= (struct afp_volume *) ((struct fuse_context *)(fuse_get_context()))->private_data; if (volume->mounted==AFP_VOLUME_UNMOUNTED) { log_for_client(NULL,AFPFSD,LOG_WARNING,"Skipping unmounting of the volume %s\n",volume->volume_name_printable); return; } if ((!volume) || (!volume->server)) return; /* We're just ignoring the results since there's nothing we could do with them anyway. */ afp_unmount_volume(volume); }
int com_disconnect(char * arg) { if (server==NULL) { printf("You're not connected yet to a server\n"); goto error; } afp_unmount_volume(vol); vol=NULL; server=NULL; snprintf(curdir,AFP_MAX_PATH,"/"); return 0; error: return -1; }
void daemon_forced_ending_hook(void) { struct afp_server * s = get_server_base(); struct afp_volume * volume; int i; for (s=get_server_base();s;s=s->next) { if (s->connect_state==SERVER_STATE_CONNECTED) for (i=0;i<s->num_volumes;i++) { volume=&s->volumes[i]; if (volume->mounted==AFP_VOLUME_MOUNTED) log_for_client(NULL,AFPFSD,LOG_NOTICE, "Unmounting %s\n",volume->mountpoint); afp_unmount_volume(volume); } } remove_all_clients(); }
static unsigned char process_unmount(struct fuse_client * c) { struct afp_server_unmount_request * req; struct afp_server * s; struct afp_volume * v; int j=0; req=(void *) c->incoming_string+1; for (s=get_server_base();s;s=s->next) { for (j=0;j<s->num_volumes;j++) { v=&s->volumes[j]; if (strcmp(v->mountpoint,req->mountpoint)==0) { goto found; } } } goto notfound; found: if (v->mounted != AFP_VOLUME_MOUNTED ) { log_for_client((void *) c,AFPFSD,LOG_NOTICE, "%s was not mounted\n",v->mountpoint); return AFP_SERVER_RESULT_ERROR; } afp_unmount_volume(v); return AFP_SERVER_RESULT_OKAY; notfound: log_for_client((void *)c,AFPFSD,LOG_WARNING, "afpfs-ng doesn't have anything mounted on %s.\n",req->mountpoint); return AFP_SERVER_RESULT_ERROR; }
int afp_connect_volume(struct afp_volume * volume, struct afp_server * server, char * mesg, unsigned int * l, unsigned int max) { unsigned short bitmap= kFPVolAttributeBit|kFPVolSignatureBit| kFPVolCreateDateBit|kFPVolIDBit | kFPVolNameBit; char new_encoding; int ret; if (server->using_version->av_number>=30) bitmap|= kFPVolNameBit|kFPVolBlockSizeBit; ret = afp_volopen(volume,bitmap, (strlen(volume->volpassword)>0) ? volume->volpassword : NULL); switch(ret){ case kFPAccessDenied: *l+=snprintf(mesg,max-*l, "Incorrect volume password\n"); goto error; case kFPNoErr: break; case kFPBitmapErr: case kFPMiscErr: case kFPObjectNotFound: case kFPParamErr: *l+=snprintf(mesg,max-*l, "Could not open volume\n"); goto error; case ETIMEDOUT: *l+=snprintf(mesg,max-*l, "Timed out waiting to open volume\n"); goto error; } /* It is said that if a volume's encoding will be the same * the server's. */ if (volume->attributes & kSupportsUTF8Names) new_encoding=kFPUTF8Name; else new_encoding=kFPLongName; if (new_encoding != server->path_encoding) { *l+=snprintf(mesg,max-*l, "Volume %s changes the server's encoding\n", volume->volume_name_printable); } server->path_encoding=new_encoding; if (volume->signature != AFP_VOL_FIXED) { *l+=snprintf(mesg,max-*l, "Volume %s does not support fixed directories\n", volume->volume_name_printable); afp_unmount_volume(volume); goto error; } if (server->using_version->av_number >=30) { if ((volume->server->server_type==AFPFS_SERVER_TYPE_NETATALK) && (~ volume->attributes & kSupportsUnixPrivs)) { volume->extra_flags &=~VOLUME_EXTRA_FLAGS_VOL_SUPPORTS_UNIX; } else { volume->extra_flags |= VOLUME_EXTRA_FLAGS_VOL_SUPPORTS_UNIX; } } else { /* This is very odd, but AFP 2.x doesn't give timestamps for directories */ } volume->mounted=AFP_VOLUME_MOUNTED; return 0; error: return 1; }