static int smb_rq_getenv(struct smb_connobj *co, struct smb_vc **vcpp, struct smb_share **sspp) { struct smb_vc *vcp = NULL; struct smb_share *ssp = NULL; int error = EINVAL; if (co->co_flags & SMBO_GONE) { SMBSDEBUG("zombie CO\n"); error = EINVAL; goto out; } switch (co->co_level) { case SMBL_SHARE: ssp = CPTOSS(co); if ((co->co_flags & SMBO_GONE) || co->co_parent == NULL) { SMBSDEBUG("zombie share %s\n", ssp->ss_name); break; } /* instead of recursion... */ co = co->co_parent; /* FALLTHROUGH */ case SMBL_VC: vcp = CPTOVC(co); if ((co->co_flags & SMBO_GONE) || co->co_parent == NULL) { SMBSDEBUG("zombie VC %s\n", vcp->vc_srvname); break; } error = 0; break; default: SMBSDEBUG("invalid level %d passed\n", co->co_level); } out: if (!error) { if (vcpp) *vcpp = vcp; if (sspp) *sspp = ssp; } return (error); }
static int smb_rq_getenv(struct smb_connobj *layer, struct smb_vc **vcpp, struct smb_share **sspp) { struct smb_vc *vcp = NULL; struct smb_share *ssp = NULL; struct smb_connobj *cp; int error = 0; switch (layer->co_level) { case SMBL_VC: vcp = CPTOVC(layer); if (layer->co_parent == NULL) { SMBERROR("zombie VC %s\n", vcp->vc_srvname); error = EINVAL; break; } break; case SMBL_SHARE: ssp = CPTOSS(layer); cp = layer->co_parent; if (cp == NULL) { SMBERROR("zombie share %s\n", ssp->ss_name); error = EINVAL; break; } error = smb_rq_getenv(cp, &vcp, NULL); if (error) break; break; default: SMBERROR("invalid layer %d passed\n", layer->co_level); error = EINVAL; } if (vcpp) *vcpp = vcp; if (sspp) *sspp = ssp; return error; }