- snprintf(path, sizeof(path), "%s%s%s", "/sys/class/net/", iface, "/operstate");
- fp = fopen(path, "r");
- if (fp == NULL) {
- warn("Failed to open file %s", path);
- return NULL;
- }
- p = fgets(status, 5, fp);
- fclose(fp);
- if(!p || strcmp(status, "up\n") != 0) {
- return NULL;
- }
+ snprintf(path, sizeof(path), "%s%s%s", "/sys/class/net/", iface,
+ "/operstate");
+ fp = fopen(path, "r");
+ if (fp == NULL) {
+ fprintf(stderr, "fopen '%s': %s\n", path,
+ strerror(errno));
+ return NULL;
+ }
+ p = fgets(status, 5, fp);
+ fclose(fp);
+ if(!p || strcmp(status, "up\n") != 0) {
+ return NULL;
+ }