VirtualBox

Changeset 57176 in vbox for trunk/src/VBox/Additions/linux


Ignore:
Timestamp:
Aug 4, 2015 3:20:30 PM (9 years ago)
Author:
vboxsync
Message:

Additions/linux/sharedfolders: properly reflect the directory file type to speed up certain file operations on Linux shared folders (thank you Tatuya Karino!)

File:
1 edited

Legend:

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

    r53757 r57176  
    112112
    113113/**
     114 * Translate RTFMODE into DT_xxx (in conjunction to rtDirType())
     115 * @param fMode     file mode
     116 * returns d_type
     117 */
     118static int sf_get_d_type(RTFMODE fMode)
     119{
     120    int d_type;
     121    switch (fMode & RTFS_TYPE_MASK)
     122    {
     123        case RTFS_TYPE_FIFO:      d_type = DT_FIFO;    break;
     124        case RTFS_TYPE_DEV_CHAR:  d_type = DT_CHR;     break;
     125        case RTFS_TYPE_DIRECTORY: d_type = DT_DIR;     break;
     126        case RTFS_TYPE_DEV_BLOCK: d_type = DT_BLK;     break;
     127        case RTFS_TYPE_FILE:      d_type = DT_REG;     break;
     128        case RTFS_TYPE_SYMLINK:   d_type = DT_LNK;     break;
     129        case RTFS_TYPE_SOCKET:    d_type = DT_SOCK;    break;
     130        case RTFS_TYPE_WHITEOUT:  d_type = DT_WHT;     break;
     131        default:                  d_type = DT_UNKNOWN; break;
     132    }
     133    return d_type;
     134}
     135
     136/**
    114137 * Extract element ([dir]->f_pos) from the directory [dir] into [d_name].
    115138 *
    116139 * @returns 0 for success, 1 for end reached, Linux error code otherwise.
    117140 */
    118 static int sf_getdent(struct file *dir, char d_name[NAME_MAX])
     141static int sf_getdent(struct file *dir, char d_name[NAME_MAX], int *d_type)
    119142{
    120143    loff_t cur;
     
    202225        }
    203226
     227        *d_type = sf_get_d_type(info->Info.Attr.fMode);
     228
    204229        return sf_nlscpy(sf_g, d_name, NAME_MAX,
    205230                         info->name.String.utf8, info->name.u16Length);
     
    245270        loff_t sanity;
    246271        char d_name[NAME_MAX];
    247 
    248         err = sf_getdent(dir, d_name);
     272        int d_type = DT_UNKNOWN;
     273
     274        err = sf_getdent(dir, d_name, &d_type);
    249275        switch (err)
    250276        {
     
    281307
    282308#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
    283         if (!dir_emit(ctx, d_name, strlen(d_name), fake_ino, DT_UNKNOWN))
     309        if (!dir_emit(ctx, d_name, strlen(d_name), fake_ino, d_type))
    284310        {
    285311            LogFunc(("dir_emit failed\n"));
     
    287313        }
    288314#else
    289         err = filldir(opaque, d_name, strlen(d_name), dir->f_pos, fake_ino, DT_UNKNOWN);
     315        err = filldir(opaque, d_name, strlen(d_name), dir->f_pos, fake_ino, d_type);
    290316        if (err)
    291317        {
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