[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#67490: [PATCH v2] tail: fix tailing sysfs files on large page kernel
From: |
Pádraig Brady |
Subject: |
bug#67490: [PATCH v2] tail: fix tailing sysfs files on large page kernels |
Date: |
Thu, 30 Nov 2023 20:11:52 +0000 |
User-agent: |
Mozilla Thunderbird |
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.