lkml.org 
[lkml]   [2004]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 2.6.2: "-" or "_", thats the question
On Mon, 16 Feb 2004, Ryan Reich wrote:

> On Mon, 16 Feb 2004, Harald Dunkel wrote:
>
> > Ryan Reich wrote:
> > > Harald Dunkel wrote:
> > >
> > >>
> > >> I am interested in the module file names. 'cat /proc/modules'
> > >> should return the correct module names, but for some modules
> > >> (like uhci_hcd vs uhci-hcd.ko) '_' and '-' are messed up.
> > >
> > >
> > > According to the modprobe man page, the two symbols are interchangeable.
> > >
> > I know. But this requires some very ugly workarounds outside
> > of module-init-tools. For example, if you want to check
> > whether a module $module_name has already been loaded, you
> > cannot use
> >
> > grep -q "^${module_name} " /proc/modules
> >
> > Instead you have to use a workaround like
> >
> > x="`echo $module_name | sed -e 's/-/_/g'`"
> > cat /proc/modules | sed -e 's/-/_/g' | grep -q "^${x} "
> >
> > This is inefficient and error-prone.
> >
> > Maybe somebody has another idea for the workaround,
> > but I like the first version.
>
> Well, you can shorten it by using 'tr':
>
> cat /proc/modules | tr _ - | grep -q "^${module_name} "
>
> /proc/modules uses the '_' and I suppose your problem is that your module name
> list uses the '-', so this solves both at once.

Sorry, I didn't realize that your problem was also the inconsistency in module
names. Someone else suggested using a shell expansion; you could try

cat /proc/modules | tr _ - | grep -q "^${module_name/_/-}"

which is both short and works.

--
Ryan Reich
ryanr@uchicago.edu
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:00    [W:0.087 / U:1.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site