VirtualBox

Ignore:
Timestamp:
Aug 11, 2020 5:05:29 PM (4 years ago)
Author:
vboxsync
Message:

IPRT,lnx-kmods: Use new linux kernel version checking macros. Moved them to separate wrapper header.

File:
1 edited

Legend:

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

    r85432 r85698  
    4646#include "revision-generated.h"
    4747#include "product-generated.h"
    48 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
     48#if RTLNX_VER_MIN(5,0,0)
    4949# include <uapi/linux/mount.h> /* for MS_REMOUNT */
    50 #elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
     50#elif RTLNX_VER_MAX(3,3,0)
    5151# include <linux/mount.h>
    5252#endif
    5353#include <linux/seq_file.h>
    5454#include <linux/vfs.h>
    55 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 62) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
     55#if RTLNX_VER_RANGE(2,5,62,  5,8,0)
    5656# include <linux/vermagic.h>
    5757#endif
     
    356356{
    357357    int rc = 0;
    358 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     358#if RTLNX_VER_MIN(2,6,0)
    359359    /* Each new shared folder map gets a new uint64_t identifier,
    360360     * allocated in sequence.  We ASSUME the sequence will not wrap. */
    361 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
     361# if RTLNX_VER_MIN(2,6,26)
    362362    static uint64_t s_u64Sequence = 0;
    363363    uint64_t idSeqMine = ASMAtomicIncU64(&s_u64Sequence);
     
    365365    struct backing_dev_info *bdi;
    366366
    367 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
     367# if RTLNX_VER_RANGE(4,0,0,  4,2,0)
    368368    pSuperInfo->bdi_org = sb->s_bdi;
    369369# endif
    370370
    371 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
     371# if RTLNX_VER_MIN(4,12,0)
    372372    rc = super_setup_bdi_name(sb, "vboxsf-%llu", (unsigned long long)idSeqMine);
    373373    if (!rc)
     
    381381    bdi->ra_pages = 0;                      /* No readahead */
    382382
    383 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 12)
     383# if RTLNX_VER_MIN(2,6,12)
    384384    bdi->capabilities = 0
    385385#  ifdef BDI_CAP_MAP_DIRECT
     
    399399#  endif
    400400#  ifdef BDI_CAP_STRICTLIMIT
    401 #   if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) /* Trouble with 3.16.x/debian8.  Process stops after dirty page throttling.
     401#   if RTLNX_VER_MIN(4,19,0) /* Trouble with 3.16.x/debian8.  Process stops after dirty page throttling.
    402402                                                       * Only tested successfully with 4.19.  Maybe skip altogether? */
    403403                      | BDI_CAP_STRICTLIMIT;
     
    414414# endif /* >= 2.6.12 */
    415415
    416 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
     416# if RTLNX_VER_RANGE(2,6,24,  4,12,0)
    417417    rc = bdi_init(&pSuperInfo->bdi);
    418 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
     418#  if RTLNX_VER_MIN(2,6,26)
    419419    if (!rc)
    420420        rc = bdi_register(&pSuperInfo->bdi, NULL, "vboxsf-%llu", (unsigned long long)idSeqMine);
     
    422422# endif  /* 4.11.0 > version >= 2.6.24 */
    423423
    424 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
     424# if RTLNX_VER_RANGE(2,6,34,  4,12,0)
    425425    if (!rc)
    426426        sb->s_bdi = bdi;
     
    437437static void vbsf_done_backing_dev(struct super_block *sb, struct vbsf_super_info *pSuperInfo)
    438438{
    439 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) && LINUX_VERSION_CODE <= KERNEL_VERSION(4, 12, 0)
     439#if RTLNX_VER_RANGE(2,6,24,  4,13,0)
    440440    bdi_destroy(&pSuperInfo->bdi);    /* includes bdi_unregister() */
    441441
    442442    /* Paranoia: Make sb->s_bdi not point at pSuperInfo->bdi, in case someone
    443443                 trouches it after this point (we may screw up something).  */
    444 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
     444# if RTLNX_VER_RANGE(4,0,0,  4,2,0)
    445445    sb->s_bdi = pSuperInfo->bdi_org; /* (noop_backing_dev_info is not exported) */
    446 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
     446# elif RTLNX_VER_RANGE(2,6,34,  4,10,0)
    447447    sb->s_bdi = &noop_backing_dev_info;
    448448# endif
     
    491491             * Note! ls -la does display '.' and '..' entries with st_ino == 0, so root is #1.
    492492             */
    493 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)
     493#if RTLNX_VER_MIN(2,4,25)
    494494            struct inode *iroot = iget_locked(sb, 1);
    495495#else
     
    500500                VBSF_SET_INODE_INFO(iroot, sf_i);
    501501
    502 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)
     502#if RTLNX_VER_MIN(2,4,25)
    503503                unlock_new_inode(iroot);
    504504#endif
     
    507507                 * Now make it a root inode.
    508508                 */
    509 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
     509#if RTLNX_VER_MIN(3,4,0)
    510510                sb->s_root = d_make_root(iroot);
    511511#else
     
    518518
    519519                SFLOGRELBOTH(("vboxsf: d_make_root failed!\n"));
    520 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) /* d_make_root calls iput */
     520#if RTLNX_VER_MAX(3,4,0) /* d_make_root calls iput */
    521521                iput(iroot);
    522522#endif
     
    582582        sb->s_magic     = 0xface;
    583583        sb->s_blocksize = 1024;
    584 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 3)
     584#if RTLNX_VER_MIN(2,4,3)
    585585        /* Required for seek/sendfile (see 'loff_t max' in fs/read_write.c / do_sendfile()). */
    586586# if defined MAX_LFS_FILESIZE
     
    592592# endif
    593593#endif
    594 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
     594#if RTLNX_VER_MIN(2,6,11)
    595595        sb->s_time_gran = 1; /* This might be a little optimistic for windows hosts, where it should be 100. */
    596596#endif
    597597        sb->s_op        = &g_vbsf_super_ops;
    598 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
     598#if RTLNX_VER_MIN(2,6,38)
    599599        sb->s_d_op      = &vbsf_dentry_ops;
    600600#endif
     
    629629 * We must free the inode info structure here.
    630630 */
    631 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
     631#if RTLNX_VER_MIN(2,6,36)
    632632static void vbsf_evict_inode(struct inode *inode)
    633633#else
     
    642642     * Flush stuff.
    643643     */
    644 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
     644#if RTLNX_VER_MIN(2,6,36)
    645645    truncate_inode_pages(&inode->i_data, 0);
    646 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     646# if RTLNX_VER_MIN(3,5,0)
    647647    clear_inode(inode);
    648648# else
     
    673673   hence we can't do anything here, and let lookup/whatever with the
    674674   job to properly fill then [inode] */
    675 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
     675#if RTLNX_VER_MAX(2,6,25)
    676676static void vbsf_read_inode(struct inode *inode)
    677677{
     
    696696 * Get file system statistics.
    697697 */
    698 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
     698#if RTLNX_VER_MIN(2,6,18)
    699699static int vbsf_statfs(struct dentry *dentry, struct kstatfs *stat)
    700 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 73)
     700#elif RTLNX_VER_MIN(2,5,73)
    701701static int vbsf_statfs(struct super_block *sb, struct kstatfs *stat)
    702702#else
     
    704704#endif
    705705{
    706 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
     706#if RTLNX_VER_MIN(2,6,18)
    707707    struct super_block *sb = dentry->d_inode->i_sb;
    708708#endif
     
    716716            stat->f_type   = UINT32_C(0x786f4256); /* 'VBox' little endian */
    717717            stat->f_bsize  = pVolInfo->ulBytesPerAllocationUnit;
    718 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 73)
     718#if RTLNX_VER_MIN(2,5,73)
    719719            stat->f_frsize = pVolInfo->ulBytesPerAllocationUnit;
    720720#endif
     
    731731            stat->f_fsid.val[1] = 0;
    732732            stat->f_namelen = 255;
    733 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
     733#if RTLNX_VER_MIN(2,6,36)
    734734            stat->f_flags = 0; /* not valid */
    735735#endif
     
    746746static int vbsf_remount_fs(struct super_block *sb, int *flags, char *data)
    747747{
    748 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 23)
     748#if RTLNX_VER_MIN(2,4,23)
    749749    struct vbsf_super_info *pSuperInfo = pSuperInfo = VBSF_GET_SUPER_INFO(sb);
    750750    struct vbsf_inode_info *sf_i;
     
    774774    /*unlock_new_inode(iroot); */
    775775    return 0;
    776 #else  /* LINUX_VERSION_CODE < 2.4.23 */
     776#else  /* < 2.4.23 */
    777777    return -ENOSYS;
    778 #endif /* LINUX_VERSION_CODE < 2.4.23 */
     778#endif /* < 2.4.23 */
    779779}
    780780
     
    786786 * the the 'szTag' option value it sets on its mount.
    787787 */
    788 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
     788#if RTLNX_VER_MAX(3,3,0)
    789789static int vbsf_show_options(struct seq_file *m, struct vfsmount *mnt)
    790790#else
     
    792792#endif
    793793{
    794 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
     794#if RTLNX_VER_MAX(3,3,0)
    795795    struct super_block     *sb         = mnt->mnt_sb;
    796796#else
     
    845845 */
    846846static struct super_operations g_vbsf_super_ops = {
    847 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
     847#if RTLNX_VER_MAX(2,6,36)
    848848    .clear_inode  = vbsf_clear_inode,
    849849#else
    850850    .evict_inode  = vbsf_evict_inode,
    851851#endif
    852 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
     852#if RTLNX_VER_MAX(2,6,25)
    853853    .read_inode   = vbsf_read_inode,
    854854#endif
     
    865865*********************************************************************************************************************************/
    866866
    867 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 4)
     867#if RTLNX_VER_MIN(2,5,4)
    868868
    869869static int vbsf_read_super_26(struct super_block *sb, void *data, int flags)
     
    879879}
    880880
    881 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
     881# if RTLNX_VER_MIN(2,6,39)
     882static struct dentry *sf_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data)
     883{
     884    TRACE();
     885    return mount_nodev(fs_type, flags, data, vbsf_read_super_26);
     886}
     887# elif RTLNX_VER_MIN(2,6,18)
     888static int vbsf_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct vfsmount *mnt)
     889{
     890    TRACE();
     891    return get_sb_nodev(fs_type, flags, data, vbsf_read_super_26, mnt);
     892}
     893# else /* < 2.6.18 */
    882894static struct super_block *vbsf_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data)
    883895{
     
    885897    return get_sb_nodev(fs_type, flags, data, vbsf_read_super_26);
    886898}
    887 # elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
    888 static int vbsf_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct vfsmount *mnt)
    889 {
    890     TRACE();
    891     return get_sb_nodev(fs_type, flags, data, vbsf_read_super_26, mnt);
    892 }
    893 # else /* LINUX_VERSION_CODE >= 2.6.39 */
    894 static struct dentry *sf_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data)
    895 {
    896     TRACE();
    897     return mount_nodev(fs_type, flags, data, vbsf_read_super_26);
    898 }
    899 # endif /* LINUX_VERSION_CODE >= 2.6.39 */
     899# endif
    900900
    901901/**
     
    905905    .owner = THIS_MODULE,
    906906    .name = "vboxsf",
    907 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
     907# if RTLNX_VER_MIN(2,6,39)
     908    .mount = sf_mount,
     909# else
    908910    .get_sb = vbsf_get_sb,
    909 # else
    910     .mount = sf_mount,
    911911# endif
    912912    .kill_sb = kill_anon_super
    913913};
    914914
    915 #else  /* LINUX_VERSION_CODE < 2.5.4 */
     915#else  /* < 2.5.4 */
    916916
    917917static struct super_block *vbsf_read_super_24(struct super_block *sb, void *data, int flags)
     
    931931static DECLARE_FSTYPE(g_vboxsf_fs_type, "vboxsf", vbsf_read_super_24, 0);
    932932
    933 #endif /* LINUX_VERSION_CODE < 2.5.4 */
     933#endif /* < 2.5.4 */
    934934
    935935
     
    10541054 * Module parameters.
    10551055 */
    1056 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 52)
     1056#if RTLNX_VER_MIN(2,5,52)
    10571057module_param_named(follow_symlinks, g_fFollowSymlinks, int, 0);
    10581058MODULE_PARM_DESC(follow_symlinks,
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