From owner-freebsd-fs@FreeBSD.ORG Tue Nov 4 08:34:08 2003 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8560516A4CF; Tue, 4 Nov 2003 08:34:08 -0800 (PST) Received: from mail.ryu16.org (YahooBB219005044050.bbtec.net [219.5.44.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 009BE43FB1; Tue, 4 Nov 2003 08:34:05 -0800 (PST) (envelope-from imura@ryu16.org) Received: from redeye.xt.ryu16.org (localhost [127.0.0.1]) by mail.ryu16.org (8.12.9p1/8.12.9) with ESMTP id hA4GY3wQ011246; Wed, 5 Nov 2003 01:34:03 +0900 (JST) (envelope-from imura@redeye.xt.ryu16.org) Received: (from imura@localhost) by redeye.xt.ryu16.org (8.12.9p1/8.12.9/Submit) id hA4GXxhX011229; Wed, 5 Nov 2003 01:33:59 +0900 (JST) (envelope-from imura) Date: Wed, 5 Nov 2003 01:33:59 +0900 From: "R. Imura" To: Scott Long Message-ID: <20031104163359.GA8303%imura@ryu16.org> References: <20031102164218.GB606%imura@ryu16.org> <20031103195211.GA63701%imura@ryu16.org> <3FA77ECC.90309@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3FA77ECC.90309@freebsd.org> User-Agent: Mutt/1.4.1i-ja.1 cc: i18n@freebsd.org cc: fs@freebsd.org Subject: Re: [patch] combine mount_udf(8) with kiconv(3) X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Nov 2003 16:34:08 -0000 Hi, On Tue, Nov 04, 2003 at 03:26:20AM -0700, Scott Long wrote: > Hi, > > This looks very good. I have one question, however, Why do you > copy transname into unibuf? Is it because of endian problems? > If so, feel free to modify the OSTA code to produce the correct > format. Doing a second zalloc() and copy for every single > filename gets expensive and should be avoided. Ah, yes, you're right. I now modified the OSTA code and add udf_UncompressUnicodeByte() to it. When iconv is available udf_UncompressUnicodeByte() is used, and when not udf_UncompressUnicode() is used. New patch is http://www.ryu16.org/FreeBSD/kiconv/udf_5_current_20031104.diff Difference from previous version's udf_vnops.c is as follows. diff -u -r1.1.2.6 udf_vnops.c --- udf_vnops.c 4 Nov 2003 15:17:48 -0000 1.1.2.6 +++ udf_vnops.c 4 Nov 2003 15:45:41 -0000 @@ -459,42 +459,43 @@ unicode_t *transname; char *unibuf, *unip; int i, unilen = 0, destlen; - size_t unileft, destleft = MAXNAMLEN; - - /* allocate a buffer big enough to hold an 8->16 bit expansion */ - transname = uma_zalloc(udf_zone_trans, M_WAITOK); - - if ((unilen = udf_UncompressUnicode(len, cs0string, transname)) == -1) { - printf("udf: Unicode translation failed\n"); - uma_zfree(udf_zone_trans, transname); - return 0; - } + size_t destleft = MAXNAMLEN; /* Convert 16-bit Unicode to destname */ if (udfmp->im_flags & UDFMNT_KICONV && udf_iconv) { + /* allocate a buffer big enough to hold an 8->16 bit expansion */ unibuf = uma_zalloc(udf_zone_trans, M_WAITOK); unip = unibuf; - for (i = 0; i < unilen ; i++) { - *unibuf++ = (char)(transname[i] >> 8); - *unibuf++ = (char)transname[i]; + if ((unilen = udf_UncompressUnicodeByte(len, cs0string, unibuf)) == -1) { + printf("udf: Unicode translation failed\n"); + uma_zfree(udf_zone_trans, unibuf); + return 0; } - unibuf = unip; - unileft = (size_t)unilen * 2; - while (unileft > 0 && destleft > 0) { + + while (unilen > 0 && destleft > 0) { udf_iconv->conv(udfmp->im_d2l, (const char **)&unibuf, - &unileft, (char **)&destname, &destleft); + (size_t *)&unilen, (char **)&destname, &destleft); /* Unconverted character found */ - if (unileft > 0 && destleft > 0) { + if (unilen > 0 && destleft > 0) { *destname++ = '?'; destleft--; unibuf += 2; - unileft -= 2; + unilen -= 2; } } uma_zfree(udf_zone_trans, unip); *destname = '\0'; destlen = MAXNAMLEN - (int)destleft; } else { + /* allocate a buffer big enough to hold an 8->16 bit expansion */ + transname = uma_zalloc(udf_zone_trans, M_WAITOK); + + if ((unilen = udf_UncompressUnicode(len, cs0string, transname)) == -1) { + printf("udf: Unicode translation failed\n"); + uma_zfree(udf_zone_trans, transname); + return 0; + } + for (i = 0; i < unilen ; i++) { if (transname[i] & 0xff00) { destname[i] = '.'; /* Fudge the 16bit chars */ @@ -502,11 +503,10 @@ destname[i] = transname[i] & 0xff; } } + uma_zfree(udf_zone_trans, transname); destname[unilen] = 0; destlen = unilen; } - - uma_zfree(udf_zone_trans, transname); return (destlen); } - R. Imura