VirtualBox

Ticket #16463: win_rename_unlink.patch

File win_rename_unlink.patch, 2.5 KB (added by mil0s, 8 years ago)

fix

  • src/VBox/Additions/linux/sharedfolders/dirops.c

    diff --git a/src/VBox/Additions/linux/sharedfolders/dirops.c b/src/VBox/Additions/linux/sharedfolders/dirops.c
    index 0267b0b..7b32718 100644
    a b static int sf_mkdir(struct inode *parent, struct dentry *dentry, int mode)  
    663663}
    664664
    665665/**
     666 * Set S_IWUSR on dentry
     667 *
     668 * @param dentry        directory cache entry
     669 */
     670static int sf_set_write(struct dentry *dentry)
     671{
     672        struct iattr iattr;
     673
     674        iattr.ia_mode = dentry->d_inode->i_mode | S_IWUSR;
     675        iattr.ia_valid = ATTR_MODE;
     676
     677        return sf_setattr(dentry, &iattr);
     678}
     679
     680/**
    666681 * Remove a regular file / directory.
    667682 *
    668683 * @param parent        inode of the directory
    static int sf_unlink_aux(struct inode *parent, struct dentry *dentry, int fDirec  
    677692    struct sf_inode_info *sf_i = GET_INODE_INFO(parent);
    678693    SHFLSTRING *path;
    679694    uint32_t fFlags;
     695    int retried = 0;
    680696
    681697    TRACE();
    682698    BUG_ON(!sf_g);
    static int sf_unlink_aux(struct inode *parent, struct dentry *dentry, int fDirec  
    690706        && dentry->d_inode
    691707        && ((dentry->d_inode->i_mode & S_IFLNK) == S_IFLNK))
    692708        fFlags |= SHFL_REMOVE_SYMLINK;
     709
     710retry:
    693711    rc = VbglR0SfRemove(&client_handle, &sf_g->map, path, fFlags);
    694712    if (RT_FAILURE(rc))
    695713    {
     714        if (  !retried++
     715            && RTErrConvertToErrno(rc) == EPERM
     716            && !sf_set_write(dentry))
     717            goto retry;
    696718        LogFunc(("(%d): VbglR0SfRemove(%s) failed rc=%Rrc\n", fDirectory, path->String.utf8, rc));
    697719        err = -RTErrConvertToErrno(rc);
    698720        goto fail1;
    static int sf_rename(struct inode *old_parent, struct dentry *old_dentry,  
    795817        else
    796818        {
    797819            int fDir = ((old_dentry->d_inode->i_mode & S_IFDIR) != 0);
     820            int retried = 0;
    798821
     822retry:
    799823            rc = VbglR0SfRename(&client_handle, &sf_g->map, old_path,
    800824                                new_path, fDir ? 0 : SHFL_RENAME_FILE | SHFL_RENAME_REPLACE_IF_EXISTS);
    801825            if (RT_SUCCESS(rc))
    static int sf_rename(struct inode *old_parent, struct dentry *old_dentry,  
    808832            }
    809833            else
    810834            {
     835                if (  !retried++
     836                    && RTErrConvertToErrno(rc) == EPERM
     837                    && !sf_set_write(new_dentry))
     838                    goto retry;
    811839                LogFunc(("VbglR0SfRename failed rc=%Rrc\n", rc));
    812840                err = -RTErrConvertToErrno(rc);
    813841                kfree(new_path);

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