}
static inline int
-same_name(const char *n1, const char *n2) {
+same_name(const char *n1, const char *n2)
+{
return 0 == memcmp(n1, n2, HEXDIR_LEN);
}
static int
-cmp_verf(nfs4_verifier *v1, nfs4_verifier *v2) {
- return(!memcmp(v1->data,v2->data,sizeof(v1->data)));
+same_verf(nfs4_verifier *v1, nfs4_verifier *v2)
+{
+ return 0 == memcmp(v1->data, v2->data, sizeof(v1->data));
}
static int
-cmp_clid(clientid_t * cl1, clientid_t * cl2) {
- return((cl1->cl_boot == cl2->cl_boot) &&
- (cl1->cl_id == cl2->cl_id));
+same_clid(clientid_t *cl1, clientid_t *cl2)
+{
+ return (cl1->cl_boot == cl2->cl_boot) && (cl1->cl_id == cl2->cl_id);
}
/* XXX what about NGROUP */
static int
-cmp_creds(struct svc_cred *cr1, struct svc_cred *cr2){
- return(cr1->cr_uid == cr2->cr_uid);
-
+same_creds(struct svc_cred *cr1, struct svc_cred *cr2)
+{
+ return cr1->cr_uid == cr2->cr_uid;
}
static void
unsigned int idhashval = clientid_hashval(clid->cl_id);
list_for_each_entry(clp, &conf_id_hashtbl[idhashval], cl_idhash) {
- if (cmp_clid(&clp->cl_clientid, clid))
+ if (same_clid(&clp->cl_clientid, clid))
return clp;
}
return NULL;
unsigned int idhashval = clientid_hashval(clid->cl_id);
list_for_each_entry(clp, &unconf_id_hashtbl[idhashval], cl_idhash) {
- if (cmp_clid(&clp->cl_clientid, clid))
+ if (same_clid(&clp->cl_clientid, clid))
return clp;
}
return NULL;
* or different ip_address
*/
status = nfserr_clid_inuse;
- if (!cmp_creds(&conf->cl_cred, &rqstp->rq_cred)
+ if (!same_creds(&conf->cl_cred, &rqstp->rq_cred)
|| conf->cl_addr != sin->sin_addr.s_addr) {
dprintk("NFSD: setclientid: string in use by client"
"at %u.%u.%u.%u\n", NIPQUAD(conf->cl_addr));
gen_confirm(new);
gen_callback(new, setclid);
add_to_unconfirmed(new, strhashval);
- } else if (cmp_verf(&conf->cl_verifier, &clverifier)) {
+ } else if (same_verf(&conf->cl_verifier, &clverifier)) {
/*
* CASE 1:
* cl_name match, confirmed, principal match
gen_confirm(new);
gen_callback(new, setclid);
add_to_unconfirmed(new, strhashval);
- } else if (!cmp_verf(&conf->cl_confirm, &unconf->cl_confirm)) {
+ } else if (!same_verf(&conf->cl_confirm, &unconf->cl_confirm)) {
/*
* CASE3:
* confirmed found (name, principal match)
goto out;
if ((conf && unconf) &&
- (cmp_verf(&unconf->cl_confirm, &confirm)) &&
- (cmp_verf(&conf->cl_verifier, &unconf->cl_verifier)) &&
+ (same_verf(&unconf->cl_confirm, &confirm)) &&
+ (same_verf(&conf->cl_verifier, &unconf->cl_verifier)) &&
(same_name(conf->cl_recdir,unconf->cl_recdir)) &&
- (!cmp_verf(&conf->cl_confirm, &unconf->cl_confirm))) {
+ (!same_verf(&conf->cl_confirm, &unconf->cl_confirm))) {
/* CASE 1:
* unconf record that matches input clientid and input confirm.
* conf record that matches input clientid.
* conf and unconf records match names, verifiers
*/
- if (!cmp_creds(&conf->cl_cred, &unconf->cl_cred))
+ if (!same_creds(&conf->cl_cred, &unconf->cl_cred))
status = nfserr_clid_inuse;
else {
/* XXX: We just turn off callbacks until we can handle
}
} else if ((conf && !unconf) ||
((conf && unconf) &&
- (!cmp_verf(&conf->cl_verifier, &unconf->cl_verifier) ||
+ (!same_verf(&conf->cl_verifier, &unconf->cl_verifier) ||
!same_name(conf->cl_recdir, unconf->cl_recdir)))) {
/* CASE 2:
* conf record that matches input clientid.
* unconf->cl_name or unconf->cl_verifier don't match the
* conf record.
*/
- if (!cmp_creds(&conf->cl_cred,&rqstp->rq_cred))
+ if (!same_creds(&conf->cl_cred, &rqstp->rq_cred))
status = nfserr_clid_inuse;
else
status = nfs_ok;
} else if (!conf && unconf
- && cmp_verf(&unconf->cl_confirm, &confirm)) {
+ && same_verf(&unconf->cl_confirm, &confirm)) {
/* CASE 3:
* conf record not found.
* unconf record found.
* unconf->cl_confirm matches input confirm
*/
- if (!cmp_creds(&unconf->cl_cred, &rqstp->rq_cred)) {
+ if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred)) {
status = nfserr_clid_inuse;
} else {
unsigned int hash =
conf = unconf;
status = nfs_ok;
}
- } else if ((!conf || (conf && !cmp_verf(&conf->cl_confirm, &confirm)))
- && (!unconf || (unconf && !cmp_verf(&unconf->cl_confirm,
+ } else if ((!conf || (conf && !same_verf(&conf->cl_confirm, &confirm)))
+ && (!unconf || (unconf && !same_verf(&unconf->cl_confirm,
&confirm)))) {
/* CASE 4:
* conf record not found, or if conf, conf->cl_confirm does not
}
static int
-cmp_owner_str(struct nfs4_stateowner *sop, struct xdr_netobj *owner, clientid_t *clid) {
- return ((sop->so_owner.len == owner->len) &&
- !memcmp(sop->so_owner.data, owner->data, owner->len) &&
- (sop->so_client->cl_clientid.cl_id == clid->cl_id));
+same_owner_str(struct nfs4_stateowner *sop, struct xdr_netobj *owner,
+ clientid_t *clid)
+{
+ return (sop->so_owner.len == owner->len) &&
+ 0 == memcmp(sop->so_owner.data, owner->data, owner->len) &&
+ (sop->so_client->cl_clientid.cl_id == clid->cl_id);
}
static struct nfs4_stateowner *
struct nfs4_stateowner *so = NULL;
list_for_each_entry(so, &ownerstr_hashtbl[hashval], so_strhash) {
- if (cmp_owner_str(so, &open->op_owner, &open->op_clientid))
+ if (same_owner_str(so, &open->op_owner, &open->op_clientid))
return so;
}
return NULL;
lkflg = setlkflg(lock->lk_type);
if (lock->lk_is_new) {
- if (!sop->so_is_open_owner)
- return nfserr_bad_stateid;
- if (!cmp_clid(&clp->cl_clientid, lockclid))
+ if (!sop->so_is_open_owner)
+ return nfserr_bad_stateid;
+ if (!same_clid(&clp->cl_clientid, lockclid))
return nfserr_bad_stateid;
- /* stp is the open stateid */
- status = nfs4_check_openmode(stp, lkflg);
- if (status)
- return status;
- } else {
- /* stp is the lock stateid */
- status = nfs4_check_openmode(stp->st_openstp, lkflg);
- if (status)
- return status;
+ /* stp is the open stateid */
+ status = nfs4_check_openmode(stp, lkflg);
+ if (status)
+ return status;
+ } else {
+ /* stp is the lock stateid */
+ status = nfs4_check_openmode(stp->st_openstp, lkflg);
+ if (status)
+ return status;
}
-
}
if ((flags & CHECK_FH) && nfs4_check_fh(current_fh, stp)) {
struct nfs4_stateowner *op;
list_for_each_entry(op, &lock_ownerstr_hashtbl[hashval], so_strhash) {
- if (cmp_owner_str(op, owner, clid))
+ if (same_owner_str(op, owner, clid))
return op;
}
return NULL;
INIT_LIST_HEAD(&matches);
for (i = 0; i < LOCK_HASH_SIZE; i++) {
list_for_each_entry(sop, &lock_ownerid_hashtbl[i], so_idhash) {
- if (!cmp_owner_str(sop, owner, clid))
+ if (!same_owner_str(sop, owner, clid))
continue;
list_for_each_entry(stp, &sop->so_stateids,
st_perstateowner) {