* [BUG] Using inotify on /proc/partitoins
@ 2013-06-14 1:26 majianpeng
2013-06-14 2:05 ` Al Viro
0 siblings, 1 reply; 2+ messages in thread
From: majianpeng @ 2013-06-14 1:26 UTC (permalink / raw)
To: john, rlove, eparis; +Cc: linux-kernel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 1190 bytes --]
Hi all,
I wanted to monitor /proc/partitions using inotify.Although now i know it can't catch the event of write.
But for read,it can't catch. The code is:
int main()
{
int fd = inotify_init();
int wd;
char buff[4096];
int ret;
if (fd < 0)
perror("inotify_init error\n");
wd = inotify_add_watch(fd, "/proc/partitions", IN_ACCESS);
if (wd < 0)
perror("inotify_add_watch error\n");
ret = read(fd, buff, 4096);
if (ret < 0)
perror("read error\n");
else
printf("buff %s\n", buff);
return 0;
}
But when i call 'cat /proc/partitions',the program can't return.
So i added some message in kernel in order to find the reason.
In procfs for some files, the inode used this method to alloc.
proc_lookup-->proc_lookup_de--->proc_get_inode-->new_inode_pseudo
In new_inode_pseudo, it will alloc new inode so every open-operation procfs will alloc new inode.
So inotify can't work.
I think it should add a flag which indicate file can't support inotify.Although there are a few files in procfs.
Thanks!
Jianpeng
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [BUG] Using inotify on /proc/partitoins
2013-06-14 1:26 [BUG] Using inotify on /proc/partitoins majianpeng
@ 2013-06-14 2:05 ` Al Viro
0 siblings, 0 replies; 2+ messages in thread
From: Al Viro @ 2013-06-14 2:05 UTC (permalink / raw)
To: majianpeng; +Cc: john, rlove, eparis, linux-kernel
On Fri, Jun 14, 2013 at 09:26:49AM +0800, majianpeng wrote:
> Hi all,
> I wanted to monitor /proc/partitions using inotify.
That, indeed, is a bug. Easily fixed - don't do that.
> But when i call 'cat /proc/partitions',the program can't return.
> So i added some message in kernel in order to find the reason.
> In procfs for some files, the inode used this method to alloc.
> proc_lookup-->proc_lookup_de--->proc_get_inode-->new_inode_pseudo
> In new_inode_pseudo, it will alloc new inode so every open-operation procfs will alloc new inode.
> So inotify can't work.
Of course, it can't work. Inotify if a kludge that kinda-sorta works
for local disk-backed filesystems, if you do not mind a pile of races.
For anything else it's completely worthless.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-14 2:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-14 1:26 [BUG] Using inotify on /proc/partitoins majianpeng
2013-06-14 2:05 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox