Skip to contentSkip to conversation

cifs: correction of unicode header files

PATCH In review Igor Druzhinin 4 participants 5 messages Aug 19, 2010 – Aug 21, 2010 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cifs: correction of unicode header files

This patch corrects a problem of compilation errors at removal of UNIUPR_NOLOWER definition and adds include guards to cifs_unicode.h.

---
 fs/cifs/cifs_unicode.h |   18 +++++++++++-------
 fs/cifs/cifs_uniupr.h  |   16 ++++++++--------
 2 files changed, 19 insertions(+), 15 deletions(-)
fs/cifs/cifs_unicode.h +11 -7
index 6506382..7fe6b52 100644
@@ -30,6 +30,8 @@
  *     This is a compressed table of upper and lower case conversion.
  *
  */
+#ifndef _CIFS_UNICODE_H
+#define _CIFS_UNICODE_H
 
 #include <asm/byteorder.h>
 #include <linux/types.h>
@@ -67,8 +69,8 @@ extern const struct UniCaseRange CifsUniUpperRange[];
 #endif				/* UNIUPR_NOUPPER */
 
 #ifndef UNIUPR_NOLOWER
-extern signed char UniLowerTable[512];
-extern struct UniCaseRange UniLowerRange[];
+extern signed char CifsUniLowerTable[512];
+extern const struct UniCaseRange CifsUniLowerRange[];
 #endif				/* UNIUPR_NOLOWER */
 
 #ifdef __KERNEL__
@@ -337,15 +339,15 @@ UniStrupr(register wchar_t *upin)
  * UniTolower:  Convert a unicode character to lower case
  */
 static inline wchar_t
-UniTolower(wchar_t uc)
+UniTolower(register wchar_t uc)
 {
-	register struct UniCaseRange *rp;
+	register const struct UniCaseRange *rp;
 
-	if (uc < sizeof(UniLowerTable)) {
+	if (uc < sizeof(CifsUniLowerTable)) {
 		/* Latin characters */
-		return uc + UniLowerTable[uc];	/* Use base tables */
+		return uc + CifsUniLowerTable[uc];	/* Use base tables */
 	} else {
-		rp = UniLowerRange;	/* Use range tables */
+		rp = CifsUniLowerRange;	/* Use range tables */
 		while (rp->start) {
 			if (uc < rp->start)	/* Before start of range */
 				return uc;	/* Uppercase = input */
@@ -374,3 +376,5 @@ UniStrlwr(register wchar_t *upin)
 }
 
 #endif
+
+#endif /* _CIFS_UNICODE_H */
fs/cifs/cifs_uniupr.h +8 -8
index 18a9d97..0ac7c5a 100644
@@ -140,7 +140,7 @@ const struct UniCaseRange CifsUniUpperRange[] = {
 /*
  * Latin lower case
  */
-static signed char CifsUniLowerTable[512] = {
+signed char CifsUniLowerTable[512] = {
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* 000-00f */
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* 010-01f */
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* 020-02f */
@@ -242,12 +242,12 @@ static signed char UniCaseRangeLff20[27] = {
 /*
  * Lower Case Range
  */
-static const struct UniCaseRange CifsUniLowerRange[] = {
-	0x0380, 0x03ab, UniCaseRangeL0380,
-	0x0400, 0x042f, UniCaseRangeL0400,
-	0x0490, 0x04cb, UniCaseRangeL0490,
-	0x1e00, 0x1ff7, UniCaseRangeL1e00,
-	0xff20, 0xff3a, UniCaseRangeLff20,
-	0, 0, 0
+const struct UniCaseRange CifsUniLowerRange[] = {
+	{0x0380, 0x03ab, UniCaseRangeL0380},
+	{0x0400, 0x042f, UniCaseRangeL0400},
+	{0x0490, 0x04cb, UniCaseRangeL0490},
+	{0x1e00, 0x1ff7, UniCaseRangeL1e00},
+	{0xff20, 0xff3a, UniCaseRangeLff20},
+	{0}
 };
 #endif
Signature · 1 line
1.7.2.1

A message that is not in the archive (sent off-list or not yet received): 1282249633-27756-1-git-send-email-jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 2/2 cifs: infrastructure for stashing passwords in keyring

This is a kernel part of a new infrastructure for stashing passwords in kernel keyring per user basis. Keys of "user" type with passwords are protected from disclosure and stored in uid-specific keyring. Search is happens according to the key description in format cifscreds:ip:username:[domainname]. In a case if user has given credentials otherwise search doesn't happen.

---
 fs/cifs/Makefile    |    2 +-
 fs/cifs/cifscreds.c |  192 +++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/cifs/cifscreds.h |   34 +++++++++
 fs/cifs/connect.c   |   13 ++++
 4 files changed, 240 insertions(+), 1 deletions(-)
 create mode 100644 fs/cifs/cifscreds.c
 create mode 100644 fs/cifs/cifscreds.h
fs/cifs/Makefile +1 -1
index adefa60..babab37 100644
@@ -6,7 +6,7 @@ obj-$(CONFIG_CIFS) += cifs.o
 cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \
 	  link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o \
 	  md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o \
-	  readdir.o ioctl.o sess.o export.o cifsacl.o
+	  readdir.o ioctl.o sess.o export.o cifsacl.o cifscreds.o
 
 cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o
 
fs/cifs/cifscreds.c new file +192 -0

192 lines not on this page · raw message

fs/cifs/cifscreds.h new file +34 -0
new file mode 100644
index 0000000..466ecf9
@@ -0,0 +1,34 @@
+/*
+ *   fs/cifs/cifscreds.c - CIFS credentinals stashing rountine definition
+ *
+ *   Copyright (c) 2010 Igor Druzhinin
+ *   Copyright (c) 2010 Jeff Layton
+ *   Author(s): Igor Druzhinin ([email protected])
+ *		Jeff Layton ([email protected])
+ *
+ *   This library is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Lesser General Public License as published
+ *   by the Free Software Foundation; either version 2.1 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This library is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+ *   the GNU Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public License
+ *   along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef _CIFSCREDS_H
+#define _CIFSCREDS_H
+
+#include <linux/keyctl.h>
+
+#define CIFSCREDS_PROG_NAME "cifscreds"
+#define DEST_KEYRING KEY_SPEC_USER_KEYRING
+
+extern char *
+cifs_get_key_password(const char *addr,	const char *user, const char *domain);
+
+#endif /* _CIFSCREDS_H */
fs/cifs/connect.c +13 -0
index 95c2ea6..ef4371e 100644
@@ -49,6 +49,7 @@
 #include "rfc1002pdu.h"
 #include "cn_cifs.h"
 #include "fscache.h"
+#include "cifscreds.h"
 
 #define CIFS_PORT 445
 #define RFC1001_PORT 139
@@ -2568,6 +2569,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
 	struct TCP_Server_Info *srvTcp;
 	char   *full_path;
 	char *mount_data = mount_data_global;
+	char *key_password;
 #ifdef CONFIG_CIFS_DFS_UPCALL
 	struct dfs_info3_param *referrals = NULL;
 	unsigned int num_referrals = 0;
@@ -2622,6 +2624,17 @@ try_mount_again:
 	}
 	cifs_sb->local_nls = volume_info->local_nls;
 
+	/* search for key with password and read its payload */
+	if (volume_info->password == NULL &&
+		!(volume_info->secFlg & CIFSSEC_MAY_KRB5)
+	) {
+		key_password = cifs_get_key_password(volume_info->UNCip,
+						volume_info->username,
+						volume_info->domainname);
+		if (key_password != NULL)
+			volume_info->password = key_password;
+	}
+
 	/* get a reference to a tcp session */
 	srvTcp = cifs_get_tcp_session(volume_info);
 	if (IS_ERR(srvTcp)) {
Signature · 1 line
1.7.2.1

A message that is not in the archive (sent off-list or not yet received): 1282249633-27756-2-git-send-email-jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw

Re: [PATCH 2/2] cifs: infrastructure for stashing passwords in keyring

Quoted 117 lines · On Fri, 20 Aug 2010 00:27:13 +0400 Igor Druzhinin…

This is a kernel part of a new infrastructure for stashing passwords in kernel keyring per user basis. Keys of "user" type with passwords are protected from disclosure and stored in uid-specific keyring. Search is happens according to the key description in format cifscreds:ip:username:[domainname]. In a case if user has given credentials otherwise search doesn't happen.

---
 fs/cifs/Makefile    |    2 +-
 fs/cifs/cifscreds.c |  192 +++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/cifs/cifscreds.h |   34 +++++++++
 fs/cifs/connect.c   |   13 ++++
 4 files changed, 240 insertions(+), 1 deletions(-)
 create mode 100644 fs/cifs/cifscreds.c
 create mode 100644 fs/cifs/cifscreds.h
fs/cifs/Makefile +1 -1
index adefa60..babab37 100644
@@ -6,7 +6,7 @@ obj-$(CONFIG_CIFS) += cifs.o
 cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \
 	  link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o \
 	  md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o \
-	  readdir.o ioctl.o sess.o export.o cifsacl.o
+	  readdir.o ioctl.o sess.o export.o cifsacl.o cifscreds.o
 
 cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o
 
fs/cifs/cifscreds.c new file +81 -0
new file mode 100644
index 0000000..828631f
@@ -0,0 +1,192 @@
+/*
+ *   fs/cifs/cifscreds.c - CIFS credentinals stashing rountine
+ *
+ *   Copyright (c) 2010 Igor Druzhinin
+ *   Copyright (c) 2010 Jeff Layton
+ *   Author(s): Igor Druzhinin ([email protected])
+ *		Jeff Layton ([email protected])
+ *
+ *   This library is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Lesser General Public License as published
+ *   by the Free Software Foundation; either version 2.1 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This library is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+ *   the GNU Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public License
+ *   along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+#include <linux/inet.h>
+#include <linux/key.h>
+#include <linux/keyctl.h>
+#include <linux/key-type.h>
+#include <keys/keyring-type.h>
+#include <keys/user-type.h>
+#include "cifsglob.h"
+#include "cifs_debug.h"
+#include "cifscreds.h"
+
+/* create key description from given credentials */
+static char *
+create_key_description(const char *addr, const char *user,
+			const char *domain, char *desc)
+{
+	char *str_end;
+	int str_len;
+
+	sprintf(desc, "%s:%s:%s:", CIFSCREDS_PROG_NAME, addr, user);
+
+	if (domain != NULL) {
+		str_end = desc + strlen(desc);
+		str_len = strlen(domain);
+		while (str_len--) {
+			*str_end = tolower(*domain++);
+			str_end++;
+		}
+		*str_end = '\0';
+	}
+
+	return desc;
+}
+
+/*
+ * searching for requested key in the uid or session specific keyring
+ * according to DEST_KEYRING macro. After all operations with key caller
+ * must do key_put()
+ */
+static struct key *
+cifs_key_search(const char *addr, const char *user, const char *domain)
+{
+	char *desc;
+	struct key *keyring, *key;
+	struct keyring_list *klist;
+	int loop;
+
+	switch (DEST_KEYRING) {
+	case KEY_SPEC_USER_KEYRING:
+		keyring = current_user()->uid_keyring;
+		break;
+
+	case KEY_SPEC_SESSION_KEYRING:
+		keyring = current_user()->session_keyring;
+		break;
+
+	default:

fs/cifs/cifscreds.c line 91

Quoted 10 lines
fs/cifs/cifscreds.c new file +10 -0
+		printk(KERN_WARNING "CIFS creds: unsupported keyring\n");
+		return NULL;
+	}
+	if (keyring == NULL) {
+		cFYI(1, "CIFS creds: keyring is not installed");
+		return NULL;
+	}
+
+	desc = kmalloc(INET6_ADDRSTRLEN + 200 + 256 + \
+			sizeof(CIFSCREDS_PROG_NAME) + 3, GFP_KERNEL);

There are a lot of magic numbers in the above. I think these should be turned into #define'd constants. Alternately, you could declare a "DESC_LENGTH" near the top of the file and add a comment that describes what each piece of the length refers to.

Quoted 13 lines
fs/cifs/cifscreds.c new file +13 -0
+	if (desc == NULL) {
+		printk(KERN_WARNING "CIFS creds: no memory for description\n");
+		return NULL;
+	}
+
+	create_key_description(addr, user, domain, desc);
+	cFYI(1, "CIFS creds: key description: %s for uid:%d",
+		desc, current_uid());
+
+	klist = rcu_dereference_protected(keyring->payload.subscriptions,
+		rwsem_is_locked((struct rw_semaphore *)&keyring->sem));
+	if (klist) {
+		for (loop = 0; loop < klist->nkeys; loop++) {

fs/cifs/cifscreds.c line 114

Quoted 10 lines
fs/cifs/cifscreds.c new file +10 -0
+			key = klist->keys[loop];
+
+			if (key->type == &key_type_user &&
+				(!key->type->match ||
+				key->type->match(key, desc)) &&
+				!test_bit(KEY_FLAG_REVOKED, &key->flags)
+			)
+				goto key_search_found;
+		}
+	}

I'm not clear on the need for the above loop -- is there some reason to not just use request_key() here? If you're concerned about limiting the search to specific keyrings, then there may be interfaces that handle that already or they can be added to the keyring code. I'm not convinced that we need to worry about that however.

Quoted 9 lines
fs/cifs/cifscreds.c new file +9 -0
+	kfree(desc);
+	return NULL;
+
+key_search_found:
+	atomic_inc(&key->usage);
+	kfree(desc);
+	return key;
+}
+

fs/cifs/cifscreds.c line 133

Quoted 10 lines
fs/cifs/cifscreds.c new file +10 -0
+/* read and copy key data to kernel buffer */
+static long cifs_key_read(const struct key *key, char *buffer, size_t buflen)
+{
+	struct user_key_payload *upayload;
+	long ret;
+
+	upayload = rcu_dereference_protected(key->payload.data,
+		rwsem_is_locked(&((struct key *)key)->sem));
+	ret = upayload->datalen;
+

You have a reference to the key here, right? Is there any need for the rcu stuff above?

Quoted 127 lines
fs/cifs/cifscreds.c new file +59 -0
+	/* we can return the data as is */
+	if (buffer && buflen > 0) {
+		if (buflen > upayload->datalen)
+			buflen = upayload->datalen;
+
+		if (memcpy(buffer, upayload->data, buflen) == NULL)
+			ret = -EFAULT;
+	}
+
+	return ret;
+}
+
+/**
+ * cifs_get_key_password - Reading password from the keyring
+ *		according to provided description.
+ * @addr: IP address of target server.
+ * @user: Name of the intrested user.
+ * @domain: Possible domain name. Can be NULL.
+ *
+ * Returns the pointer to password or NULL, and the caller is
+ * responsible for freeing it.
+ */
+char *
+cifs_get_key_password(const char *addr, const char *user, const char *domain)
+{
+	struct key *pass_key;
+	char *key_password = NULL;
+	long pass_len;
+
+	pass_key = cifs_key_search(addr, user, domain);
+	if (pass_key == NULL) {
+		cFYI(1, "CIFS creds: Appropriate key for %s not found",	addr);
+		return NULL;
+	}
+
+	pass_len = cifs_key_read(pass_key, NULL, 0);
+	if (pass_len == 0) {
+		cFYI(1, "CIFS creds: Password key for %s is empty", addr);
+		goto no_key_password;
+	}
+
+	key_password = kzalloc(pass_len, GFP_KERNEL);
+	if (key_password == NULL) {
+		printk(KERN_WARNING "CIFS creds: no memory for password\n");
+		goto no_key_password;
+	}
+
+	pass_len = cifs_key_read(pass_key, key_password, pass_len);
+	if (pass_len < 0) {
+		printk(KERN_WARNING "CIFS creds: unable to read key's "
+			"payload for %s\n", addr);
+		kzfree(key_password);
+		key_password = NULL;
+	}
+
+no_key_password:
+	key_put(pass_key);
+	return key_password;
+}
fs/cifs/cifscreds.h new file +34 -0
new file mode 100644
index 0000000..466ecf9
@@ -0,0 +1,34 @@
+/*
+ *   fs/cifs/cifscreds.c - CIFS credentinals stashing rountine definition
+ *
+ *   Copyright (c) 2010 Igor Druzhinin
+ *   Copyright (c) 2010 Jeff Layton
+ *   Author(s): Igor Druzhinin ([email protected])
+ *		Jeff Layton ([email protected])
+ *
+ *   This library is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Lesser General Public License as published
+ *   by the Free Software Foundation; either version 2.1 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This library is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+ *   the GNU Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public License
+ *   along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef _CIFSCREDS_H
+#define _CIFSCREDS_H
+
+#include <linux/keyctl.h>
+
+#define CIFSCREDS_PROG_NAME "cifscreds"
+#define DEST_KEYRING KEY_SPEC_USER_KEYRING
+
+extern char *
+cifs_get_key_password(const char *addr,	const char *user, const char *domain);
+
+#endif /* _CIFSCREDS_H */
fs/cifs/connect.c +6 -0
index 95c2ea6..ef4371e 100644
@@ -49,6 +49,7 @@
 #include "rfc1002pdu.h"
 #include "cn_cifs.h"
 #include "fscache.h"
+#include "cifscreds.h"
 
 #define CIFS_PORT 445
 #define RFC1001_PORT 139
@@ -2568,6 +2569,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
 	struct TCP_Server_Info *srvTcp;
 	char   *full_path;
 	char *mount_data = mount_data_global;
+	char *key_password;
 #ifdef CONFIG_CIFS_DFS_UPCALL
 	struct dfs_info3_param *referrals = NULL;
 	unsigned int num_referrals = 0;
@@ -2622,6 +2624,17 @@ try_mount_again:
 	}
 	cifs_sb->local_nls = volume_info->local_nls;
 
+	/* search for key with password and read its payload */
+	if (volume_info->password == NULL &&
+		!(volume_info->secFlg & CIFSSEC_MAY_KRB5)
+	) {

fs/cifs/connect.c try_mount_again: · line 2640

Quoted 10 lines
fs/cifs/connect.c +7 -0
+		key_password = cifs_get_key_password(volume_info->UNCip,
+						volume_info->username,
+						volume_info->domainname);
+		if (key_password != NULL)
+			volume_info->password = key_password;
+	}
+
 	/* get a reference to a tcp session */
 	srvTcp = cifs_get_tcp_session(volume_info);
 	if (IS_ERR(srvTcp)) {

Would it be better to put the above into CIFS_SessSetup() instead? Maybe add a static helper function does all of the above in sess.c and have each authtype that would need a password call that function to set the smb session password?

That may make it easier to integrate this into the multiuser mount code later too.

Signature · 1 line
Jeff Layton <[email protected]>
Acked-by
#5 lore raw
In reply to a message not in the archive
Quoted 4 lines · On Fri, 20 Aug 2010 00:27:12 +0400 Igor Druzhinin…

This patch corrects a problem of compilation errors at removal of UNIUPR_NOLOWER definition and adds include guards to cifs_unicode.h.

Quoted 89 lines
---
 fs/cifs/cifs_unicode.h |   18 +++++++++++-------
 fs/cifs/cifs_uniupr.h  |   16 ++++++++--------
 2 files changed, 19 insertions(+), 15 deletions(-)
fs/cifs/cifs_unicode.h +11 -7
index 6506382..7fe6b52 100644
@@ -30,6 +30,8 @@
  *     This is a compressed table of upper and lower case conversion.
  *
  */
+#ifndef _CIFS_UNICODE_H
+#define _CIFS_UNICODE_H
 
 #include <asm/byteorder.h>
 #include <linux/types.h>
@@ -67,8 +69,8 @@ extern const struct UniCaseRange CifsUniUpperRange[];
 #endif				/* UNIUPR_NOUPPER */
 
 #ifndef UNIUPR_NOLOWER
-extern signed char UniLowerTable[512];
-extern struct UniCaseRange UniLowerRange[];
+extern signed char CifsUniLowerTable[512];
+extern const struct UniCaseRange CifsUniLowerRange[];
 #endif				/* UNIUPR_NOLOWER */
 
 #ifdef __KERNEL__
@@ -337,15 +339,15 @@ UniStrupr(register wchar_t *upin)
  * UniTolower:  Convert a unicode character to lower case
  */
 static inline wchar_t
-UniTolower(wchar_t uc)
+UniTolower(register wchar_t uc)
 {
-	register struct UniCaseRange *rp;
+	register const struct UniCaseRange *rp;
 
-	if (uc < sizeof(UniLowerTable)) {
+	if (uc < sizeof(CifsUniLowerTable)) {
 		/* Latin characters */
-		return uc + UniLowerTable[uc];	/* Use base tables */
+		return uc + CifsUniLowerTable[uc];	/* Use base tables */
 	} else {
-		rp = UniLowerRange;	/* Use range tables */
+		rp = CifsUniLowerRange;	/* Use range tables */
 		while (rp->start) {
 			if (uc < rp->start)	/* Before start of range */
 				return uc;	/* Uppercase = input */
@@ -374,3 +376,5 @@ UniStrlwr(register wchar_t *upin)
 }
 
 #endif
+
+#endif /* _CIFS_UNICODE_H */
fs/cifs/cifs_uniupr.h +8 -8
index 18a9d97..0ac7c5a 100644
@@ -140,7 +140,7 @@ const struct UniCaseRange CifsUniUpperRange[] = {
 /*
  * Latin lower case
  */
-static signed char CifsUniLowerTable[512] = {
+signed char CifsUniLowerTable[512] = {
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* 000-00f */
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* 010-01f */
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* 020-02f */
@@ -242,12 +242,12 @@ static signed char UniCaseRangeLff20[27] = {
 /*
  * Lower Case Range
  */
-static const struct UniCaseRange CifsUniLowerRange[] = {
-	0x0380, 0x03ab, UniCaseRangeL0380,
-	0x0400, 0x042f, UniCaseRangeL0400,
-	0x0490, 0x04cb, UniCaseRangeL0490,
-	0x1e00, 0x1ff7, UniCaseRangeL1e00,
-	0xff20, 0xff3a, UniCaseRangeLff20,
-	0, 0, 0
+const struct UniCaseRange CifsUniLowerRange[] = {
+	{0x0380, 0x03ab, UniCaseRangeL0380},
+	{0x0400, 0x042f, UniCaseRangeL0400},
+	{0x0490, 0x04cb, UniCaseRangeL0490},
+	{0x1e00, 0x1ff7, UniCaseRangeL1e00},
+	{0xff20, 0xff3a, UniCaseRangeLff20},
+	{0}
 };
 #endif
Signature · 1 line
Jeff Layton <[email protected]>
#6 lore raw
In reply to a message not in the archive

Igor, quick question, what is 512, could it be any other number?

Quoted 101 lines · Igor Druzhinin

This patch corrects a problem of compilation errors at removal of UNIUPR_NOLOWER definition and adds include guards to cifs_unicode.h.

---
 fs/cifs/cifs_unicode.h |   18 +++++++++++-------
 fs/cifs/cifs_uniupr.h  |   16 ++++++++--------

 2 files changed, 19 insertions(+), 15 deletions(-)
fs/cifs/cifs_unicode.h +4 -2
index 6506382..7fe6b52 100644
@@ -30,6 +30,8 @@
  *     This is a compressed table of upper and lower case conversion.
  *
  */
+#ifndef _CIFS_UNICODE_H
+#define _CIFS_UNICODE_H
 
  #include <asm/byteorder.h>
  #include <linux/types.h>
@@ -67,8 +69,8 @@ extern const struct UniCaseRange CifsUniUpperRange[];
  #endif                         /* UNIUPR_NOUPPER */
 
  #ifndef UNIUPR_NOLOWER
-extern signed char UniLowerTable[512];
-extern struct UniCaseRange UniLowerRange[];
+extern signed char CifsUniLowerTable[512];
+extern const struct UniCaseRange CifsUniLowerRange[];
  #endif                         /* UNIUPR_NOLOWER */
 
  #ifdef __KERNEL__
@@ -337,15 +339,15 @@ UniStrupr(register wchar_t *upin)
  * UniTolower:  Convert a unicode character to lower case
  */

 static inline wchar_t

fs/cifs/cifs_unicode.h +1 -1
-UniTolower(wchar_t uc)
+UniTolower(register wchar_t uc)

 {
-       register struct UniCaseRange *rp;
+       register const struct UniCaseRange *rp;

-       if (uc < sizeof(UniLowerTable)) {
+       if (uc < sizeof(CifsUniLowerTable)) {
               /* Latin characters */
-               return uc + UniLowerTable[uc];  /* Use base tables */
+               return uc + CifsUniLowerTable[uc];      /* Use base tables */ } else {
-               rp = UniLowerRange;     /* Use range tables */
+               rp = CifsUniLowerRange; /* Use range tables */ while (rp->start) {
                       if (uc < rp->start)     /* Before start of range */ return uc;      /* Uppercase = input */

fs/cifs/cifs_unicode.h +2 -0
@@ -374,3 +376,5 @@ UniStrlwr(register wchar_t *upin)
  }
 
  #endif
+
+#endif /* _CIFS_UNICODE_H */
fs/cifs/cifs_uniupr.h +1 -1
index 18a9d97..0ac7c5a 100644
@@ -140,7 +140,7 @@ const struct UniCaseRange CifsUniUpperRange[] = {
  /*
  * Latin lower case
  */
-static signed char CifsUniLowerTable[512] = {
+signed char CifsUniLowerTable[512] = {

       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 000-00f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 010-01f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 020-02f */

fs/cifs/cifs_uniupr.h +7 -8
@@ -242,12 +242,12 @@ static signed char UniCaseRangeLff20[27] = {
  /*
  * Lower Case Range
  */
-static const struct UniCaseRange CifsUniLowerRange[] = {
-       0x0380, 0x03ab, UniCaseRangeL0380,
-       0x0400, 0x042f, UniCaseRangeL0400,
-       0x0490, 0x04cb, UniCaseRangeL0490,
-       0x1e00, 0x1ff7, UniCaseRangeL1e00,
-       0xff20, 0xff3a, UniCaseRangeLff20,
-       0, 0, 0
+const struct UniCaseRange CifsUniLowerRange[] = {
+       {0x0380, 0x03ab, UniCaseRangeL0380},
+       {0x0400, 0x042f, UniCaseRangeL0400},
+       {0x0490, 0x04cb, UniCaseRangeL0490},
+       {0x1e00, 0x1ff7, UniCaseRangeL1e00},
+       {0xff20, 0xff3a, UniCaseRangeLff20},
+       {0}
  };
  #endif
--

1.7.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html