summaryrefslogtreecommitdiffstats
path: root/utils/genmodinfo
blob: c4b4c3a27a9f3b8f535a67215e28049ccc735a8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python

import commands
import os
import string
import sys

uname = os.uname()[2]

if len(sys.argv) > 1:
    path = sys.argv[1]
else:
    path = '/lib/modules/%s' % (uname,)
    
mods = {}
for root, dirs, files in os.walk(path):
    for file in files:
        mods[file] = os.path.join(root,file)

modules = { 'scsi_hostadapter' : [ 'block' ], 'eth' : [ 'networking'] }
blacklist = ("ata_generic",)

list = {}

for modtype in modules.keys():
    list[modtype] = {}
    for file in modules[modtype]:
        try:
            f = open('%s/modules.%s' % (path,file),'r')
        except:
            continue
        lines = f.readlines()
        f.close()
        for line in lines:
            line = line.strip()
            if mods.has_key(line):
                desc = commands.getoutput("modinfo -F description %s" % (mods[line]))
                modname = line[:-3]
                if modname in blacklist:
                    continue
                if desc and len(desc) > 65:
                    desc = desc[:65]
                if not desc:
                    desc = "%s driver" % (modname,)
                modinfo = """
%s
        %s
        "%s"
""" % (modname, modtype, desc)
                list[modtype][modname] = modinfo

print "Version 0"
for type in list.keys():
    modlist = list[type].keys()
    modlist.sort()
    for m in modlist:
        print list[type][m]