Call user_ent_hash_build() once after the getopt_long() loop if -p, -z
or -Z is used.
Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
char *pid_context;
char *sock_context;
const char *no_ctx = "unavailable";
- static int user_ent_hash_build_init;
-
- /* If show_users & show_proc_ctx set only do this once */
- if (user_ent_hash_build_init != 0)
- return;
-
- user_ent_hash_build_init = 1;
strlcpy(name, root, sizeof(name));
break;
case 'p':
show_users++;
- user_ent_hash_build();
break;
case 'b':
show_options = 1;
exit(1);
}
show_proc_ctx++;
- user_ent_hash_build();
break;
case 'N':
if (netns_switch(optarg))
}
}
+ if (show_users || show_proc_ctx || show_sock_ctx)
+ user_ent_hash_build();
+
argc -= optind;
argv += optind;