Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
net-tools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
net-tools
Commits
20f0f8e1
Commit
20f0f8e1
authored
Dec 01, 2007
by
Bernd Eckenfels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Faster pagesize aligned fopen for netstat -s (Eric Dumazet)
parent
41cae5eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
7 deletions
+30
-7
lib/proc.c
lib/proc.c
+21
-1
lib/proc.h
lib/proc.h
+5
-3
statistics.c
statistics.c
+4
-3
No files found.
lib/proc.c
View file @
20f0f8e1
/* Tolerant /proc file parser. Copyright 1998 Andi Kleen */
/* $Id: proc.c,v 1.
4 1999/01/05 20:54:00 philip
Exp $ */
/* $Id: proc.c,v 1.
5 2007/12/01 18:44:57 ecki
Exp $ */
/* Fixme: cannot currently cope with removed fields */
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
/* Caller must free return string. */
...
...
@@ -72,3 +73,22 @@ int proc_guess_fmt(char *name, FILE *fh, ...)
va_end
(
ap
);
return
flag
;
}
FILE
*
proc_fopen
(
const
char
*
name
)
{
static
char
*
buffer
;
static
size_t
pagesz
;
FILE
*
fd
=
fopen
(
name
,
"r"
);
if
(
fd
==
NULL
)
return
NULL
;
if
(
!
buffer
)
{
pagesz
=
getpagesize
();
buffer
=
malloc
(
pagesz
);
}
setvbuf
(
fd
,
buffer
,
_IOFBF
,
pagesz
);
return
fd
;
}
lib/proc.h
View file @
20f0f8e1
/* Generate a suitable scanf format for a column title line
*/
/*
* prototypes for proc.c
*/
char
*
proc_gen_fmt
(
char
*
name
,
int
more
,
FILE
*
fh
,...);
int
proc_guess_fmt
(
char
*
name
,
FILE
*
fh
,...);
FILE
*
proc_fopen
(
const
char
*
name
);
statistics.c
View file @
20f0f8e1
/*
* Copyright 1997,1999,2000 Andi Kleen. Subject to the GPL.
* $Id: statistics.c,v 1.
19 2007/12/01 18:29:05
ecki Exp $
* $Id: statistics.c,v 1.
20 2007/12/01 18:44:56
ecki Exp $
* 19980630 - i18n - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* 19981113 - i18n fixes - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* 19990101 - added net/netstat, -t, -u, -w supprt - Bernd Eckenfels
...
...
@@ -11,6 +11,7 @@
#include <string.h>
#include "config.h"
#include "intl.h"
#include "proc.h"
/* #define WARN 1 */
...
...
@@ -387,7 +388,7 @@ void parsesnmp(int flag_raw, int flag_tcp, int flag_udp)
f_raw
=
flag_raw
;
f_tcp
=
flag_tcp
;
f_udp
=
flag_udp
;
f
=
fopen
(
"/proc/net/snmp"
,
"r
"
);
f
=
proc_fopen
(
"/proc/net/snmp
"
);
if
(
!
f
)
{
perror
(
_
(
"cannot open /proc/net/snmp"
));
return
;
...
...
@@ -401,7 +402,7 @@ void parsesnmp(int flag_raw, int flag_tcp, int flag_udp)
fclose
(
f
);
f
=
fopen
(
"/proc/net/netstat"
,
"r
"
);
f
=
proc_fopen
(
"/proc/net/netstat
"
);
if
(
f
)
{
if
(
process_fd
(
f
)
<
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment