Beispiel #1
0
/*
 * Encode a lock as part of an NLM call
 */
static __be32 *
nlm4_encode_lock(__be32 *p, struct nlm_lock *lock)
{
    struct file_lock    *fl = &lock->fl;
    __s64            start, len;

    if (!(p = xdr_encode_string(p, lock->caller))
     || !(p = nlm4_encode_fh(p, &lock->fh))
     || !(p = nlm4_encode_oh(p, &lock->oh)))
        return NULL;

    if (fl->fl_start > NLM4_OFFSET_MAX
     || (fl->fl_end > NLM4_OFFSET_MAX && fl->fl_end != OFFSET_MAX))
        return NULL;

    *p++ = htonl(lock->svid);

    start = loff_t_to_s64(fl->fl_start);
    if (fl->fl_end == OFFSET_MAX)
        len = 0;
    else
        len = loff_t_to_s64(fl->fl_end - fl->fl_start + 1);

    p = xdr_encode_hyper(p, start);
    p = xdr_encode_hyper(p, len);

    return p;
}
static void nlm4_compute_offsets(const struct nlm_lock *lock,
				 u64 *l_offset, u64 *l_len)
{
	const struct file_lock *fl = &lock->fl;

	BUG_ON(fl->fl_start > NLM4_OFFSET_MAX);
	BUG_ON(fl->fl_end > NLM4_OFFSET_MAX &&
				fl->fl_end != OFFSET_MAX);

	*l_offset = loff_t_to_s64(fl->fl_start);
	if (fl->fl_end == OFFSET_MAX)
		*l_len = 0;
	else
		*l_len = loff_t_to_s64(fl->fl_end - fl->fl_start + 1);
}
Beispiel #3
0
/*
 * Encode result of a TEST/TEST_MSG call
 */
static __be32 *
nlm4_encode_testres(__be32 *p, struct nlm_res *resp)
{
	s64		start, len;

	dprintk("xdr: before encode_testres (p %p resp %p)\n", p, resp);
	if (!(p = nlm4_encode_cookie(p, &resp->cookie)))
		return NULL;
	*p++ = resp->status;

	if (resp->status == nlm_lck_denied) {
		struct file_lock	*fl = &resp->lock.fl;

		*p++ = (fl->fl_type == F_RDLCK)? xdr_zero : xdr_one;
		*p++ = htonl(resp->lock.svid);

		/* Encode owner handle. */
		if (!(p = xdr_encode_netobj(p, &resp->lock.oh)))
			return NULL;

		start = loff_t_to_s64(fl->fl_start);
		if (fl->fl_end == OFFSET_MAX)
			len = 0;
		else
			len = loff_t_to_s64(fl->fl_end - fl->fl_start + 1);
		
		p = xdr_encode_hyper(p, start);
		p = xdr_encode_hyper(p, len);
		dprintk("xdr: encode_testres (status %u pid %d type %d start %Ld end %Ld)\n",
			resp->status, (int)resp->lock.svid, fl->fl_type,
			(long long)fl->fl_start,  (long long)fl->fl_end);
	}

	dprintk("xdr: after encode_testres (p %p resp %p)\n", p, resp);
	return p;
}