Print this page
asdf


 115 static void nlm_init_shrlock(struct shrlock *, nlm4_share *, struct nlm_host *);
 116 static callb_cpr_t *nlm_block_callback(flk_cb_when_t, void *);
 117 static int nlm_vop_frlock(vnode_t *, int, flock64_t *, int, offset_t,
 118     struct flk_callback *, cred_t *, caller_context_t *);
 119 
 120 /*
 121  * Convert a lock from network to local form, and
 122  * check for valid range (no overflow).
 123  */
 124 static int
 125 nlm_init_flock(struct flock64 *fl, struct nlm4_lock *nl,
 126         struct nlm_host *host, rpcvers_t vers, short type)
 127 {
 128         uint64_t off, len;
 129 
 130         bzero(fl, sizeof (*fl));
 131         off = nl->l_offset;
 132         len = nl->l_len;
 133 
 134         if (vers < NLM4_VERS) {
 135                 /*
 136                  * Make sure range is valid for 32-bit client.
 137                  * Also allow len == ~0 to mean lock to EOF,
 138                  * which is supposed to be l_len == 0.
 139                  */
 140                 if (len == MAX_UOFF32)
 141                         len = 0;
 142                 if (off > MAX_UOFF32 || len > MAX_UOFF32)
 143                         return (EINVAL);
 144                 if (off + len > MAX_UOFF32 + 1)
 145                         return (EINVAL);
 146         } else {
 147                 /*
 148                  * Check range for 64-bit client (no overflow).
 149                  * Again allow len == ~0 to mean lock to EOF.
 150                  */
 151                 if (len == MAX_U_OFFSET_T)
 152                         len = 0;
 153                 if (len != 0 && off + (len - 1) < off)
 154                         return (EINVAL);
 155         }
 156 
 157         fl->l_type = type;
 158         fl->l_whence = SEEK_SET;
 159         fl->l_start = off;
 160         fl->l_len = len;
 161         fl->l_sysid = host->nh_sysid;




 115 static void nlm_init_shrlock(struct shrlock *, nlm4_share *, struct nlm_host *);
 116 static callb_cpr_t *nlm_block_callback(flk_cb_when_t, void *);
 117 static int nlm_vop_frlock(vnode_t *, int, flock64_t *, int, offset_t,
 118     struct flk_callback *, cred_t *, caller_context_t *);
 119 
 120 /*
 121  * Convert a lock from network to local form, and
 122  * check for valid range (no overflow).
 123  */
 124 static int
 125 nlm_init_flock(struct flock64 *fl, struct nlm4_lock *nl,
 126         struct nlm_host *host, rpcvers_t vers, short type)
 127 {
 128         uint64_t off, len;
 129 
 130         bzero(fl, sizeof (*fl));
 131         off = nl->l_offset;
 132         len = nl->l_len;
 133 
 134         if (vers < NLM4_VERS) {







 135                 if (off > MAX_UOFF32 || len > MAX_UOFF32)
 136                         return (EINVAL);
 137                 if (off + len > MAX_UOFF32 + 1)
 138                         return (EINVAL);
 139         } else {
 140                 /*
 141                  * Check range for 64-bit client (no overflow).
 142                  * Again allow len == ~0 to mean lock to EOF.
 143                  */
 144                 if (len == MAX_U_OFFSET_T)
 145                         len = 0;
 146                 if (len != 0 && off + (len - 1) < off)
 147                         return (EINVAL);
 148         }
 149 
 150         fl->l_type = type;
 151         fl->l_whence = SEEK_SET;
 152         fl->l_start = off;
 153         fl->l_len = len;
 154         fl->l_sysid = host->nh_sysid;