[Gllug] file offset in running process

Daniel P. Berrange dan at berrange.com
Fri Aug 14 14:58:45 UTC 2009


On Fri, Aug 14, 2009 at 03:50:26PM +0100, Alain Williams wrote:
> I am doing a large 'dd'. I want to know how far it has got. How do I do it ?
> 
> lsof does not support -o (offset) under Linux.
> Strace reports nothing useful.

As others have said,  kill -USR1 is easiest for 'dd'.

For the more general case though, recent kernels have started exposing
this info in /proc/$PID/fdinfo

eg

# dd if=/dev/zero of=demo.img bs=1 count=10000000

# pgrep dd
10729

# lsof -p 10729
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
[snip]
dd      10729 berrange    0r   CHR    1,5      0t0     482 /dev/zero
dd      10729 berrange    1w   REG  253,1  2934408 2126103 /home/berrange/demo.img
dd      10729 berrange    2u   CHR 136,10      0t0      13 /dev/pts/10


# cat /proc/10729/1
pos:	9592469
flags:	0100001


The 'pos' field is the offset,  'flags' is the flags passed to open()
so you can see whether its a read/write/etc 

Regards,
Daniel
-- 
|: http://berrange.com/     -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://freshmeat.net/~danielpb/    -o-   http://gtk-vnc.sourceforge.net :|
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20090814/03b57fa0/attachment.pgp>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list