FreeBSD/sys/fs/nfsclient/nfs_clstate.c
/*
 * Search for a matching file, mode and, optionally, lockowner.
 */
Search for a matching file, mode and, optionally, lockowner.
Search for a matching file mode and optionally lockowner .
static int
nfscl_getopen(struct nfsclownerhead *ohp, u_int8_t *nfhp, int fhlen,
    u_int8_t *openown, u_int8_t *lockown, u_int32_t mode,
    struct nfscllockowner **lpp, struct nfsclopen **opp)
{
	struct nfsclowner *owp;
	struct nfsclopen *op, *rop, *rop2;
	struct nfscllockowner *lp;
	int keep_looping;
	if (lpp != NULL)
		*lpp = NULL;
	rop = NULL;
	rop2 = NULL;
	keep_looping = 1;
	owp = LIST_FIRST(ohp);
	while (owp != NULL && keep_looping != 0) {
		op = LIST_FIRST(&owp->nfsow_open);
		while (op != NULL && keep_looping != 0) {
			if (op->nfso_fhlen == fhlen &&
			    !NFSBCMP(op->nfso_fh, nfhp, fhlen)
			    && (op->nfso_mode & mode) == mode) {
				if (lpp != NULL) {
					LIST_FOREACH(lp, &op->nfso_lock,
					    nfsl_list) {
						if (!NFSBCMP(lp->nfsl_owner,
						    lockown,
						    NFSV4CL_LOCKNAMELEN)) {
							*lpp = lp;
							rop = op;
							keep_looping = 0;
							break;
						}
					}
				}
				if (rop == NULL && !NFSBCMP(owp->nfsow_owner,
				    openown, NFSV4CL_LOCKNAMELEN)) {
					rop = op;
					if (lpp == NULL)
						keep_looping = 0;
				}
				if (rop2 == NULL)
					rop2 = op;
			}
			op = LIST_NEXT(op, nfso_list);
		}
		owp = LIST_NEXT(owp, nfsow_list);
	}
	if (rop == NULL)
		rop = rop2;
	if (rop == NULL)
		return (EBADF);
	*opp = rop;
	return (0);
}
static int nfscl_getopen ( struct nfsclownerhead * ohp , u_int8_t * nfhp , int fhlen , u_int8_t * openown , u_int8_t * lockown , u_int32_t mode , struct nfscllockowner * * lpp , struct nfsclopen * * opp ) { struct nfsclowner * owp ; struct nfsclopen * op , * rop , * rop2 ; struct nfscllockowner * lp ; int keep_looping ; if ( lpp != NULL ) * lpp = NULL ; rop = NULL ; rop2 = NULL ; keep_looping = 1 ; owp = LIST_FIRST ( ohp ) ; while ( owp != NULL && keep_looping != 0 ) { op = LIST_FIRST ( & owp -> nfsow_open ) ; while ( op != NULL && keep_looping != 0 ) { if ( op -> nfso_fhlen == fhlen && ! NFSBCMP ( op -> nfso_fh , nfhp , fhlen ) && ( op -> nfso_mode & mode ) == mode ) { if ( lpp != NULL ) { LIST_FOREACH ( lp , & op -> nfso_lock , nfsl_list ) { if ( ! NFSBCMP ( lp -> nfsl_owner , lockown , NFSV4CL_LOCKNAMELEN ) ) { * lpp = lp ; rop = op ; keep_looping = 0 ; break ; } } } if ( rop == NULL && ! NFSBCMP ( owp -> nfsow_owner , openown , NFSV4CL_LOCKNAMELEN ) ) { rop = op ; if ( lpp == NULL ) keep_looping = 0 ; } if ( rop2 == NULL ) rop2 = op ; } op = LIST_NEXT ( op , nfso_list ) ; } owp = LIST_NEXT ( owp , nfsow_list ) ; } if ( rop == NULL ) rop = rop2 ; if ( rop == NULL ) return ( EBADF ) ; * opp = rop ; return ( 0 ) ; }
Search for a matching file, mode and, optionally, lockowner.
Search for a matching file mode and optionally lockowner .
/*
	 * rop will be set to the open to be returned. There are three
	 * variants of this, all for an open of the correct file:
	 * 1 - A match of lockown.
	 * 2 - A match of the openown, when no lockown match exists.
	 * 3 - A match for any open, if no openown or lockown match exists.
	 * Looking for #2 over #3 probably isn't necessary, but since
	 * RFC3530 is vague w.r.t. the relationship between openowners and
	 * lockowners, I think this is the safer way to go.
	 */ /* Search the client list */ /* and look for the correct open */ /* Now look for a matching lockowner. */