コード例 #1
0
ファイル: xdr4.c プロジェクト: mdamt/linux
static __be32 *
nlm4_decode_lock(__be32 *p, struct nlm_lock *lock)
{
	struct file_lock	*fl = &lock->fl;
	__u64			len, start;
	__s64			end;

	if (!(p = xdr_decode_string_inplace(p, &lock->caller,
					    &lock->len, NLM_MAXSTRLEN))
	 || !(p = nlm4_decode_fh(p, &lock->fh))
	 || !(p = nlm4_decode_oh(p, &lock->oh)))
		return NULL;
	lock->svid  = ntohl(*p++);

	locks_init_lock(fl);
	fl->fl_owner = current->files;
	fl->fl_pid   = (pid_t)lock->svid;
	fl->fl_flags = FL_POSIX;
	fl->fl_type  = F_RDLCK;		/* as good as anything else */
	p = xdr_decode_hyper(p, &start);
	p = xdr_decode_hyper(p, &len);
	end = start + len - 1;

	fl->fl_start = s64_to_loff_t(start);

	if (len == 0 || end < 0)
		fl->fl_end = OFFSET_MAX;
	else
		fl->fl_end = s64_to_loff_t(end);
	return p;
}
コード例 #2
0
ファイル: xdr4.c プロジェクト: 274914765/C
static int
nlm4clt_decode_testres(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
{
    if (!(p = nlm4_decode_cookie(p, &resp->cookie)))
        return -EIO;
    resp->status = *p++;
    if (resp->status == nlm_lck_denied) {
        struct file_lock    *fl = &resp->lock.fl;
        u32            excl;
        __u64            start, len;
        __s64            end;

        memset(&resp->lock, 0, sizeof(resp->lock));
        locks_init_lock(fl);
        excl = ntohl(*p++);
        resp->lock.svid = ntohl(*p++);
        fl->fl_pid = (pid_t)resp->lock.svid;
        if (!(p = nlm4_decode_oh(p, &resp->lock.oh)))
            return -EIO;

        fl->fl_flags = FL_POSIX;
        fl->fl_type  = excl? F_WRLCK : F_RDLCK;
        p = xdr_decode_hyper(p, &start);
        p = xdr_decode_hyper(p, &len);
        end = start + len - 1;

        fl->fl_start = s64_to_loff_t(start);
        if (len == 0 || end < 0)
            fl->fl_end = OFFSET_MAX;
        else
            fl->fl_end = s64_to_loff_t(end);
    }
    return 0;
}