DAFS: fssync online requires a partition name argument

fssync-debug online silently fails when run without a partition name.
Check for the required partition name on the server side and the client
side.  Report errors back to the client when the server side fails to
pre-attach the volume.

Change-Id: I454b202ac83893b1ee54d586a46d891773090a64
Reviewed-on: http://gerrit.openafs.org/5615
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
This commit is contained in:
Michael Meffie 2011-10-13 12:23:35 -04:00 committed by Derrick Brashear
parent 87f969f82d
commit d171a5e059
2 changed files with 13 additions and 1 deletions

View File

@ -445,6 +445,10 @@ VolOnline(struct cmd_syndesc * as, void * rock)
common_prolog(as, &state);
common_volop_prolog(as, &state);
if (state.vop->partName==0 || *(state.vop->partName)==0) {
fprintf(stderr, "required argument -partition not given\n");
return -1;
}
do_volop(&state, FSYNC_VOL_ON, NULL);
return 0;

View File

@ -674,6 +674,7 @@ FSYNC_com_VolOn(FSSYNC_VolOp_command * vcom, SYNC_response * res)
Volume * vp;
Error error;
/* Verify the partition name is null terminated. */
if (SYNC_verifyProtocolString(vcom->vop->partName, sizeof(vcom->vop->partName))) {
res->hdr.reason = SYNC_REASON_MALFORMED_PACKET;
code = SYNC_FAILED;
@ -683,6 +684,13 @@ FSYNC_com_VolOn(FSSYNC_VolOp_command * vcom, SYNC_response * res)
/* so, we need to attach the volume */
#ifdef AFS_DEMAND_ATTACH_FS
/* Verify the partition name is not empty. */
if (*vcom->vop->partName == 0) {
res->hdr.reason = FSYNC_BAD_PART;
code = SYNC_FAILED;
goto done;
}
/* check DAFS permissions */
vp = VLookupVolume_r(&error, vcom->vop->volume, NULL);
if (vp &&
@ -763,11 +771,11 @@ FSYNC_com_VolOn(FSSYNC_VolOp_command * vcom, SYNC_response * res)
V_VOLUPD);
if (vp)
VPutVolume_r(vp);
#endif /* !AFS_DEMAND_ATTACH_FS */
if (error) {
code = SYNC_DENIED;
res->hdr.reason = error;
}
#endif /* !AFS_DEMAND_ATTACH_FS */
done:
return code;