Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Fri, 1 Mar 2002 18:42:35 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Fri, 1 Mar 2002 18:42:26 -0500 Received: from fungus.teststation.com ([212.32.186.211]:8208 "EHLO fungus.teststation.com") by vger.kernel.org with ESMTP id ; Fri, 1 Mar 2002 18:42:18 -0500 Date: Sat, 2 Mar 2002 00:41:58 +0100 (CET) From: Urban Widmark X-X-Sender: To: Cyrille Chepelov , =?iso-8859-1?Q?Christian_Borntr=E4ger?= , cc: Alexander Viro Subject: [PATCH] smbfs codepage fixes for 2.4.18 Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-1463780587-1260605775-1015025226=:23050" Content-ID: Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---1463780587-1260605775-1015025226=:23050 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII Content-ID: Ok, I think I've got something regarding the 2.4.18 oopses. (oopsen?) There are two errors in the changes to smbfs in 2.4.18-rc3 (and 2.5.5) 1. SMB_MAXNAMELEN (max length of a single path component) was used where SMB_MAXPATHLEN (max total path length) should have been used. 2. The charset conversion routine was modified to return errors as negative values but not all callers was changed to handle this. When an "illegal" character was hit the length of the string was set to 0xffffffff and when computing the hash value it read outside the kernel memory. Attached is a patch vs 2.4.18 that fixes these issues for me. Please test and let me know. If I select a codepage/charset combination that doesn't match I now get a somewhat cryptic message instead of an oops (just a temporary thing). "smbfs: filename charset conversion failed" The file is then hidden, which is bad. Conversion errors should map to '?' as they used to or do some translation into ":####" strings. I'll do something about that. Some comments on what some of you have been doing: The smbfs remote codepage can never be utf8 since there are no smb servers that talk utf8. It can be one of the dos codepages, it can be blank or with additional patches it can be a 2 byte little endian unicode format. Furthermore, the local charset must be one that matches the chars used in the remote set. Otherwise you get conversion errors. A few known good combinations are: cp850 <-> iso8859-1 cp866 <-> koi8-r cp932 <-> euc-jp (the right is the local = linux side) See also the smb.conf manpage. But even with these it seems to be possible to create chars that do not match, and I think it is caused by windows trying to map unicode to a codepage and not finding a matching char to use. Local utf8 always matches the remote and is preferred if your system is setup to handle it. I would explain the reported smb_proc_readdir_long: name= result=-2, rcls=1, err=2 as a name conversion problem. If the conversion failed one way it used to be truncated and would then fail when sent back to the server. The error is ERRDOS - ERRbadfile (File not found). Check the config and the nls maps used. /Urban ---1463780587-1260605775-1015025226=:23050 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME="smbfs-2.4.18-codepage.patch" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: ATTACHMENT; FILENAME="smbfs-2.4.18-codepage.patch" ZGlmZiAtdXJOIC1YIGV4Y2x1ZGUgbGludXgtMi40LjE4LW9yaWcvZnMvc21i ZnMvY2FjaGUuYyBsaW51eC0yLjQuMTgtc21iZnMvZnMvc21iZnMvY2FjaGUu Yw0KLS0tIGxpbnV4LTIuNC4xOC1vcmlnL2ZzL3NtYmZzL2NhY2hlLmMJU2F0 IEphbiAxMiAxNjo1NTo1OCAyMDAyDQorKysgbGludXgtMi40LjE4LXNtYmZz L2ZzL3NtYmZzL2NhY2hlLmMJRnJpIE1hciAgMSAyMTo0NjozNiAyMDAyDQpA QCAtODQsNyArODQsNyBAQA0KIAlzdHJ1Y3QgbGlzdF9oZWFkICpuZXh0Ow0K IA0KIAlpZiAoZF92YWxpZGF0ZShkZW50LCBwYXJlbnQpKSB7DQotCQlpZiAo ZGVudC0+ZF9uYW1lLmxlbiA8PSBTTUJfTUFYUEFUSExFTiAmJg0KKwkJaWYg KGRlbnQtPmRfbmFtZS5sZW4gPD0gU01CX01BWE5BTUVMRU4gJiYNCiAJCSAg ICAodW5zaWduZWQgbG9uZylkZW50LT5kX2ZzZGF0YSA9PSBmcG9zKSB7DQog CQkJaWYgKCFkZW50LT5k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mNvZGVfcGF0aChzZXJ2ZXIsIHBhcmFt KzYsIFNNQl9NQVhOQU1FTEVOKzEsIGRpciwgTlVMTCk7DQorCXJlc3VsdCA9 IHNtYl9lbmNvZGVfcGF0aChzZXJ2ZXIsIHBhcmFtKzYsIFNNQl9NQVhQQVRI TEVOKzEsIGRpciwgTlVMTCk7DQogCWlmIChyZXN1bHQgPCAwKQ0KIAkJZ290 byBvdXQ7DQogCXAgPSBwYXJhbSArIDYgKyByZXN1bHQ7DQo= ---1463780587-1260605775-1015025226=:23050-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/