GNU bug report logs - #67490
[PATCH v2] tail: fix tailing sysfs files on large page kernels

Previous Next

Package: coreutils;

Reported by: dann frazier <dann.frazier <at> canonical.com>

Date: Mon, 27 Nov 2023 17:31:02 UTC

Severity: normal

Tags: patch

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #25 received at 67490 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: dann frazier <dann.frazier <at> canonical.com>, 67490 <at> debbugs.gnu.org
Subject: Re: bug#67490: [PATCH v2] tail: fix tailing sysfs files on large page
 kernels
Date: Thu, 30 Nov 2023 20:11:52 +0000
Much clearer thanks.

On my system:

  $ stat /sys/kernel/profiling
    File: /sys/kernel/profiling
    Size: 4096      	Blocks: 0          IO Block: 4096   regular file

I can easily repro by setting the buffer size < PAGE_SIZE.

So this patch handles the case where sysfs reports a file is a certain size,
but it isn't really. In that case seeking to anywhere other than the start
doesn't give an error, but reading returns nothing. So we use a buffer size
large enough (>= PAGE_SIZE as inferred from st_blksize) so that we'll be
reading from the start of the file in this case.

Note st_blksize can have unusual values, so it might be better
to use the io_blksize() wrapper to sanitize the values.
Though that will generally give 128K, which is good when processing all of a file,
but perhaps overkill when processing just the last part of a file.

So perhaps it's better to use buffer_size = MAX (BUFSIZ, getpagesize ())
and avoid all the st_blksize edge cases.

I'll think about it a little, and make the adjustments.

thanks!
Pádraig.




This bug report was last modified 1 year and 175 days ago.

Previous Next


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