coredump,analyze: use read_full_file() for reading various top-level /proc/ files
Kernel API file systems typically use either "raw" or "seq_file" to implement their various interface files. The former are really simple (to point I'd call them broken), in that they have no understanding of file offsets, and return their contents again and again on every read(), and thus EOF is indicated by a short read, not by a zero read. The latter otoh works like a typical file: you read until you get a zero-sized read back. We have read_virtual_file() to read the "raw" files, and can use regular read_full_file() to read the "seq_file" ones. Apparently all files in the top-level /proc/ directory use 'seq_file'. but we accidentally used read_virtual_file() for them. Fix that. Also clarify in a comment what the rules are. Fixes: #36131
This commit is contained in:
@@ -122,7 +122,7 @@ int proc_cmdline(char **ret) {
|
||||
if (detect_container() > 0)
|
||||
return pid_get_cmdline(1, SIZE_MAX, 0, ret);
|
||||
|
||||
return read_virtual_file("/proc/cmdline", SIZE_MAX, ret, NULL);
|
||||
return read_full_file("/proc/cmdline", ret, /* ret_size= */ NULL);
|
||||
}
|
||||
|
||||
static int proc_cmdline_strv_internal(char ***ret, bool filter_pid1_args) {
|
||||
|
||||
Reference in New Issue
Block a user