Messages in this thread Patch in this message |  | | From | Linus Torvalds <> | | Date | Wed, 29 Jun 2011 09:22:35 -0700 | | Subject | Re: [PATCH] Add cloexec information to fdinfo |
| |
On Wed, Jun 29, 2011 at 1:15 AM, Ulrich Drepper <drepper@akkadia.org> wrote: > > In this specific case I was trying to re-implement the pfiles program. > For normal file descriptors (not sockets) this was the last piece of > information which wasn't available. This is all part of my "give > Solaris users no reason to not switch" effort. I intend to offer the > code to the util-linux-ng maintainers.
Ok.
So the part I really dislike about the patch is how it makes O_CLOEXEC so magically different from the other O_xyz flags.
Wouldn't it be much nicer to just show it in the "flags:" line?
Also, I don't think you need the rcu locking, since we hold the files->file_lock here anyway.
>> Also, it's by no means the only thing not visible in /proc. Things >> like file locking status, leases, file descriptor ownership, signal >> number associated with the setown etc. > > True, and maybe that will be useful as well. > > I might actually have some more patches to get to socket information but > I haven't fully checked out yet what is available.
So at least O_CLOEXEC seems to have a real reason, and fits the existing model. I think a patch like the attached would be ok. Does that work for you? It's entirely untested here.
Linus fs/proc/base.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c index fc5bc2767692..e2a016f24d38 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1920,6 +1920,14 @@ static int proc_fd_info(struct inode *inode, struct path *path, char *info) spin_lock(&files->file_lock); file = fcheck_files(files, fd); if (file) { + unsigned int f_flags; + struct fdtable *fdt; + + fdt = files_fdtable(files); + f_flags = file->f_flags & ~O_CLOEXEC; + if (FD_ISSET(fd, fdt->close_on_exec)) + f_flags |= O_CLOEXEC; + if (path) { *path = file->f_path; path_get(&file->f_path); @@ -1929,7 +1937,7 @@ static int proc_fd_info(struct inode *inode, struct path *path, char *info) "pos:\t%lli\n" "flags:\t0%o\n", (long long) file->f_pos, - file->f_flags); + f_flags); spin_unlock(&files->file_lock); put_files_struct(files); return 0; |  |