Re: [PATCH 03/29] modpost: add read_text_file() and get_line() helpers

2020-05-22 Thread Masahiro Yamada
On Wed, May 20, 2020 at 9:29 PM Peter Zijlstra wrote: > > On Wed, May 20, 2020 at 09:17:45PM +0900, Masahiro Yamada wrote: > > > The specification [1] says this: > > > > "The value returned may be less than nbyte if the number of bytes > > left in the file is less than nbyte, if the read()

Re: [PATCH 03/29] modpost: add read_text_file() and get_line() helpers

2020-05-20 Thread Peter Zijlstra
On Wed, May 20, 2020 at 09:17:45PM +0900, Masahiro Yamada wrote: > The specification [1] says this: > > "The value returned may be less than nbyte if the number of bytes > left in the file is less than nbyte, if the read() request was > interrupted by a signal, or if the file is a pipe or FIFO

Re: [PATCH 03/29] modpost: add read_text_file() and get_line() helpers

2020-05-20 Thread Masahiro Yamada
On Tue, May 19, 2020 at 7:21 PM Peter Zijlstra wrote: > > On Sun, May 17, 2020 at 06:48:33PM +0900, Masahiro Yamada wrote: > > > +char *read_text_file(const char *filename) > > +{ > > + struct stat st; > > + int fd; > > + char *buf; > > + > > + fd = open(filename, O_RDONLY); > > +

Re: [PATCH 03/29] modpost: add read_text_file() and get_line() helpers

2020-05-19 Thread Peter Zijlstra
On Sun, May 17, 2020 at 06:48:33PM +0900, Masahiro Yamada wrote: > +char *read_text_file(const char *filename) > +{ > + struct stat st; > + int fd; > + char *buf; > + > + fd = open(filename, O_RDONLY); > + if (fd < 0) > + return NULL; > + > + if (fstat(fd, ) <

[PATCH 03/29] modpost: add read_text_file() and get_line() helpers

2020-05-17 Thread Masahiro Yamada
modpost uses grab_file() to open a file, but it is not suitable for a text file because the mmaped 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