Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Nov 2003 09:46:24 -0700 (MST)
From:      Scott Long <scottl@freebsd.org>
To:        "R. Imura" <imura@ryu16.org>
Cc:        fs@freebsd.org
Subject:   Re: [patch] combine mount_udf(8) with kiconv(3)
Message-ID:  <20031104094546.I36900@pooker.samsco.home>
In-Reply-To: <20031104163359.GA8303%imura@ryu16.org>
References:  <20031102164218.GB606%imura@ryu16.org> <20031103195211.GA63701%imura@ryu16.org> <3FA77ECC.90309@freebsd.org> <20031104163359.GA8303%imura@ryu16.org>

next in thread | previous in thread | raw e-mail | index | archive | help

Ok, looks good.  Please send me a full diff and I'll commit it.

Thanks!

Scott

On Wed, 5 Nov 2003, R. Imura wrote:

> 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
>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031104094546.I36900>