Increase standard I/O buffer a lot to be able to

read huge informations at once as otherwise all files below
/proc/sys, not using the seq_file API at the kernel side,
will return EOF on a second read.

Signed-off-by: Werner Fink <werner@suse.de>
This commit is contained in:
Werner Fink 2017-07-07 14:09:11 +02:00 committed by Craig Small
parent e6e228e7f4
commit 8af3db9274

View File

@ -156,6 +156,8 @@ static char *StripLeadingAndTrailingSpaces(char *oneline)
/*
* Read a sysctl setting
*/
#define IOBUFSIZ (128<<10)
static char *iobuf;
static int ReadSetting(const char *restrict const name)
{
int rc = 0;
@ -218,6 +220,9 @@ static int ReadSetting(const char *restrict const name)
fp = fopen(tmpname, "r");
if (iobuf)
setvbuf(fp, iobuf, _IOFBF, IOBUFSIZ);
if (!fp) {
switch (errno) {
case ENOENT:
@ -428,6 +433,9 @@ static int WriteSetting(const char *setting)
fp = fopen(tmpname, "w");
if (iobuf)
setvbuf(fp, iobuf, _IOFBF, IOBUFSIZ);
if (!fp) {
switch (errno) {
case ENOENT:
@ -791,6 +799,8 @@ int main(int argc, char *argv[])
argc -= optind;
argv += optind;
iobuf = (char*)malloc(IOBUFSIZ); /* Allow to fail */
if (DisplayAllOpt)
return DisplayAll(PROC_PATH);