3 dd-alike which supports SEEK_SET seeking
4 Copyright (C) 2011 Kirill Smelkov <kirr@navytux.spb.ru>
6 This program is free software: you can Use, Study, Modify and Redistribute it
7 under the terms of the GNU General Public License version 2. This program is
8 distributed WITHOUT ANY WARRANTY. See COPYING file for full License terms.
11 dd's skip uses SEEK_CUR, and also it checks whether current position is >
12 st_size after, and errors if it is, which is not good for us - in our case all
13 files have st_size=0, like in /proc.
15 So here goes small utility
16 $ xdd off1,size1 off2,size2 ... <in >out
19 from os
import read
, write
, lseek
, SEEK_SET
27 chunk
= read(fd
, size
)
53 for arg
in sys
.argv
[1:]:
54 offset
, size
= arg
.split(',')
57 work
.append( (offset
, size
) )
59 for offset
, size
in work
:
60 lseek(0, offset
, SEEK_SET
)
66 if __name__
== '__main__':