From: "\"FJCL) 荻野 大輔\"" <ogino.daisuke@jp.fujitsu.com>
To: linux-kernel@vger.kernel.org
Cc: linux-pci@vger.kernel.org, adobriyan@gmail.com
Subject: [patch] procfs: returns ENOENT on opening the being-removed proc entry
Date: Fri, 24 Jun 2011 10:48:08 +0900 [thread overview]
Message-ID: <20110624104509.6195.371AB99A@jp.fujitsu.com> (raw)
From: Daisuke Ohino <ogino.daisuke@jp.fujitsu.com>
opening the proc entry may return EINVAL if the entry is being removed, for
example open("/proc/bus/pci/XX/YY") during the corresponding device is being
hot-removed. The return value is inappropriate and should return ENOENT.
This return value comes from proc_reg_open().
fs/proc/inode.c:
-----------------------------------------------------------
static int proc_reg_open(struct inode *inode, struct file *file)
{
(snip)
if (!pde->proc_fops) {
spin_unlock(&pde->pde_unload_lock);
kfree(pdeo);
return -EINVAL;
}
(snip)
-----------------------------------------------------------
pde->proc_fops is NULL iff the proc entry is being removed. It
is set by remove_proc_entry().
-----------------------------------------------------------
void remove_proc_entry(const char *name, struct proc_dir_entry*parent)
{
(snip)
/*
* Stop accepting new callers into module. If you're
* dynamically allocating ->proc_fops, save a pointer somewhere.
*/
de->proc_fops = NULL;
(snip)
-----------------------------------------------------------
But POSIX says:
-----------------------------------------------------------
[EINVAL]
The implementation does not support synchronized I/O for this file.
-----------------------------------------------------------
Since removing proc entry is apparently not related to synchronized I/O,
this function should return ENOENT in this case.
Signed-off-by: Daisuke Ogino <ogino.daisuke@jp.fujitsu.com>
---
fs/proc/inode.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 74b48cf..7ed72d6 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -319,7 +319,7 @@ static int proc_reg_open(struct inode *inode, struct file *file)
if (!pde->proc_fops) {
spin_unlock(&pde->pde_unload_lock);
kfree(pdeo);
- return -EINVAL;
+ return -ENOENT;
}
pde->pde_users++;
open = pde->proc_fops->open;
--
Since I don't subscribe LKML, please Cc me if you have any comment.
Thanks,
Daisuke
next reply other threads:[~2011-06-24 1:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-24 1:48 "FJCL) 荻野 大輔" [this message]
2011-06-27 1:19 ` KAMEZAWA Hiroyuki
2011-06-30 10:44 ` Daisuke Ogino
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=20110624104509.6195.371AB99A@jp.fujitsu.com \
--to=ogino.daisuke@jp.fujitsu.com \
--cc=adobriyan@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@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
all inboxes | Powered by JetHome®