module: Modify module_flags() to accept show_state argument
No functional change. With this patch a given module's state information (i.e. 'mod->state') can be omitted from the specified buffer. Please note that this is in preparation to include the last unloaded module's taint flag(s), if available. Signed-off-by: Aaron Tomlin <atomlin@redhat.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
This commit is contained in:
parent
73b4fc92f9
commit
17dd25c29c
@ -103,7 +103,7 @@ struct module *find_module_all(const char *name, size_t len, bool even_unformed)
|
|||||||
int cmp_name(const void *name, const void *sym);
|
int cmp_name(const void *name, const void *sym);
|
||||||
long module_get_offset(struct module *mod, unsigned int *size, Elf_Shdr *sechdr,
|
long module_get_offset(struct module *mod, unsigned int *size, Elf_Shdr *sechdr,
|
||||||
unsigned int section);
|
unsigned int section);
|
||||||
char *module_flags(struct module *mod, char *buf);
|
char *module_flags(struct module *mod, char *buf, bool show_state);
|
||||||
size_t module_flags_taint(unsigned long taints, char *buf);
|
size_t module_flags_taint(unsigned long taints, char *buf);
|
||||||
|
|
||||||
static inline void module_assert_mutex_or_preempt(void)
|
static inline void module_assert_mutex_or_preempt(void)
|
||||||
|
@ -2979,24 +2979,27 @@ static void cfi_cleanup(struct module *mod)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Keep in sync with MODULE_FLAGS_BUF_SIZE !!! */
|
/* Keep in sync with MODULE_FLAGS_BUF_SIZE !!! */
|
||||||
char *module_flags(struct module *mod, char *buf)
|
char *module_flags(struct module *mod, char *buf, bool show_state)
|
||||||
{
|
{
|
||||||
int bx = 0;
|
int bx = 0;
|
||||||
|
|
||||||
BUG_ON(mod->state == MODULE_STATE_UNFORMED);
|
BUG_ON(mod->state == MODULE_STATE_UNFORMED);
|
||||||
|
if (!mod->taints && !show_state)
|
||||||
|
goto out;
|
||||||
if (mod->taints ||
|
if (mod->taints ||
|
||||||
mod->state == MODULE_STATE_GOING ||
|
mod->state == MODULE_STATE_GOING ||
|
||||||
mod->state == MODULE_STATE_COMING) {
|
mod->state == MODULE_STATE_COMING) {
|
||||||
buf[bx++] = '(';
|
buf[bx++] = '(';
|
||||||
bx += module_flags_taint(mod->taints, buf + bx);
|
bx += module_flags_taint(mod->taints, buf + bx);
|
||||||
/* Show a - for module-is-being-unloaded */
|
/* Show a - for module-is-being-unloaded */
|
||||||
if (mod->state == MODULE_STATE_GOING)
|
if (mod->state == MODULE_STATE_GOING && show_state)
|
||||||
buf[bx++] = '-';
|
buf[bx++] = '-';
|
||||||
/* Show a + for module-is-being-loaded */
|
/* Show a + for module-is-being-loaded */
|
||||||
if (mod->state == MODULE_STATE_COMING)
|
if (mod->state == MODULE_STATE_COMING && show_state)
|
||||||
buf[bx++] = '+';
|
buf[bx++] = '+';
|
||||||
buf[bx++] = ')';
|
buf[bx++] = ')';
|
||||||
}
|
}
|
||||||
|
out:
|
||||||
buf[bx] = '\0';
|
buf[bx] = '\0';
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
@ -3129,7 +3132,7 @@ void print_modules(void)
|
|||||||
list_for_each_entry_rcu(mod, &modules, list) {
|
list_for_each_entry_rcu(mod, &modules, list) {
|
||||||
if (mod->state == MODULE_STATE_UNFORMED)
|
if (mod->state == MODULE_STATE_UNFORMED)
|
||||||
continue;
|
continue;
|
||||||
pr_cont(" %s%s", mod->name, module_flags(mod, buf));
|
pr_cont(" %s%s", mod->name, module_flags(mod, buf, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
print_unloaded_tainted_modules();
|
print_unloaded_tainted_modules();
|
||||||
|
@ -91,7 +91,7 @@ static int m_show(struct seq_file *m, void *p)
|
|||||||
|
|
||||||
/* Taints info */
|
/* Taints info */
|
||||||
if (mod->taints)
|
if (mod->taints)
|
||||||
seq_printf(m, " %s", module_flags(mod, buf));
|
seq_printf(m, " %s", module_flags(mod, buf, true));
|
||||||
|
|
||||||
seq_puts(m, "\n");
|
seq_puts(m, "\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user