From df6d26e4bda11fbbaba12289638d04b4cc868b98 Mon Sep 17 00:00:00 2001
From: "heikki@hundin.mysql.fi" <>
Date: Thu, 3 Mar 2005 17:46:56 +0200
Subject: [PATCH] srv0start.c:   Work around the AIX 5.1 ML7 patch problem in
 errno at a higher level, in srv0start.c os0file.c:   Revert the AIX patch
 here

---
 innobase/os/os0file.c    |  9 ---------
 innobase/srv/srv0start.c | 19 +++++++++++++++++--
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 334452e09a..cadf1c0385 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -291,15 +291,6 @@ os_file_get_last_error(void)
 		return(OS_FILE_NOT_FOUND);
 	} else if (err == EEXIST) {
 		return(OS_FILE_ALREADY_EXISTS);
-#ifdef UNIV_AIX
-	} else if (err == 0) {
-		fprintf(stderr,
-"InnoDB: errno is 0. Since AIX 5.1 after security patch ML7 erroneously\n"
-"InnoDB: sets errno to 0 when it should be EEXIST, we assume that the real\n"
-"InnoDB: error here was EEXIST.\n");
- 
-		return(OS_FILE_ALREADY_EXISTS);
-#endif
 	} else {
 		return(100 + err);
 	}
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index 9baa86234a..53ef97dc42 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -540,7 +540,14 @@ open_or_create_log_file(
 	files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL,
 						OS_LOG_FILE, &ret);
 	if (ret == FALSE) {
-		if (os_file_get_last_error() != OS_FILE_ALREADY_EXISTS) {
+		if (os_file_get_last_error() != OS_FILE_ALREADY_EXISTS
+#ifdef UNIV_AIX
+		   	/* AIX 5.1 after security patch ML7 may have errno set
+			to 0 here, which causes our function to return 100;
+			work around that AIX problem */
+		   && os_file_get_last_error() != 100
+#endif
+		) {
 			fprintf(stderr,
 			"InnoDB: Error in creating or opening %s\n", name);
 				
@@ -712,7 +719,15 @@ open_or_create_data_files(
 		if (ret == FALSE) {
 			if (srv_data_file_is_raw_partition[i] != SRV_OLD_RAW
 			    && os_file_get_last_error() !=
-						OS_FILE_ALREADY_EXISTS) {
+						OS_FILE_ALREADY_EXISTS
+#ifdef UNIV_AIX
+		   		/* AIX 5.1 after security patch ML7 may have
+				errno set to 0 here, which causes our function
+				to return 100; work around that AIX problem */
+		   	    && os_file_get_last_error() != 100
+#endif
+			) {
+
 				fprintf(stderr,
 				"InnoDB: Error in creating or opening %s\n",
 				name);
-- 
2.30.9