root/floppyfw/scripts/modhash.pl

Revision 1, 2.5 KB (checked in by root, 6 years ago)

First post

Line 
1#!/usr/bin/perl -T
2#
3# $Id: modhash.pl,v 1.1.1.1 2004/08/31 13:33:28 thomasez Exp $
4
5
6use strict;
7
8use vars qw($moduleroot $kernelversion);
9
10require ("./modpick.conf");
11
12my ($m, $p) = &readModulesDep();
13
14print "PATHS:\n\n";
15&printPaths($m, $p);
16
17
18sub readModulesDep {
19
20        my ($modules, $paths);
21        my ($depfile) = $moduleroot . "/" . $kernelversion . "/modules.dep";
22        open (DEP, "$depfile" )
23                 or die "No modules.dep.\n";
24
25        my ($last_module);
26        while (<DEP>) {
27
28                chomp;
29                next unless (/kernel/);
30
31                my ($line) = /\w+\/kernel\/(.*)/;
32
33                if ($line =~ /\:/) {
34                        $last_module = undef;
35
36                        my ($modline, $dep) = split (/\:/, $line);
37                        my (@path) = split (/\//, $modline);
38
39                        my ($module, $lastp, $lastp1, $lastp2, $lastp3);
40
41                        foreach my $p (@path) {
42                                #
43                                # We have a module;
44                                #
45                                ($module) = $1 if ( $p =~ /(.*\.o)/ );
46
47                                if ($module) {
48                                        # Gawd this is ugly.
49                                        push @{$paths->{$lastp}->{'modules'}}, $module
50                                                unless ($lastp1);
51
52                                        push @{$paths->{$lastp}->{$lastp1}->{'modules'}}, $module
53                                                unless ($lastp2);
54                                        push @{$paths->{$lastp}->{$lastp1}->{$lastp2}->{'modules'}}, $module
55                                                unless ($lastp3);
56                                        push @{$paths->{$lastp}->{$lastp1}->{$lastp2}->{$lastp3}->{'modules'}}, $module
57                                                if ($lastp3);
58
59                                        $modules->{$module}->{'file'} = $modline;
60
61                                        next;
62                                }
63
64
65                                # Gawd this is ugly. Part II.
66                                $lastp3 = $p if ($lastp && $lastp1 && $lastp2 && !$lastp3);
67                                $lastp2 = $p if ($lastp && $lastp1 && !$lastp2);
68                                $lastp1 = $p if ($lastp && !$lastp1);
69                                $lastp = $p if (!$lastp);
70
71
72                        }
73#                       print $module . ";" . $lastp . ";" . $lastp1 . ";" . $lastp2 . ";" . "$lastp3;\n";
74
75                        if ($dep) {
76                                my ($dmodule) = $1 if ($dep =~ /\/(\w+-?\w+\.o)/);
77        print "DEPM: $module-$dmodule\n";
78                                push @{$modules->{$module}->{'depends'}}, $dmodule;
79                                $last_module = $module;
80
81                        }
82
83
84
85                }
86
87                if ($last_module && $line =~ /^\t/) {
88                        my ($dmodule) = $1 if ( $_ =~ /(.*\.o)/ );
89#                       print "DEPM2: $dmodule\n";
90
91                        push @{$modules->{$last_module}->{'depends'}}, $dmodule;
92                }
93               
94
95        }
96
97       
98       
99        close (DEP);
100        return ($modules, $paths);
101
102
103}
104
105sub printPaths {
106        my ($modules, $path, $level) = @_;
107
108        $level++;
109
110
111        foreach my $pat (sort(keys (%$path))) {
112                print "Path:$pat\n" if ($pat && $pat ne "modules");
113                if ($pat eq "modules") {
114                        foreach my $mod (@{$path->{'modules'}}) {
115                                print "\t$mod - ";
116                                print join (";", @{$modules->{$mod}->{'depends'}}) if (exists($modules->{$mod}->{'depends'}));
117                                print "\n";
118
119
120                        }
121                        next;
122                }
123                &printPaths($modules, $path->{$pat}, $level) if (ref($path->{$pat}) eq "HASH");
124        }
125
126}
Note: See TracBrowser for help on using the browser.