VirtualBox

Changeset 77741 in vbox


Ignore:
Timestamp:
Mar 17, 2019 3:42:04 AM (6 years ago)
Author:
vboxsync
Message:

linux/vboxsf: Fixed nls conversion issue (don't try convert the zero terminator, at least not on 2.6.8). Hacked around missing invalidate_mapping_pages symbol in kernels before 2.6.21.

Location:
trunk/src/VBox/Additions/linux/sharedfolders
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/sharedfolders/dirops.c

    r77708 r77741  
    288288{
    289289    char szDstName[NAME_MAX];
    290     int rc = vbsf_nlscpy(sf_g, szDstName, sizeof(szDstName), pszSrcName, cchSrcName + 1);
     290    int rc = vbsf_nlscpy(sf_g, szDstName, sizeof(szDstName), pszSrcName, cchSrcName);
    291291    if (rc == 0) {
    292292#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
  • trunk/src/VBox/Additions/linux/sharedfolders/regops.c

    r77735 r77741  
    545545# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
    546546    ssize_t cPagesLocked = get_user_pages_unlocked(uPtrFrom, cPages, papPages,
    547                                fWrite ? FOLL_WRITE | FOLL_FORCE : FOLL_FORCE);
     547                                                   fWrite ? FOLL_WRITE | FOLL_FORCE : FOLL_FORCE);
    548548# elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
    549549    ssize_t cPagesLocked = get_user_pages_unlocked(uPtrFrom, cPages, fWrite, 1 /*force*/, papPages);
     
    844844    if (mapping)
    845845        invalidate_inode_pages2_range(mapping, offStart >> PAGE_SHIFT, (offEnd - 1) >> PAGE_SHIFT);
    846 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 60)
     846# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 21)
     847    if (mapping && mapping->nrpages > 0)
     848        invalidate_mapping_pages(mapping, offStart >> PAGE_SHIFT, (offEnd - 1) >> PAGE_SHIFT);
     849# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 60) && 0 /** @todo invalidate_mapping_pages was added in 2.5.60, but exported in 2.6.21 */
    847850    if (mapping && mapping->nrpages > 0)
    848851        invalidate_mapping_pages(mapping, offStart >> PAGE_SHIFT, (offEnd - 1) >> PAGE_SHIFT);
     
    26922695/**
    26932696 * Address space (for the page cache) operations for regular files.
     2697 *
     2698 * @todo the FsPerf touch/flush (mmap) test fails on 4.4.0 (ubuntu 16.04 lts).
    26942699 */
    26952700struct address_space_operations vbsf_reg_aops = {
  • trunk/src/VBox/Additions/linux/sharedfolders/utils.c

    r77629 r77741  
    3939int vbsf_nlscpy(struct vbsf_super_info *sf_g, char *name, size_t name_bound_len, const unsigned char *utf8_name, size_t utf8_len)
    4040{
     41    Assert(RTStrNLen(utf8_name, utf8_len) == utf8_len);
     42
    4143    if (sf_g->nls) {
    42         const char *in;
    43         char *out;
    44         size_t out_len;
    45         size_t out_bound_len;
    46         size_t in_bound_len;
    47 
    48         in = utf8_name;
    49         in_bound_len = utf8_len;
    50 
    51         out = name;
    52         out_len = 0;
    53         out_bound_len = name_bound_len;
     44        const char *in              = utf8_name;
     45        size_t      in_bound_len    = utf8_len;
     46        char       *out             = name;
     47        size_t      out_bound_len   = name_bound_len;
     48        size_t      out_len         = 0;
    5449
    5550        while (in_bound_len) {
    56             int nb;
    5751#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
    5852            unicode_t uni;
    59 
    60             nb = utf8_to_utf32(in, in_bound_len, &uni);
     53            int cbInEnc = utf8_to_utf32(in, in_bound_len, &uni);
    6154#else
    6255            linux_wchar_t uni;
    63 
    64             nb = utf8_mbtowc(&uni, in, in_bound_len);
    65 #endif
    66             if (nb < 0) {
    67                 LogFunc(("utf8_mbtowc failed(%s) %x:%d\n", (const char *)utf8_name, *in, in_bound_len));
     56            int cbInEnc = utf8_mbtowc(&uni, in, in_bound_len);
     57#endif
     58            if (cbInEnc >= 0) {
     59                int cbOutEnc = sf_g->nls->uni2char(uni, out, out_bound_len);
     60                if (cbOutEnc >= 0) {
     61                    /*SFLOG3(("vbsf_nlscpy: cbOutEnc=%d cbInEnc=%d uni=%#x in_bound_len=%u\n", cbOutEnc, cbInEnc, uni, in_bound_len));*/
     62                    out           += cbOutEnc;
     63                    out_bound_len -= cbOutEnc;
     64                    out_len       += cbOutEnc;
     65
     66                    in            += cbInEnc;
     67                    in_bound_len  -= cbInEnc;
     68                } else {
     69                    SFLOG(("vbsf_nlscpy: nls->uni2char failed with %d on %#x (pos %u in '%s'), out_bound_len=%u\n",
     70                           cbOutEnc, uni, in - (const char *)utf8_name, (const char *)utf8_name, (unsigned)out_bound_len));
     71                    return cbOutEnc;
     72                }
     73            } else {
     74                SFLOG(("vbsf_nlscpy: utf8_to_utf32/utf8_mbtowc failed with %d on %x (pos %u in '%s'), in_bound_len=%u!\n",
     75                       cbInEnc, *in, in - (const char *)utf8_name, (const char *)utf8_name, (unsigned)in_bound_len));
    6876                return -EINVAL;
    6977            }
    70             in += nb;
    71             in_bound_len -= nb;
    72 
    73             nb = sf_g->nls->uni2char(uni, out, out_bound_len);
    74             if (nb < 0) {
    75                 LogFunc(("nls->uni2char failed(%s) %x:%d\n", utf8_name, uni, out_bound_len));
    76                 return nb;
    77             }
    78             out += nb;
    79             out_bound_len -= nb;
    80             out_len += nb;
    8178        }
    8279
    83         *out = 0;
     80        *out = '\0';
    8481    } else {
    8582        if (utf8_len + 1 > name_bound_len)
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c

    r77739 r77741  
    193193                sf_g->fNlsIsUtf8 = false;
    194194                sf_g->nls = load_nls(info->nls_name);
    195                 if (!sf_g->nls) {
     195                if (sf_g->nls) {
     196                    SFLOGFLOW(("vbsf_super_info_alloc_and_map_it: nls=%s -> %p\n", info->nls_name, sf_g->nls));
     197                } else {
    196198                    SFLOGRELBOTH(("vboxsf: Failed to load nls '%s'!\n", info->nls_name));
    197199                    rc = -EINVAL;
     
    206208                sf_g->fNlsIsUtf8 = false;
    207209                sf_g->nls = load_nls_default();
     210                SFLOGFLOW(("vbsf_super_info_alloc_and_map_it: CONFIG_NLS_DEFAULT=%s -> %p\n", CONFIG_NLS_DEFAULT, sf_g->nls));
    208211            } else
    209212                sf_g->nls = NULL;
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h

    r77739 r77741  
    5959 * Logging wrappers.
    6060 */
    61 #if 1
     61#if 0
    6262# define TRACE()                LogFunc(("tracepoint\n"))
    63 # define SFLOGFLOW(aArgs)       Log(aArgs)
     63# define SFLOG(aArgs)           Log(aArgs)
     64# define SFLOGFLOW(aArgs)       LogFlow(aArgs)
    6465# define SFLOG2(aArgs)          Log2(aArgs)
    6566# define SFLOG3(aArgs)          Log3(aArgs)
     
    7071#else
    7172# define TRACE()                RTLogBackdoorPrintf("%s: tracepoint\n", __FUNCTION__)
     73# define SFLOG(aArgs)           RTLogBackdoorPrintf aArgs
    7274# define SFLOGFLOW(aArgs)       RTLogBackdoorPrintf aArgs
    7375# define SFLOG2(aArgs)          RTLogBackdoorPrintf aArgs
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette