From: majianpeng <majianpeng@gmail.com>
To: john <john@johnmccutchan.com>, rlove <rlove@rlove.org>,
eparis <eparis@parisplace.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [BUG] Using inotify on /proc/partitoins
Date: Fri, 14 Jun 2013 09:26:49 +0800 [thread overview]
Message-ID: <201306140926455537935@gmail.com> (raw)
[-- 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¥
next reply other threads:[~2013-06-14 1:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-14 1:26 majianpeng [this message]
2013-06-14 2:05 ` [BUG] Using inotify on /proc/partitoins Al Viro
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=201306140926455537935@gmail.com \
--to=majianpeng@gmail.com \
--cc=eparis@parisplace.org \
--cc=john@johnmccutchan.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rlove@rlove.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.