Deleted Added
full compact
lockd_lock.c (115004) lockd_lock.c (121558)
1/* $NetBSD: lockd_lock.c,v 1.5 2000/11/21 03:47:41 enami Exp $ */
1/* $NetBSD: lockd_lock.c,v 1.5 2000/11/21 03:47:41 enami Exp $ */
2/* $FreeBSD: head/usr.sbin/rpc.lockd/lockd_lock.c 115004 2003-05-14 21:16:33Z rwatson $ */
2/* $FreeBSD: head/usr.sbin/rpc.lockd/lockd_lock.c 121558 2003-10-26 06:10:44Z peter $ */
3
4/*
5 * Copyright (c) 2001 Andrew P. Lentvorski, Jr.
6 * Copyright (c) 2000 Manuel Bouyer.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:

--- 144 unchanged lines hidden (view full) ---

155enum split_status {SPL_DISJOINT=0, SPL_LOCK1=1, SPL_LOCK2=2, SPL_CONTAINED=4, SPL_RESERR=8};
156
157enum partialfilelock_status lock_partialfilelock(struct file_lock *fl);
158
159void send_granted(struct file_lock *fl, int opcode);
160void siglock(void);
161void sigunlock(void);
162void monitor_lock_host(const char *hostname);
3
4/*
5 * Copyright (c) 2001 Andrew P. Lentvorski, Jr.
6 * Copyright (c) 2000 Manuel Bouyer.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:

--- 144 unchanged lines hidden (view full) ---

155enum split_status {SPL_DISJOINT=0, SPL_LOCK1=1, SPL_LOCK2=2, SPL_CONTAINED=4, SPL_RESERR=8};
156
157enum partialfilelock_status lock_partialfilelock(struct file_lock *fl);
158
159void send_granted(struct file_lock *fl, int opcode);
160void siglock(void);
161void sigunlock(void);
162void monitor_lock_host(const char *hostname);
163void unmonitor_lock_host(const char *hostname);
163void unmonitor_lock_host(char *hostname);
164
165void copy_nlm4_lock_to_nlm4_holder(const struct nlm4_lock *src,
166 const bool_t exclusive, struct nlm4_holder *dest);
167struct file_lock * allocate_file_lock(const netobj *lockowner,
168 const netobj *matchcookie);
169void deallocate_file_lock(struct file_lock *fl);
170void fill_file_lock(struct file_lock *fl, const fhandle_t *fh,
171 struct sockaddr *addr, const bool_t exclusive, const int32_t svid,

--- 1850 unchanged lines hidden (view full) ---

2022
2023 smon.mon_id.mon_name = nhp->name;
2024 smon.mon_id.my_id.my_name = "localhost\0";
2025
2026 smon.mon_id.my_id.my_prog = NLM_PROG;
2027 smon.mon_id.my_id.my_vers = NLM_SM;
2028 smon.mon_id.my_id.my_proc = NLM_SM_NOTIFY;
2029
164
165void copy_nlm4_lock_to_nlm4_holder(const struct nlm4_lock *src,
166 const bool_t exclusive, struct nlm4_holder *dest);
167struct file_lock * allocate_file_lock(const netobj *lockowner,
168 const netobj *matchcookie);
169void deallocate_file_lock(struct file_lock *fl);
170void fill_file_lock(struct file_lock *fl, const fhandle_t *fh,
171 struct sockaddr *addr, const bool_t exclusive, const int32_t svid,

--- 1850 unchanged lines hidden (view full) ---

2022
2023 smon.mon_id.mon_name = nhp->name;
2024 smon.mon_id.my_id.my_name = "localhost\0";
2025
2026 smon.mon_id.my_id.my_prog = NLM_PROG;
2027 smon.mon_id.my_id.my_vers = NLM_SM;
2028 smon.mon_id.my_id.my_proc = NLM_SM_NOTIFY;
2029
2030 rpcret = callrpc("localhost", SM_PROG, SM_VERS, SM_MON, xdr_mon,
2031 &smon, xdr_sm_stat_res, &sres);
2030 rpcret = callrpc("localhost", SM_PROG, SM_VERS, SM_MON,
2031 (xdrproc_t)xdr_mon, &smon,
2032 (xdrproc_t)xdr_sm_stat_res, &sres);
2032
2033 if (rpcret == 0) {
2034 if (sres.res_stat == stat_fail) {
2035 debuglog("Statd call failed\n");
2036 statflag = 0;
2037 } else {
2038 statflag = 1;
2039 }

--- 10 unchanged lines hidden (view full) ---

2050 }
2051
2052}
2053
2054/*
2055 * unmonitor_lock_host: clear monitor ref counts and inform statd when gone
2056 */
2057void
2033
2034 if (rpcret == 0) {
2035 if (sres.res_stat == stat_fail) {
2036 debuglog("Statd call failed\n");
2037 statflag = 0;
2038 } else {
2039 statflag = 1;
2040 }

--- 10 unchanged lines hidden (view full) ---

2051 }
2052
2053}
2054
2055/*
2056 * unmonitor_lock_host: clear monitor ref counts and inform statd when gone
2057 */
2058void
2058unmonitor_lock_host(const char *hostname)
2059unmonitor_lock_host(char *hostname)
2059{
2060 struct host *ihp;
2061 struct mon_id smon_id;
2062 struct sm_stat smstat;
2063 int rpcret;
2064
2065 rpcret = 0;
2066

--- 25 unchanged lines hidden (view full) ---

2092 bzero(&smon_id,sizeof(smon_id));
2093
2094 smon_id.mon_name = hostname;
2095 smon_id.my_id.my_name = "localhost";
2096 smon_id.my_id.my_prog = NLM_PROG;
2097 smon_id.my_id.my_vers = NLM_SM;
2098 smon_id.my_id.my_proc = NLM_SM_NOTIFY;
2099
2060{
2061 struct host *ihp;
2062 struct mon_id smon_id;
2063 struct sm_stat smstat;
2064 int rpcret;
2065
2066 rpcret = 0;
2067

--- 25 unchanged lines hidden (view full) ---

2093 bzero(&smon_id,sizeof(smon_id));
2094
2095 smon_id.mon_name = hostname;
2096 smon_id.my_id.my_name = "localhost";
2097 smon_id.my_id.my_prog = NLM_PROG;
2098 smon_id.my_id.my_vers = NLM_SM;
2099 smon_id.my_id.my_proc = NLM_SM_NOTIFY;
2100
2100 rpcret = callrpc("localhost", SM_PROG, SM_VERS, SM_UNMON, xdr_mon,
2101 &smon_id, xdr_sm_stat_res, &smstat);
2101 rpcret = callrpc("localhost", SM_PROG, SM_VERS, SM_UNMON,
2102 (xdrproc_t)xdr_mon, &smon_id,
2103 (xdrproc_t)xdr_sm_stat_res, &smstat);
2102
2103 if (rpcret != 0) {
2104 debuglog("Rpc call to unmonitor statd failed with "
2105 " return value: %d\n", rpcret);
2106 }
2107
2108 LIST_REMOVE(ihp, hostlst);
2109 free(ihp);

--- 68 unchanged lines hidden (view full) ---

2178 res.alock.oh = fl->client.oh;
2179 res.alock.svid = fl->client.svid;
2180 res.alock.l_offset = fl->client.l_offset;
2181 res.alock.l_len = fl->client.l_len;
2182 debuglog("sending v4 reply%s",
2183 (fl->flags & LOCK_ASYNC) ? " (async)":"");
2184 if (fl->flags & LOCK_ASYNC) {
2185 success = clnt_call(cli, NLM4_GRANTED_MSG,
2104
2105 if (rpcret != 0) {
2106 debuglog("Rpc call to unmonitor statd failed with "
2107 " return value: %d\n", rpcret);
2108 }
2109
2110 LIST_REMOVE(ihp, hostlst);
2111 free(ihp);

--- 68 unchanged lines hidden (view full) ---

2180 res.alock.oh = fl->client.oh;
2181 res.alock.svid = fl->client.svid;
2182 res.alock.l_offset = fl->client.l_offset;
2183 res.alock.l_len = fl->client.l_len;
2184 debuglog("sending v4 reply%s",
2185 (fl->flags & LOCK_ASYNC) ? " (async)":"");
2186 if (fl->flags & LOCK_ASYNC) {
2187 success = clnt_call(cli, NLM4_GRANTED_MSG,
2186 xdr_nlm4_testargs, &res, xdr_void, &dummy, timeo);
2188 (xdrproc_t)xdr_nlm4_testargs, &res,
2189 (xdrproc_t)xdr_void, &dummy, timeo);
2187 } else {
2188 success = clnt_call(cli, NLM4_GRANTED,
2190 } else {
2191 success = clnt_call(cli, NLM4_GRANTED,
2189 xdr_nlm4_testargs, &res, xdr_nlm4_res,
2190 &retval4, timeo);
2192 (xdrproc_t)xdr_nlm4_testargs, &res,
2193 (xdrproc_t)xdr_nlm4_res, &retval4, timeo);
2191 }
2192 } else {
2193 static nlm_testargs res;
2194
2195 res.cookie = fl->client_cookie;
2196 res.exclusive = fl->client.exclusive;
2197 res.alock.caller_name = fl->client_name;
2198 res.alock.fh.n_len = sizeof(fhandle_t);
2199 res.alock.fh.n_bytes = (char*)&fl->filehandle;
2200 res.alock.oh = fl->client.oh;
2201 res.alock.svid = fl->client.svid;
2202 res.alock.l_offset = fl->client.l_offset;
2203 res.alock.l_len = fl->client.l_len;
2204 debuglog("sending v1 reply%s",
2205 (fl->flags & LOCK_ASYNC) ? " (async)":"");
2206 if (fl->flags & LOCK_ASYNC) {
2207 success = clnt_call(cli, NLM_GRANTED_MSG,
2194 }
2195 } else {
2196 static nlm_testargs res;
2197
2198 res.cookie = fl->client_cookie;
2199 res.exclusive = fl->client.exclusive;
2200 res.alock.caller_name = fl->client_name;
2201 res.alock.fh.n_len = sizeof(fhandle_t);
2202 res.alock.fh.n_bytes = (char*)&fl->filehandle;
2203 res.alock.oh = fl->client.oh;
2204 res.alock.svid = fl->client.svid;
2205 res.alock.l_offset = fl->client.l_offset;
2206 res.alock.l_len = fl->client.l_len;
2207 debuglog("sending v1 reply%s",
2208 (fl->flags & LOCK_ASYNC) ? " (async)":"");
2209 if (fl->flags & LOCK_ASYNC) {
2210 success = clnt_call(cli, NLM_GRANTED_MSG,
2208 xdr_nlm_testargs, &res, xdr_void, &dummy, timeo);
2211 (xdrproc_t)xdr_nlm_testargs, &res,
2212 (xdrproc_t)xdr_void, &dummy, timeo);
2209 } else {
2210 success = clnt_call(cli, NLM_GRANTED,
2213 } else {
2214 success = clnt_call(cli, NLM_GRANTED,
2211 xdr_nlm_testargs, &res, xdr_nlm_res,
2212 &retval, timeo);
2215 (xdrproc_t)xdr_nlm_testargs, &res,
2216 (xdrproc_t)xdr_nlm_res, &retval, timeo);
2213 }
2214 }
2215 if (debug_level > 2)
2216 debuglog("clnt_call returns %d(%s) for granted",
2217 success, clnt_sperrno(success));
2218
2219}
2220

--- 38 unchanged lines hidden ---
2217 }
2218 }
2219 if (debug_level > 2)
2220 debuglog("clnt_call returns %d(%s) for granted",
2221 success, clnt_sperrno(success));
2222
2223}
2224

--- 38 unchanged lines hidden ---