From ac5100f54329676469688d1b5415cd8d6428c909 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 1 Jun 2020 14:57:17 +0900 Subject: modpost: add read_text_file() and get_line() helpers modpost uses grab_file() to open a file, but it is not suitable for a text file because the mmap'ed file is not terminated by null byte. Actually, I see some issues for the use of grab_file(). The new helper, read_text_file() loads the whole file content into a malloc'ed buffer, and appends a null byte. Then, get_line() reads each line. To handle text files, I intend to replace as follows: grab_file() -> read_text_file() get_new_line() -> get_line() Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts/mod/modpost.h') diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index e5eace03a2b3..f4412febcd13 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -191,6 +191,8 @@ void add_moddevtable(struct buffer *buf, struct module *mod); void get_src_version(const char *modname, char sum[], unsigned sumlen); /* from modpost.c */ +char *read_text_file(const char *filename); +char *get_line(char **stringp); void *grab_file(const char *filename, unsigned long *size); char* get_next_line(unsigned long *pos, void *file, unsigned long size); void release_file(void *file, unsigned long size); -- cgit v1.2.3