Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 284657
b: refs/heads/master
c: cca3e70
h: refs/heads/master
i:
  284655: bdd7d69
v: v3
  • Loading branch information
Kay Sievers authored and Rusty Russell committed Jan 12, 2012
1 parent 2c1958b commit 466f302
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 30 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8487bfd954928660a52e91384a9b1f1049217e35
refs/heads/master: cca3e707301862ca9b9327e6a732463982f8cd1b
16 changes: 16 additions & 0 deletions trunk/Documentation/ABI/testing/sysfs-module
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,19 @@ Description: Maximum time allowed for periodic transfers per microframe (μs)
Beware, non-standard modes are usually not thoroughly tested by
hardware designers, and the hardware can malfunction when this
setting differ from default 100.

What: /sys/module/*/{coresize,initsize}
Date: Jan 2012
KernelVersion:»·3.3
Contact: Kay Sievers <kay.sievers@vrfy.org>
Description: Module size in bytes.

What: /sys/module/*/taint
Date: Jan 2012
KernelVersion:»·3.3
Contact: Kay Sievers <kay.sievers@vrfy.org>
Description: Module taint flags:
P - proprietary module
O - out-of-tree module
F - force-loaded module
C - staging driver module
93 changes: 64 additions & 29 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,26 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
return ret;
}

static size_t module_flags_taint(struct module *mod, char *buf)
{
size_t l = 0;

if (mod->taints & (1 << TAINT_PROPRIETARY_MODULE))
buf[l++] = 'P';
if (mod->taints & (1 << TAINT_OOT_MODULE))
buf[l++] = 'O';
if (mod->taints & (1 << TAINT_FORCED_MODULE))
buf[l++] = 'F';
if (mod->taints & (1 << TAINT_CRAP))
buf[l++] = 'C';
/*
* TAINT_FORCED_RMMOD: could be added.
* TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't
* apply to modules.
*/
return l;
}

static inline void print_unload_info(struct seq_file *m, struct module *mod)
{
struct module_use *use;
Expand Down Expand Up @@ -900,10 +920,8 @@ static ssize_t show_refcnt(struct module_attribute *mattr,
return sprintf(buffer, "%lu\n", module_refcount(mk->mod));
}

static struct module_attribute refcnt = {
.attr = { .name = "refcnt", .mode = 0444 },
.show = show_refcnt,
};
static struct module_attribute modinfo_refcnt =
__ATTR(refcnt, 0444, show_refcnt, NULL);

void module_put(struct module *module)
{
Expand Down Expand Up @@ -963,10 +981,8 @@ static ssize_t show_initstate(struct module_attribute *mattr,
return sprintf(buffer, "%s\n", state);
}

static struct module_attribute initstate = {
.attr = { .name = "initstate", .mode = 0444 },
.show = show_initstate,
};
static struct module_attribute modinfo_initstate =
__ATTR(initstate, 0444, show_initstate, NULL);

static ssize_t store_uevent(struct module_attribute *mattr,
struct module_kobject *mk,
Expand All @@ -979,18 +995,50 @@ static ssize_t store_uevent(struct module_attribute *mattr,
return count;
}

struct module_attribute module_uevent = {
.attr = { .name = "uevent", .mode = 0200 },
.store = store_uevent,
};
struct module_attribute module_uevent =
__ATTR(uevent, 0200, NULL, store_uevent);

static ssize_t show_coresize(struct module_attribute *mattr,
struct module_kobject *mk, char *buffer)
{
return sprintf(buffer, "%u\n", mk->mod->core_size);
}

static struct module_attribute modinfo_coresize =
__ATTR(coresize, 0444, show_coresize, NULL);

static ssize_t show_initsize(struct module_attribute *mattr,
struct module_kobject *mk, char *buffer)
{
return sprintf(buffer, "%u\n", mk->mod->init_size);
}

static struct module_attribute modinfo_initsize =
__ATTR(initsize, 0444, show_initsize, NULL);

static ssize_t show_taint(struct module_attribute *mattr,
struct module_kobject *mk, char *buffer)
{
size_t l;

l = module_flags_taint(mk->mod, buffer);
buffer[l++] = '\n';
return l;
}

static struct module_attribute modinfo_taint =
__ATTR(taint, 0444, show_taint, NULL);

static struct module_attribute *modinfo_attrs[] = {
&module_uevent,
&modinfo_version,
&modinfo_srcversion,
&initstate,
&module_uevent,
&modinfo_initstate,
&modinfo_coresize,
&modinfo_initsize,
&modinfo_taint,
#ifdef CONFIG_MODULE_UNLOAD
&refcnt,
&modinfo_refcnt,
#endif
NULL,
};
Expand Down Expand Up @@ -3236,20 +3284,7 @@ static char *module_flags(struct module *mod, char *buf)
mod->state == MODULE_STATE_GOING ||
mod->state == MODULE_STATE_COMING) {
buf[bx++] = '(';
if (mod->taints & (1 << TAINT_PROPRIETARY_MODULE))
buf[bx++] = 'P';
else if (mod->taints & (1 << TAINT_OOT_MODULE))
buf[bx++] = 'O';
if (mod->taints & (1 << TAINT_FORCED_MODULE))
buf[bx++] = 'F';
if (mod->taints & (1 << TAINT_CRAP))
buf[bx++] = 'C';
/*
* TAINT_FORCED_RMMOD: could be added.
* TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't
* apply to modules.
*/

bx += module_flags_taint(mod, buf + bx);
/* Show a - for module-is-being-unloaded */
if (mod->state == MODULE_STATE_GOING)
buf[bx++] = '-';
Expand Down

0 comments on commit 466f302

Please sign in to comment.