@@ -39,6 +39,11 @@ struct lnc {
3939 char lnc_name [NCHNAMLEN + 1 ]; /* name */
4040};
4141
42+ /* For NetBSD 10 compat */
43+ #ifndef NC_NLEN
44+ #define NC_NLEN (ncp ) ((ncp)->nc_nlen)
45+ #endif
46+
4247static const rb_tree_ops_t lnc_rbtree_ops = {
4348 .rbto_compare_nodes = lnc_compare_nodes ,
4449 .rbto_compare_key = lnc_compare_key ,
@@ -84,7 +89,7 @@ static struct lnc *ncache_enter_local(KA_T vp, const struct lnc *plnc,
8489 }
8590 lnc -> lnc_vp = vp ;
8691 lnc -> lnc_plnc = plnc ;
87- lnc -> lnc_nlen = nc -> nc_nlen ;
92+ lnc -> lnc_nlen = NC_NLEN ( nc ) ;
8893 memcpy (lnc -> lnc_name , nc -> nc_name , lnc -> lnc_nlen );
8994 lnc -> lnc_name [lnc -> lnc_nlen ] = 0 ;
9095
@@ -104,13 +109,13 @@ static int sanity_check_namecache(const struct namecache *nc) {
104109 if (nc -> nc_vp == NULL )
105110 return -1 ;
106111
107- if (nc -> nc_nlen > NCHNAMLEN )
112+ if (NC_NLEN ( nc ) > NCHNAMLEN )
108113 return -1 ;
109114
110- if (nc -> nc_nlen == 1 && nc -> nc_name [0 ] == '.' )
115+ if (NC_NLEN ( nc ) == 1 && nc -> nc_name [0 ] == '.' )
111116 return -1 ;
112117
113- if (nc -> nc_nlen == 2 && nc -> nc_name [0 ] == '.' && nc -> nc_name [1 ] == '.' )
118+ if (NC_NLEN ( nc ) == 2 && nc -> nc_name [0 ] == '.' && nc -> nc_name [1 ] == '.' )
114119 return -1 ;
115120
116121 return 0 ;
@@ -137,21 +142,21 @@ static void ncache_walk(struct lsof_context *ctx, KA_T ncp,
137142 if (sanity_check_vnode_impl (& vi ) == 0 && sanity_check_namecache (& nc ) == 0 ) {
138143 lnc = ncache_enter_local (vp , plnc , & nc );
139144 if (vi .vi_vnode .v_type == VDIR && vi .vi_nc_tree .rbt_root != NULL ) {
140- ncache_walk ((KA_T )vi .vi_nc_tree .rbt_root , lnc );
145+ ncache_walk (ctx , (KA_T )vi .vi_nc_tree .rbt_root , lnc );
141146 }
142147 }
143148 if (left )
144- ncache_walk (left , plnc );
149+ ncache_walk (ctx , left , plnc );
145150 if (right )
146- ncache_walk (right , plnc );
151+ ncache_walk (ctx , right , plnc );
147152}
148153
149154void ncache_load (struct lsof_context * ctx ) {
150155 KA_T rootvnode_addr ;
151156 struct vnode_impl vi ;
152157
153158 rootvnode_addr = (KA_T )0 ;
154- if (get_Nl_value ("rootvnode" , (struct drive_Nl * )NULL , & rootvnode_addr ) <
159+ if (get_Nl_value (ctx , "rootvnode" , (struct drive_Nl * )NULL , & rootvnode_addr ) <
155160 0 ||
156161 !rootvnode_addr ||
157162 kread (ctx , (KA_T )rootvnode_addr , (char * )& rootvnode_addr ,
@@ -161,7 +166,7 @@ void ncache_load(struct lsof_context *ctx) {
161166 }
162167
163168 rb_tree_init (& lnc_rbtree , & lnc_rbtree_ops );
164- ncache_walk ((KA_T )vi .vi_nc_tree .rbt_root , 0 );
169+ ncache_walk (ctx , (KA_T )vi .vi_nc_tree .rbt_root , 0 );
165170}
166171
167172static void build_path (char * * buf , size_t * remaining , const struct lnc * lnc ) {
@@ -187,7 +192,7 @@ static void build_path(char **buf, size_t *remaining, const struct lnc *lnc) {
187192 * buf += len ;
188193}
189194
190- char * ncache_lookup (char * buf , int blen , int * fp ) {
195+ char * ncache_lookup (struct lsof_context * ctx , char * buf , int blen , int * fp ) {
191196 const struct lnc * lnc ;
192197 char * p ;
193198 size_t remaining ;
0 commit comments