LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-13-2005, 06:30 AM   #1
nasarlinux
LQ Newbie
 
Registered: Aug 2005
Posts: 8

Rep: Reputation: 0
linux modules


Hi,

lsmod gives me a "Used by" column which is a count. It represents the usage count of the module. Can anybody tell me how to find out which process uses this. I want unload a module like yenta_socket, but i could not do it becuase some process uses it and i could not get which process using this module.

thanks
Nasar
 
Old 09-13-2005, 11:16 PM   #2
JCipriani
Member
 
Registered: Aug 2005
Location: Pittsburgh, PA, USA
Distribution: Redhat 9, OS X 10.4.x, Win2K
Posts: 85

Rep: Reputation: 15
If it's yenta_socket, it's probably some program that's using a PCMCIA device.

If the module you are trying to unload is a device driver module, first do
Code:
cat /proc/devices
You'll see a list of module names and associated device numbers, for example:
Code:
Character devices:
  1 mem
  2 pty
  3 ttyp
  4 ttyS
  5 cua
  7 vcs
 10 misc
 13 input
 14 sound
 21 sg
 29 fb
 36 netlink
Then you can look in /dev and see which devices have that major number; in that pair of numbers just before the data, the first one is the major number. For example:
Code:
$ ls -la /dev | grep " 14,"
crw-------    1 root     root      14,   4 Aug 30  2002 audio
crw-------    1 root     root      14,  20 Aug 30  2002 audio1
crw-------    1 root     root      14,   7 Aug 30  2002 audioctl
crw-------    1 root     root      14,   3 Aug 30  2002 dsp
crw-------    1 root     root      14,  19 Aug 30  2002 dsp1
crw-------    1 root     root      14,   2 Aug 30  2002 midi00
crw-------    1 root     root      14,  18 Aug 30  2002 midi01
crw-------    1 root     root      14,  34 Aug 30  2002 midi02
crw-------    1 root     root      14,  50 Aug 30  2002 midi03
crw-------    1 root     root      14,   0 Aug 30  2002 mixer
crw-------    1 root     root      14,  16 Aug 30  2002 mixer1
crw-------    1 root     root      14,  17 Aug 30  2002 patmgr0
crw-------    1 root     root      14,  33 Aug 30  2002 patmgr1
crw-------    1 root     root      14,   1 Aug 30  2002 sequencer
crw-------    1 root     root      14,   8 Aug 30  2002 sequencer2
crw-------    1 root     root      14,   6 Aug 30  2002 sndstat
And that might give you a hint as to which program it is. I know there's a way to list all open files by all processes, and I'll be damned if I can remember what it is. You could use that to see which processes have the device in question open.

It's also possible that another module caused your module to load, indirectly. In that case, that other module will be listed in the "used by" column in lsmod, and you can look for that module instead.

There's probably a better way to do all of this, too. But I don't know it, although I'd like to. You could probably poke around in /proc/*/fd and write a script or use find or something to figure out which process has the device open. That's all assuming it's a device driver module that's actually associated with some device that a process is using, of course.

Sorry, that's the best I could come up with.

Jason

Last edited by JCipriani; 09-13-2005 at 11:19 PM.
 
Old 09-13-2005, 11:23 PM   #3
JCipriani
Member
 
Registered: Aug 2005
Location: Pittsburgh, PA, USA
Distribution: Redhat 9, OS X 10.4.x, Win2K
Posts: 85

Rep: Reputation: 15
The command to list open files is lsof, which might be in /sbin or /usr/sbin. The man page is big but it does exist.

Oh, and, it's also possible, if the module itself is buggy or if something went wrong, that a process stopped using it but it's usage count wasn't decremented. In that case there's nothing you can do about it... but that's probably not the case at all. But it can happen.

Last edited by JCipriani; 09-13-2005 at 11:26 PM.
 
Old 09-14-2005, 08:04 AM   #4
nasarlinux
LQ Newbie
 
Registered: Aug 2005
Posts: 8

Original Poster
Rep: Reputation: 0
thanks

Hi,

Thanks you very much.

I'll see the man page of lsof.

--Nasar
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Update-modules: No longer managing /lib/modules/modprobe.conf? geekzen Debian 0 04-03-2004 06:49 PM
/etc/conf.modules is more recent than /lib/module/2.2.15-4mdk/modules.dep Derek-kun Linux - Newbie 3 09-26-2003 02:56 AM
Slack9 - no PPP (can't open dependencies file /lib/modules/2.4.18/modules.dep) bluehz Slackware 1 05-04-2003 02:32 PM
Re: modprobe: Note: /etc/modules.conf is more recent than lib/modules/2.4.9/modules.d Andy.M Linux - General 1 01-24-2002 01:50 AM
Re: modprobe: Note: /etc/modules.conf is more recent than lib/modules/2.4.9/modules.d Andy.M Linux - Newbie 2 01-24-2002 01:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration