[PATCH] v9fs: zero copy implementation
[powerpc.git] / fs / 9p / error.c
index 834cb17..e4b6f8f 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <linux/list.h>
 #include <linux/jhash.h>
-#include <linux/string.h>
 
 #include "debug.h"
 #include "error.h"
@@ -55,7 +54,8 @@ int v9fs_error_init(void)
 
        /* load initial error map into hash table */
        for (c = errmap; c->name != NULL; c++) {
-               bucket = jhash(c->name, strlen(c->name), 0) % ERRHASHSZ;
+               c->namelen = strlen(c->name);
+               bucket = jhash(c->name, c->namelen, 0) % ERRHASHSZ;
                INIT_HLIST_NODE(&c->list);
                hlist_add_head(&c->list, &hash_errmap[bucket]);
        }
@@ -69,15 +69,15 @@ int v9fs_error_init(void)
  *
  */
 
-int v9fs_errstr2errno(char *errstr)
+int v9fs_errstr2errno(char *errstr, int len)
 {
        int errno = 0;
        struct hlist_node *p = NULL;
        struct errormap *c = NULL;
-       int bucket = jhash(errstr, strlen(errstr), 0) % ERRHASHSZ;
+       int bucket = jhash(errstr, len, 0) % ERRHASHSZ;
 
        hlist_for_each_entry(c, p, &hash_errmap[bucket], list) {
-               if (!strcmp(c->name, errstr)) {
+               if (c->namelen==len && !memcmp(c->name, errstr, len)) {
                        errno = c->val;
                        break;
                }