From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: drepper@akkadia.org
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
rientjes@google.com, torvalds@linux-foundation.org,
viro@zeniv.linux.org.uk, wilsons@start.ca,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] Add cloexec information to fdinfo
Date: Mon, 13 Jun 2011 11:54:41 +0900 [thread overview]
Message-ID: <4DF57BF1.90509@jp.fujitsu.com> (raw)
In-Reply-To: <201106100355.p5A3t8Aa024924@drepperk.user.openhosting.com>
(2011/06/10 12:55), drepper@akkadia.org wrote:
> There is one piece of information about a file descriptor which is
> currently not visible from the outside: the close-on-exec flag. The
> /proc/PID/fdinfo/* files have the mode information but this is
> missing. Is the following patch acceptable?
>
> What I don't know is whether the RCU locking is needed given that
> real locks are taken. Someone with more knowledge could just
> remove those two lines.
>
>
> Signed-off-by: Ulrich Drepper <drepper@gmail.com>
>
> base.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 14def99..bda3651 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1924,12 +1924,23 @@ static int proc_fd_info(struct inode *inode, struct path *path, char *info)
> *path = file->f_path;
> path_get(&file->f_path);
> }
> - if (info)
> + if (info) {
> + int cloexec;
> + struct fdtable *fdt;
> +
> + rcu_read_lock();
> + fdt = files_fdtable(files);
> + cloexec = FD_ISSET(fd, fdt->close_on_exec);
> + rcu_read_unlock();
> +
> snprintf(info, PROC_FDINFO_MAX,
> "pos:\t%lli\n"
> - "flags:\t0%o\n",
> + "flags:\t0%o\n"
> + "cloexec: %d\n",
> (long long) file->f_pos,
> - file->f_flags);
> + file->f_flags,
> + cloexec);
> + }
> spin_unlock(&files->file_lock);
> put_files_struct(files);
> return 0;
I think this is correct and useful. However I don't know fdtable life cycle detail.
cc to linux-fsdevel.
next prev parent reply other threads:[~2011-06-13 2:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-10 3:55 [PATCH] Add cloexec information to fdinfo drepper
2011-06-13 2:54 ` KOSAKI Motohiro [this message]
[not found] ` <201106100355.p5A3t8Aa024924-/1RLGD9tqMZ22nUyOigohnmVWlWGoA+o+lehtg8QC5Y@public.gmane.org>
2011-06-20 21:31 ` Andrew Morton
2011-06-20 21:31 ` Andrew Morton
2011-06-28 7:07 ` Ulrich Drepper
2011-06-28 17:23 ` Linus Torvalds
2011-06-29 8:15 ` Ulrich Drepper
2011-06-29 10:51 ` Pádraig Brady
2011-06-29 16:22 ` Linus Torvalds
2011-06-29 18:05 ` Linus Torvalds
2011-06-30 2:59 ` Ulrich Drepper
2011-06-30 13:39 ` Ulrich Drepper
2011-06-30 16:07 ` Linus Torvalds
2011-08-05 11:49 ` Ulrich Drepper
2011-08-06 18:58 ` Linus Torvalds
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=4DF57BF1.90509@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=drepper@akkadia.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rientjes@google.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
--cc=wilsons@start.ca \
/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.