@@ -35,10 +35,16 @@ static int for_each_table(int (*func)(const char
*tablename))
int ret = 1;
FILE *procfile = NULL;
char tablename[XT_TABLE_MAXNAMELEN+1];
-
- procfile = fopen("/proc/net/ip6_tables_names", "re");
- if (!procfile)
- return ret;
+ static const char filename[] = "/proc/net/ip6_tables_names";
+
+ procfile = fopen(filename, "re");
+ if (!procfile) {
+ if (errno == ENOENT)
+ return ret;
+ fprintf(stderr, "Failed to list table names in %s: %s\n",
+ filename, strerror(errno));
+ exit(1);
+ }
while (fgets(tablename, sizeof(tablename), procfile)) {
if (tablename[strlen(tablename) - 1] != '\n')
@@ -33,10 +33,16 @@ static int for_each_table(int (*func)(const char
*tablename))
int ret = 1;
FILE *procfile = NULL;
char tablename[XT_TABLE_MAXNAMELEN+1];
-
- procfile = fopen("/proc/net/ip_tables_names", "re");
- if (!procfile)
- return ret;
+ static const char filename[] = "/proc/net/ip_tables_names";
+
+ procfile = fopen(filename, "re");
+ if (!procfile) {
+ if (errno == ENOENT)
+ return ret;
+ fprintf(stderr, "Failed to list table names in %s: %s\n",
+ filename, strerror(errno));
+ exit(1);
+ }
while (fgets(tablename, sizeof(tablename), procfile)) {