Re: insmod: /lib/modules/2.2.17/block/xd.o: init_module: Device or resource busy
Thomas NOEL wrote:
> Maintenant, comment faire pour détecter d'où vient la demande d'accès à
> /dev/xd* ? Je pense qu'il faudrait que tu épluches les logs un peu plus,
> sans passer par logcheck... Bon courage quoi ;)
Ecrire un module pour le block-major-13 qui trace via kprintf() le petit
nom du process qui essaye de faire un open().
A compiler avec
gcc -c -DMODULE -D__KERNEL__ -I/usr/src/kernel-source-2.2.17 trace.c
Ensuite, soit tu le places dans /lib/modules/2.2.17/... soit tu le
charges directement par un `insmod trace major=13'.
J'ai fait le insmod suivi de wc /dev/xda, voici le résultat d'un dmesg:
trace: log activated for major number 13
trace: process 917 wc try open block major 13
C'est tout fait, en directe live ! Et il fonctionne avec ma 2.2.17.
--
Edouard G. Parmelan
http://egp.free.fr
/*
* Copyright (C) 2000 Edouard G. Parmelan
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/sched.h>
static int major = 13;
MODULE_AUTHOR("Edouard G. Parmelan <egp@free.fr>");
MODULE_PARM(major, "i");
MODULE_PARM_DESC(major, "major number");
static int trace_open (struct inode *inode, struct file *file)
{
struct task_struct *tsk = current;
printk (KERN_INFO "trace: process %d %s try open block major %d\n",
tsk->pid, tsk->comm, major);
return -ENODEV;
}
static struct file_operations trace_fops = {
open: trace_open
};
int init_module(void)
{
int error;
if (register_blkdev (major, "trace", &trace_fops)) {
printk (KERN_ERR "trace: Unable to get major number %d\n", major);
return -1;
}
printk (KERN_INFO "trace: log activated for major number %d\n", major);
return 0;
}
void cleanup_module (void)
{
unregister_blkdev (major, "trace");
}
Reply to: