Re: [patch] Re: 2.2.16pre nls in 2.3?

From: Urban Widmark (urban@svenskatest.se)
Date: Sun May 21 2000 - 07:35:25 EDT

  • Next message: Alan Cox: "Re: [patch] Re: 2.2.16pre nls in 2.3?"

    On Sun, 21 May 2000, Petr Vandrovec wrote:

    > Hi Urban,
    > from ncpfs point of view it looks OK. I have one question - currently
    > callers of ncp_io2vol conversions assume that this conversion will not
    > produce string longer than original (it can produce shorter if external
    > encoding is utf8). But after multibyte encodings come to kernel, this
    > may be no longer true. Is there any method to compute upper boundary of
    > resulting string size? I do not want to use get_free_page() for
    > temporary results :-(

    You would like something
      nls->max_character_size
    or
      nls->strlen(unicode_str)
    or
      nls->str_ubound(str_len)
    or
    #define NLS_MAX_CODEPAGE_CHAR_SIZE 2
    ?

    I don't think there is anything in the current interface to ask the nls
    how long strings it may produce.

    You allocate these temporary results on the stack ... how long can 'len'
    be?
    - __u8 __name[len];
    + __u8 __name[2*len]; /* 16-bit character support hack :) */

    For my smbfs-nls thing I now have a temporary buffer in the 'server'
    structure. That works because the server struct is locked and there is no
    recursion. But it doesn't adjust the maxlength by which encoding we use
    and will give errors if the name is too long (hmm, I think it will
    truncate them silently ... oops :)

    Also, iirc the linux side encoding, as returned to userspace, is supposed
    to be (capable of handling) utf8, not just iso-whatever. Currently that
    means that 6-byte characters are possible (nls_base.c).

    The ncpfs code I changed will complain (loudly?) if the charset wants more
    than one byte per character.

            if (out->uni2char(uc.uni2, uc.uni1, &nc, 1, &len) == -1)
                    return -EINVAL;

    The 1 is for the maximum number of characters it is allowed to write, and
    the 2.2.16-pre code has a similar limitation. Since you do toupper/tolower
    that needs fixing too for the new codepages.

    /Urban

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/



    This archive was generated by hypermail 2b29 : Sun May 21 2000 - 07:39:16 EDT