VirtualBox

Ignore:
Timestamp:
Mar 14, 2019 8:10:40 PM (6 years ago)
Author:
vboxsync
Message:

linux/vboxsf: Various build fixes for older kernels (atomic_open, read_iter, write_iter). bugref:9172

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

Legend:

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

    r77704 r77706  
    3535#include "vfsmod.h"
    3636#include <iprt/err.h>
     37
     38#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
     39# define d_in_lookup(a_pDirEntry)  (d_unhashed(a_pDirEntry))
     40#endif
     41
    3742
    3843
     
    903908 * of that approach.  The call combines the lookup and open.
    904909 */
    905 static int vbsf_inode_atomic_open(struct inode *pDirInode, struct dentry *dentry, struct file *file,  unsigned fOpen, umode_t fMode)
     910static int vbsf_inode_atomic_open(struct inode *pDirInode, struct dentry *dentry, struct file *file,  unsigned fOpen,
     911                                  umode_t fMode
     912# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0)
     913                                  , int *opened
     914# endif
     915                                  )
    906916{
    907917    SFLOGFLOW(("vbsf_inode_atomic_open: pDirInode=%p dentry=%p file=%p fOpen=%#x, fMode=%#x\n", pDirInode, dentry, file, fOpen, fMode));
     
    952962                 * and call finish_open() to do the remaining open() work.
    953963                 */
     964# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
    954965                if (fCreated)
    955966                    file->f_mode |= FMODE_CREATED;
    956967                rc = finish_open(file, dentry, generic_file_open);
     968# else
     969                if (fCreated)
     970                    *opened |= FILE_CREATED;
     971                rc = finish_open(file, dentry, generic_file_open, opened);
     972# endif
    957973                if (rc == 0) {
    958974                    /*
     
    10131029#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
    10141030static int vbsf_inode_create(struct inode *parent, struct dentry *dentry, umode_t mode, struct nameidata *nd)
    1015 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     1031#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 75)
    10161032static int vbsf_inode_create(struct inode *parent, struct dentry *dentry, int mode, struct nameidata *nd)
    10171033#else
     
    10191035#endif
    10201036{
    1021 /** @todo @a nd (struct nameidata) contains intent with partial open flags for
    1022  *        2.6.0-3.5.999.  In 3.6.0 atomic_open was introduced and stuff
    1023  *        changed (investigate)... */
     1037    uint32_t fCreateFlags = SHFL_CF_ACT_CREATE_IF_NEW
     1038                          | SHFL_CF_ACT_FAIL_IF_EXISTS
     1039                          | SHFL_CF_ACCESS_READWRITE;
     1040#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 75)
     1041    /* Clear the RD flag if write-only access requested.  Otherwise assume we
     1042       need write access to create stuff. */
     1043    if (!(nd->intent.open.flags & 1) ) {
     1044        fCreateFlags &= SHFL_CF_ACCESS_READWRITE;
     1045        fCreateFlags |= SHFL_CF_ACCESS_WRITE;
     1046    }
     1047    /* (file since 2.6.15) */
     1048#endif
    10241049    TRACE();
    10251050    AssertMsg(!(mode & S_IFMT) || (mode & S_IFMT) == S_IFREG, ("0%o\n", mode));
    1026     return vbsf_create_worker(parent, dentry, (mode & ~S_IFMT) | S_IFREG,
    1027                                 SHFL_CF_ACT_CREATE_IF_NEW
    1028                               | SHFL_CF_ACT_FAIL_IF_EXISTS
    1029                               | SHFL_CF_ACCESS_READWRITE,
     1051    return vbsf_create_worker(parent, dentry, (mode & ~S_IFMT) | S_IFREG, fCreateFlags,
    10301052                              true /*fStashHandle*/, false /*fDoLookup*/, NULL /*phHandle*/, NULL /*fCreated*/);
    10311053}
  • trunk/src/VBox/Additions/linux/sharedfolders/regops.c

    r77704 r77706  
    5353#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
    5454# define SEEK_END 2
     55#endif
     56
     57#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
     58# define iter_is_iovec(a_pIter) ( !((a_pIter)->type & (ITER_KVEC | ITER_BVEC)) )
    5559#endif
    5660
     
    17951799    /** @todo This should be handled by the host, it returning the new file
    17961800     *        offset when appending.  We may have an outdated i_size value here! */
     1801#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
    17971802    if (kio->ki_flags & IOCB_APPEND)
     1803#else
     1804    if (kio->ki_filp->f_flags & O_APPEND)
     1805#endif
    17981806        kio->ki_pos = offFile = i_size_read(inode);
    17991807
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