From: matthieu castet <castet.matthieu@free.fr>
To: Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: device_remove_file and disconnect
Date: Wed, 29 Jun 2005 18:59:00 +0200 [thread overview]
Message-ID: <42C2D354.6060607@free.fr> (raw)
[-- Attachment #1: Type: text/plain, Size: 609 bytes --]
Hi,
I have a question about sysfs interface.
If you open a sysfs file created by a module, then remove it (rmmoding
the module that create this sysfs file), then try to read the opened
file, you often get strange result (segdefault or oppps).
I attach a small program to test it : open your sysfs file with it
`wait_read /sysfs/file', rmmod the module, and press enter.
I was wondering if it is to user of sysfs to prevent that (with mutex,
...) or it is a sysfs bug ?
If it is the first case, I fear that lot's of modules are broken.
Regards,
Matthieu
PS : CC me as I am not subscribed to lkml.
[-- Attachment #2: wait_read.c --]
[-- Type: text/x-csrc, Size: 624 bytes --]
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char *argv[])
{
char c;
char buf[1024];
int fd, i, n;
if (argc != 2)
return -1;
fd = open(argv[1], O_RDONLY);
if (fd < 0) {
perror("wait_read - open fail");
return -1;
}
c = getc(stdin);
n = read(fd, buf, 1024);
for (i = 0; i < n; i++)
putc(buf[i], stdout);
if (n < 0)
perror("wait_read - read fail");
else
putc('\n', stdout);
close(fd);
}
next reply other threads:[~2005-06-29 17:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-29 16:59 matthieu castet [this message]
2005-06-29 18:46 ` device_remove_file and disconnect Greg KH
2005-06-29 20:17 ` matthieu castet
2005-06-29 22:42 ` Greg KH
2005-06-30 7:26 ` mat
2005-06-30 17:04 ` Greg KH
2005-06-30 20:31 ` matthieu castet
2005-07-02 23:27 ` matthieu castet
2005-07-03 4:54 ` Dmitry Torokhov
2005-07-25 1:54 ` Greg KH
2005-06-30 20:36 ` Dmitry Torokhov
2005-07-03 4:38 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42C2D354.6060607@free.fr \
--to=castet.matthieu@free.fr \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox