GNU bug report logs - #36291
od --skip-bytes reads everything from the very beginning

Previous Next

Package: coreutils;

Reported by: Szőts Ákos <szotsaki <at> gmail.com>

Date: Wed, 19 Jun 2019 13:27:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#36291: closed (od --skip-bytes reads everything from the very
 beginning)
Date: Thu, 20 Jun 2019 01:53:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Wed, 19 Jun 2019 18:52:01 -0700
with message-id <bdae18fe-4f51-8dae-deac-1c857dfd86ab <at> cs.ucla.edu>
and subject line Re: bug#36291: od --skip-bytes reads everything from the very beginning
has caused the debbugs.gnu.org bug report #36291,
regarding od --skip-bytes reads everything from the very beginning
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
36291: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=36291
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Szőts Ákos <szotsaki <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: od --skip-bytes reads everything from the very beginning
Date: Wed, 19 Jun 2019 10:20:10 +0200
Dear List members,

I've recently discovered that od "--skip-bytes" feature doesn't
actually seek into the file but rather it reads everything from the
very beginning until the given offset is reached.

This can be problematic in two cases:
 - when speed matters, and
 - when parts of the file is read-protected (like in the case of
/dev/mem when CONFIG_STRICT_DEVMEM=y, which is usually the case). In
this example od will reach an area in /dev/mem which is read-protected
(even for root) and will report back EPERM before it could reach the
requested, and allowed, memory area. The error report will be
misleading since the resulting EPERM is not because the requested area
is protected (as suggested by the error message) but because of the
inner mechanics of the program.

In contrary, hexdump jumps to the address directly.

You can test it by running the following two commands:
- strace hexdump --skip 0xFE000124 --length 1 /dev/sda
- strace od --skip-bytes 0xFE000124 --read-bytes 1 /dev/sda

I don't know whether this behaviour is intended but if so, could you
please expand the documentation a little bit with this additional
information?

od version: od (GNU coreutils) 8.30, openSUSE Tumbleweed, x64

Thank you and all the best,

Ákos


[Message part 3 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 36291-done <at> debbugs.gnu.org,
 Szőts Ákos <szotsaki <at> gmail.com>
Subject: Re: bug#36291: od --skip-bytes reads everything from the very
 beginning
Date: Wed, 19 Jun 2019 18:52:01 -0700
[Message part 4 (text/plain, inline)]
On 6/19/19 12:42 PM, Pádraig Brady wrote:
> Maybe we should relax the cases we do read() for,
> and try to seek in block/character special files,
> falling back to read() where that fails?

Sure, that's easy enough. I installed the attached patch and am marking 
this bug report as done.

[0001-od-use-fseek-on-non-regular-files.txt (text/plain, attachment)]

This bug report was last modified 5 years and 337 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.