[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs opens only first 16384 bytes of file?!
From: |
Ruijie Yu |
Subject: |
Re: Emacs opens only first 16384 bytes of file?! |
Date: |
Sun, 12 Feb 2023 13:56:48 +0800 |
User-agent: |
mu4e 1.8.13; emacs 29.0.60 |
Óscar Fuentes <ofv@wanadoo.es> writes:
> [...]
> As of today (Emacs 30, current development branch) the same is true.
>
> /proc/cpuinfo is not a regular file, in the sense that its content is
> not stored in a device. AFAIK it is generated on-the-fly when it is
> read.
>
> You can do some simple observations:
>
> $ ls -l /proc/cpuinfo
> -r--r--r-- 1 root root 0 feb 7 03:34 /proc/cpuinfo
> $ du /proc/cpuinfo
> 0 /proc/cpuinfo
>
> Here those tools are saying that the file's size is 0.
Thanks for elaborating on the part that I missed. So, to reproduce the
issue, we need to find a file which does not show size, and whose
contents are generated on-the-fly when read -- in the original report,
it is /proc/cpuinfo, and I have also found /proc/kallsyms which contains
around 12M of data. In this case, I have reproduced the issue on my
Emacs 29 build.
> I guess that Emacs detects that the file is special and reads its
> contents following some heuristics. What surprises me is that M-x
> revert-file actually reads all the content.
>
> Of course, looking at the sources would be enlightening, but why do the
> effort of actually clearing the matter when it is so cheap to throw
> speculation? ;-)
I think the limit of 16384 is probably caused by fileio.c:3919
(907fd1f7ff4 somewhere on master, inside DEFUN "insert-file-contents")
which declares a read buffer. The constant READ_BUF_SIZE is indirectly
set as 16 * 1024 = 16384. Didn't read further there, nor inside
`revert-buffer'.
> (I looked at insert-file-contents, but bailed out after the fifth
> screenful of code. A 1000+ lines function, no kidding.)
Yeah, that's exactly why I didn't read further there.
--
Best,
RY