Skip to content

Commit

Permalink
dd: support skip and seek values greater than 2G on android
Browse files Browse the repository at this point in the history
it could be useful to keep a bs=1 to get exact positions.
bionic fail to use the CONFIG_LFS flag to support large offsets,
this workaround fix the function on /dev/mem or /dev/kmem inputs

Change-Id: I7fc951b001f065e02254037da2a1e61520e20282
  • Loading branch information
tpruvot committed Jul 27, 2012
1 parent 31a2146 commit 6a025ba
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion coreutils/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
int flags;
size_t oc;
off_t count;
off_t seek, skip;
uoff_t seek, skip;
const char *infile, *outfile;
} Z;
#define flags (Z.flags )
Expand Down Expand Up @@ -344,6 +344,20 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
} else {
outfile = bb_msg_standard_output;
}
#if (!ENABLE_LFS) && defined(ANDROID)
if (skip) {
if (lseek64(ifd, skip * ibs, SEEK_SET) == (off64_t) -1)
fprintf(stderr, "warning: skip lseek64 failed\n");
else
skip = 0;
}
if (seek) {
if (lseek64(ifd, seek * obs, SEEK_SET) == (off64_t) -1)
fprintf(stderr, "warning: seek lseek64 failed\n");
else
seek = 0;
}
#endif
if (skip) {
if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) {
while (skip-- > 0) {
Expand Down

0 comments on commit 6a025ba

Please sign in to comment.