]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - net-tools/patches/net-tools-1.60-netstat_inode.patch
Change file layout of the makefiles.
[people/ms/ipfire-3.x.git] / net-tools / patches / net-tools-1.60-netstat_inode.patch
1 --- net-tools-1.60/netstat.c.inode 2006-02-23 09:28:23.000000000 +0100
2 +++ net-tools-1.60/netstat.c 2006-02-23 09:33:57.000000000 +0100
3 @@ -231,7 +231,7 @@
4
5 static struct prg_node {
6 struct prg_node *next;
7 - int inode;
8 + unsigned long inode;
9 char name[PROGNAME_WIDTH];
10 char scon[SELINUX_WIDTH];
11 } *prg_hash[PRG_HASH_SIZE];
12 @@ -268,7 +268,7 @@
13 /* NOT working as of glibc-2.0.7: */
14 #undef DIRENT_HAVE_D_TYPE_WORKS
15
16 -static void prg_cache_add(int inode, char *name, char *scon)
17 +static void prg_cache_add(unsigned long inode, char *name, char *scon)
18 {
19 unsigned hi = PRG_HASHIT(inode);
20 struct prg_node **pnp,*pn;
21 @@ -332,15 +332,16 @@
22 prg_cache_loaded=0;
23 }
24
25 -static void extract_type_1_socket_inode(const char lname[], long * inode_p) {
26 +static void extract_type_1_socket_inode(const char lname[], unsigned long * inode_p, int * status) {
27
28 /* If lname is of the form "socket:[12345]", extract the "12345"
29 - as *inode_p. Otherwise, return -1 as *inode_p.
30 + as *inode_p. Otherwise, return -1 as *status.
31 */
32
33 - if (strlen(lname) < PRG_SOCKET_PFXl+3) *inode_p = -1;
34 - else if (memcmp(lname, PRG_SOCKET_PFX, PRG_SOCKET_PFXl)) *inode_p = -1;
35 - else if (lname[strlen(lname)-1] != ']') *inode_p = -1;
36 + *status = 0;
37 + if (strlen(lname) < PRG_SOCKET_PFXl+3) *status = -1;
38 + else if (memcmp(lname, PRG_SOCKET_PFX, PRG_SOCKET_PFXl)) *status = -1;
39 + else if (lname[strlen(lname)-1] != ']') *status = -1;
40 else {
41 char inode_str[strlen(lname + 1)]; /* e.g. "12345" */
42 const int inode_str_len = strlen(lname) - PRG_SOCKET_PFXl - 1;
43 @@ -348,28 +349,30 @@
44
45 strncpy(inode_str, lname+PRG_SOCKET_PFXl, inode_str_len);
46 inode_str[inode_str_len] = '\0';
47 - *inode_p = strtol(inode_str,&serr,0);
48 - if (!serr || *serr || *inode_p < 0 || *inode_p >= INT_MAX)
49 - *inode_p = -1;
50 + errno = 0;
51 + *inode_p = strtoul(inode_str,&serr,0);
52 + if (!serr || *serr || errno)
53 + *status = -1;
54 }
55 }
56
57
58
59 -static void extract_type_2_socket_inode(const char lname[], long * inode_p) {
60 +static void extract_type_2_socket_inode(const char lname[], unsigned long * inode_p, int * status) {
61
62 /* If lname is of the form "[0000]:12345", extract the "12345"
63 - as *inode_p. Otherwise, return -1 as *inode_p.
64 + as *inode_p. Otherwise, return -1 as *status.
65 */
66
67 - if (strlen(lname) < PRG_SOCKET_PFX2l+1) *inode_p = -1;
68 - else if (memcmp(lname, PRG_SOCKET_PFX2, PRG_SOCKET_PFX2l)) *inode_p = -1;
69 + if (strlen(lname) < PRG_SOCKET_PFX2l+1) *status = -1;
70 + else if (memcmp(lname, PRG_SOCKET_PFX2, PRG_SOCKET_PFX2l)) *status = -1;
71 else {
72 char *serr;
73
74 - *inode_p=strtol(lname + PRG_SOCKET_PFX2l,&serr,0);
75 - if (!serr || *serr || *inode_p < 0 || *inode_p >= INT_MAX)
76 - *inode_p = -1;
77 + errno = 0;
78 + *inode_p=strtoul(lname + PRG_SOCKET_PFX2l,&serr,0);
79 + if (!serr || *serr || errno)
80 + *status = -1;
81 }
82 }
83
84 @@ -380,11 +383,12 @@
85 char line[LINE_MAX],eacces=0;
86 int procfdlen,fd,cmdllen,lnamelen;
87 char lname[30],cmdlbuf[512],finbuf[PROGNAME_WIDTH];
88 - long inode;
89 + unsigned long inode;
90 const char *cs,*cmdlp;
91 DIR *dirproc=NULL,*dirfd=NULL;
92 struct dirent *direproc,*direfd;
93 security_context_t scon=NULL;
94 + int status;
95
96 if (prg_cache_loaded || !flag_prg) return;
97 prg_cache_loaded=1;
98 @@ -424,11 +428,11 @@
99 lnamelen=readlink(line,lname,sizeof(lname)-1);
100 lname[lnamelen] = '\0'; /*make it a null-terminated string*/
101
102 - extract_type_1_socket_inode(lname, &inode);
103 + extract_type_1_socket_inode(lname, &inode, &status);
104
105 - if (inode < 0) extract_type_2_socket_inode(lname, &inode);
106 + if (status < 0) extract_type_2_socket_inode(lname, &inode, &status);
107
108 - if (inode < 0) continue;
109 + if (status < 0) continue;
110
111 if (!cmdlp) {
112 if (procfdlen - PATH_FD_SUFFl + PATH_CMDLINEl >=
113 @@ -732,7 +736,7 @@
114 printf("%-10s ", pw->pw_name);
115 else
116 printf("%-10d ", uid);
117 - printf("%-10ld ",inode);
118 + printf("%-10lu ",inode);
119 }
120 if (flag_prg)
121 printf("%-" PROGNAME_WIDTHs "s",prg_cache_get(inode));
122 @@ -921,7 +925,7 @@
123 return;
124
125 num = sscanf(line,
126 - "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %ld %512s\n",
127 + "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %512s\n",
128 &d, local_addr, &local_port, rem_addr, &rem_port, &state,
129 &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
130
131 @@ -1064,7 +1068,7 @@
132
133 more[0] = '\0';
134 num = sscanf(line,
135 - "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %ld %512s\n",
136 + "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %512s\n",
137 &d, local_addr, &local_port,
138 rem_addr, &rem_port, &state,
139 &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
140 @@ -1206,7 +1210,7 @@
141
142 more[0] = '\0';
143 num = sscanf(line,
144 - "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %ld %512s\n",
145 + "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %512s\n",
146 &d, local_addr, &local_port, rem_addr, &rem_port, &state,
147 &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
148
149 @@ -1320,9 +1324,9 @@
150 static int has = 0;
151 char path[MAXPATHLEN], ss_flags[32];
152 char *ss_proto, *ss_state, *ss_type;
153 - int num, state, type, inode;
154 + int num, state, type;
155 void *d;
156 - unsigned long refcnt, proto, flags;
157 + unsigned long refcnt, proto, flags, inode;
158
159 if (nr == 0) {
160 if (strstr(line, "Inode"))
161 @@ -1330,14 +1334,14 @@
162 return;
163 }
164 path[0] = '\0';
165 - num = sscanf(line, "%p: %lX %lX %lX %X %X %d %s",
166 + num = sscanf(line, "%p: %lX %lX %lX %X %X %lu %s",
167 &d, &refcnt, &proto, &flags, &type, &state, &inode, path);
168 if (num < 6) {
169 fprintf(stderr, _("warning, got bogus unix line.\n"));
170 return;
171 }
172 if (!(has & HAS_INODE))
173 - snprintf(path,sizeof(path),"%d",inode);
174 + snprintf(path,sizeof(path),"%lu",inode);
175
176 if (!flag_all) {
177 if ((state == SS_UNCONNECTED) && (flags & SO_ACCEPTCON)) {
178 @@ -1429,7 +1433,7 @@
179 printf("%-5s %-6ld %-11s %-10s %-13s ",
180 ss_proto, refcnt, ss_flags, ss_type, ss_state);
181 if (has & HAS_INODE)
182 - printf("%-6d ",inode);
183 + printf("%-6lu ",inode);
184 else
185 printf("- ");
186 if (flag_prg)