mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
To: Hank Leininger <hlein@korelogic.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: Accessing file-offset info for fds in /proc?
Date: Tue, 20 Feb 2007 07:43:33 -0600	[thread overview]
Message-ID: <1171979013.28491.16.camel@kleikamp.austin.ibm.com> (raw)
In-Reply-To: <20070220073130.GV5752@timmy.spinoli.org>

On Tue, 2007-02-20 at 02:31 -0500, Hank Leininger wrote:
> Is there anything provided by the kernel that would let you see the
> current offset of an existing filehandle?
> 
> Sometimes when processing a very large file (grepping a log, bzip2'ing
> or gpg'ing a file, or whatever), I'd really like to know how far along
> it is, because I'm impatient.  lsof has an -o flag to show offsets for
> file descriptors it lists, but it appears that's not supported under
> Linux.  It looks like all of the information lsof and fuser print about 
> files in use, etc can be gotten from /proc/*/fd/* (and /proc/*/maps, but
> I'm not really concerned with mmap'ed files, just positions on fds).
> Sometimes I'll resort to strace -s4096'ing the process to see what chunk
> of text it's currently reading, and try to guess from that.  Silly.
> 
> Has anybody ever developed a patch to implement this?  I realize this
> could create a variety of information-leakage problems; the information
> probably would need to be restricted, such as by the same rules as
> dumpable.  Are there any horribly painful reasons why this couldn't be
> done?

It shouldn't be too painful.  The code to populate /proc/*/fd/ has the
file struct.  It just doesn't have a place pass the offset to user-space
since it's basically creating a symlink.  In proc_fd_link(), it has the
file struct.  The offset is file->f_pos.

One could create something like /proc/*/fd_offsets, whose read method
could list the file descriptor, path, and offset for each open file.

Shaggy
-- 
David Kleikamp
IBM Linux Technology Center


  reply	other threads:[~2007-02-20 13:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-20  7:31 Hank Leininger
2007-02-20 13:43 ` Dave Kleikamp [this message]
2007-02-20 14:51   ` Miklos Szeredi

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=1171979013.28491.16.camel@kleikamp.austin.ibm.com \
    --to=shaggy@linux.vnet.ibm.com \
    --cc=hlein@korelogic.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@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®