From a1e5b90c0d7c6642cc1dc617ec324df8c88df049 Mon Sep 17 00:00:00 2001
From: Maxime Bizon <mbizon@freebox.fr>
Date: Mon, 4 Nov 2013 19:52:37 +0100
Subject: [PATCH 01/18] hostapd: silence more error cases when we cannot
 remove interface directory.

Signed-hostap: Maxime Bizon <mbizon@freebox.fr>
---
 hostapd/ctrl_iface.c |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 4dddf80..a833201 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -1751,15 +1751,20 @@ void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd)
 
 		if (hapd->conf->ctrl_interface &&
 		    rmdir(hapd->conf->ctrl_interface) < 0) {
-			if (errno == ENOTEMPTY) {
+			switch (errno) {
+			case ENOTEMPTY:
+			case EPERM:
+			case EROFS:
 				wpa_printf(MSG_DEBUG, "Control interface "
 					   "directory not empty - leaving it "
 					   "behind");
-			} else {
+				break;
+			default:
 				wpa_printf(MSG_ERROR,
 					   "rmdir[ctrl_interface=%s]: %s",
 					   hapd->conf->ctrl_interface,
 					   strerror(errno));
+				break;
 			}
 		}
 	}
@@ -1897,7 +1902,7 @@ int hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface)
 
 	if (mkdir(interface->global_iface_path, S_IRWXU | S_IRWXG) < 0) {
 		if (errno == EEXIST) {
-			wpa_printf(MSG_DEBUG, "Using existing control "
+			wpa_printf(MSG_DEBUG, "Using existing global control "
 				   "interface directory.");
 		} else {
 			perror("mkdir[ctrl_interface]");
@@ -2006,15 +2011,20 @@ void hostapd_global_ctrl_iface_deinit(struct hapd_interfaces *interfaces)
 
 		if (interfaces->global_iface_path &&
 		    rmdir(interfaces->global_iface_path) < 0) {
-			if (errno == ENOTEMPTY) {
-				wpa_printf(MSG_DEBUG, "Control interface "
+			switch (errno) {
+			case ENOTEMPTY:
+			case EPERM:
+			case EROFS:
+				wpa_printf(MSG_DEBUG, "Global control interface "
 					   "directory not empty - leaving it "
 					   "behind");
-			} else {
+				break;
+			default:
 				wpa_printf(MSG_ERROR,
-					   "rmdir[ctrl_interface=%s]: %s",
+					   "rmdir[global_ctrl_interface=%s]: %s",
 					   interfaces->global_iface_path,
 					   strerror(errno));
+				break;
 			}
 		}
 		os_free(interfaces->global_iface_path);
-- 
1.7.9.5

