~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/isofs/joliet.c

Version: ~ [ linux-5.8-rc4 ] ~ [ linux-5.7.7 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.50 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.131 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.187 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.229 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.229 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  linux/fs/isofs/joliet.c
  3  *
  4  *  (C) 1996 Gordon Chaffee
  5  *
  6  *  Joliet: Microsoft's Unicode extensions to iso9660
  7  */
  8 
  9 #include <linux/types.h>
 10 #include <linux/nls.h>
 11 #include "isofs.h"
 12 
 13 /*
 14  * Convert Unicode 16 to UTF-8 or ASCII.
 15  */
 16 static int
 17 uni16_to_x8(unsigned char *ascii, __be16 *uni, int len, struct nls_table *nls)
 18 {
 19         __be16 *ip, ch;
 20         unsigned char *op;
 21 
 22         ip = uni;
 23         op = ascii;
 24 
 25         while ((ch = get_unaligned(ip)) && len) {
 26                 int llen;
 27                 llen = nls->uni2char(be16_to_cpu(ch), op, NLS_MAX_CHARSET_SIZE);
 28                 if (llen > 0)
 29                         op += llen;
 30                 else
 31                         *op++ = '?';
 32                 ip++;
 33 
 34                 len--;
 35         }
 36         *op = 0;
 37         return (op - ascii);
 38 }
 39 
 40 int
 41 get_joliet_filename(struct iso_directory_record * de, unsigned char *outname, struct inode * inode)
 42 {
 43         unsigned char utf8;
 44         struct nls_table *nls;
 45         unsigned char len = 0;
 46 
 47         utf8 = ISOFS_SB(inode->i_sb)->s_utf8;
 48         nls = ISOFS_SB(inode->i_sb)->s_nls_iocharset;
 49 
 50         if (utf8) {
 51                 len = utf16s_to_utf8s((const wchar_t *) de->name,
 52                                 de->name_len[0] >> 1, UTF16_BIG_ENDIAN,
 53                                 outname, PAGE_SIZE);
 54         } else {
 55                 len = uni16_to_x8(outname, (__be16 *) de->name,
 56                                 de->name_len[0] >> 1, nls);
 57         }
 58         if ((len > 2) && (outname[len-2] == ';') && (outname[len-1] == '1'))
 59                 len -= 2;
 60 
 61         /*
 62          * Windows doesn't like periods at the end of a name,
 63          * so neither do we
 64          */
 65         while (len >= 2 && (outname[len-1] == '.'))
 66                 len--;
 67 
 68         return len;
 69 }
 70 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp