Fix missing strnlen problems

Fix missing strnlen (a GNU extension) problems by using qemu_strnlen
used for user emulators also for system emulators.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
diff --git a/block.c b/block.c
index 3fe9317..c7589b1 100644
--- a/block.c
+++ b/block.c
@@ -225,7 +225,7 @@
 {
     BlockDriver *drv1;
     char protocol[128];
-    int len = strnlen(filename, 127)+1;
+    int len = qemu_strnlen(filename, 127) + 1;
     const char *p;
 
 #ifdef _WIN32
diff --git a/bsd-user/uaccess.c b/bsd-user/uaccess.c
index cc51449..9ec1b23 100644
--- a/bsd-user/uaccess.c
+++ b/bsd-user/uaccess.c
@@ -37,17 +37,6 @@
     return ret;
 }
 
-/* XXX: use host strnlen if available ? */
-static int qemu_strnlen(const char *s, int max_len)
-{
-    int i;
-    for(i = 0; i < max_len; i++) {
-        if (s[i] == '\0')
-            break;
-    }
-    return i;
-}
-
 /* Return the length of a string in target memory or -TARGET_EFAULT if
    access error  */
 abi_long target_strlen(abi_ulong guest_addr1)
diff --git a/cutils.c b/cutils.c
index 73d4e1f..6196a90 100644
--- a/cutils.c
+++ b/cutils.c
@@ -109,6 +109,19 @@
     return 1;
 }
 
+/* XXX: use host strnlen if available ? */
+int qemu_strnlen(const char *s, int max_len)
+{
+    int i;
+
+    for(i = 0; i < max_len; i++) {
+        if (s[i] == '\0') {
+            break;
+        }
+    }
+    return i;
+}
+
 time_t mktimegm(struct tm *tm)
 {
     time_t t;
diff --git a/linux-user/uaccess.c b/linux-user/uaccess.c
index 4d50693..a4d108c 100644
--- a/linux-user/uaccess.c
+++ b/linux-user/uaccess.c
@@ -37,17 +37,6 @@
     return ret;
 }
 
-/* XXX: use host strnlen if available ? */
-static int qemu_strnlen(const char *s, int max_len)
-{
-    int i;
-    for(i = 0; i < max_len; i++) {
-        if (s[i] == '\0')
-            break;
-    }
-    return i;
-}
-
 /* Return the length of a string in target memory or -TARGET_EFAULT if
    access error  */
 abi_long target_strlen(abi_ulong guest_addr1)
diff --git a/qemu-common.h b/qemu-common.h
index 5b8ac77..a5d8fff 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -109,6 +109,7 @@
 char *pstrcat(char *buf, int buf_size, const char *s);
 int strstart(const char *str, const char *val, const char **ptr);
 int stristart(const char *str, const char *val, const char **ptr);
+int qemu_strnlen(const char *s, int max_len);
 time_t mktimegm(struct tm *tm);
 int qemu_fls(int i);