Changeset 85698 in vbox for trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c
- Timestamp:
- Aug 11, 2020 5:05:29 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c
r85432 r85698 46 46 #include "revision-generated.h" 47 47 #include "product-generated.h" 48 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0,0)48 #if RTLNX_VER_MIN(5,0,0) 49 49 # 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) 51 51 # include <linux/mount.h> 52 52 #endif 53 53 #include <linux/seq_file.h> 54 54 #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) 56 56 # include <linux/vermagic.h> 57 57 #endif … … 356 356 { 357 357 int rc = 0; 358 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,0)358 #if RTLNX_VER_MIN(2,6,0) 359 359 /* Each new shared folder map gets a new uint64_t identifier, 360 360 * 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) 362 362 static uint64_t s_u64Sequence = 0; 363 363 uint64_t idSeqMine = ASMAtomicIncU64(&s_u64Sequence); … … 365 365 struct backing_dev_info *bdi; 366 366 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) 368 368 pSuperInfo->bdi_org = sb->s_bdi; 369 369 # endif 370 370 371 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12,0)371 # if RTLNX_VER_MIN(4,12,0) 372 372 rc = super_setup_bdi_name(sb, "vboxsf-%llu", (unsigned long long)idSeqMine); 373 373 if (!rc) … … 381 381 bdi->ra_pages = 0; /* No readahead */ 382 382 383 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,12)383 # if RTLNX_VER_MIN(2,6,12) 384 384 bdi->capabilities = 0 385 385 # ifdef BDI_CAP_MAP_DIRECT … … 399 399 # endif 400 400 # 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. 402 402 * Only tested successfully with 4.19. Maybe skip altogether? */ 403 403 | BDI_CAP_STRICTLIMIT; … … 414 414 # endif /* >= 2.6.12 */ 415 415 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) 417 417 rc = bdi_init(&pSuperInfo->bdi); 418 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,26)418 # if RTLNX_VER_MIN(2,6,26) 419 419 if (!rc) 420 420 rc = bdi_register(&pSuperInfo->bdi, NULL, "vboxsf-%llu", (unsigned long long)idSeqMine); … … 422 422 # endif /* 4.11.0 > version >= 2.6.24 */ 423 423 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) 425 425 if (!rc) 426 426 sb->s_bdi = bdi; … … 437 437 static void vbsf_done_backing_dev(struct super_block *sb, struct vbsf_super_info *pSuperInfo) 438 438 { 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) 440 440 bdi_destroy(&pSuperInfo->bdi); /* includes bdi_unregister() */ 441 441 442 442 /* Paranoia: Make sb->s_bdi not point at pSuperInfo->bdi, in case someone 443 443 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) 445 445 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) 447 447 sb->s_bdi = &noop_backing_dev_info; 448 448 # endif … … 491 491 * Note! ls -la does display '.' and '..' entries with st_ino == 0, so root is #1. 492 492 */ 493 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,25)493 #if RTLNX_VER_MIN(2,4,25) 494 494 struct inode *iroot = iget_locked(sb, 1); 495 495 #else … … 500 500 VBSF_SET_INODE_INFO(iroot, sf_i); 501 501 502 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,25)502 #if RTLNX_VER_MIN(2,4,25) 503 503 unlock_new_inode(iroot); 504 504 #endif … … 507 507 * Now make it a root inode. 508 508 */ 509 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4,0)509 #if RTLNX_VER_MIN(3,4,0) 510 510 sb->s_root = d_make_root(iroot); 511 511 #else … … 518 518 519 519 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 */ 521 521 iput(iroot); 522 522 #endif … … 582 582 sb->s_magic = 0xface; 583 583 sb->s_blocksize = 1024; 584 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,3)584 #if RTLNX_VER_MIN(2,4,3) 585 585 /* Required for seek/sendfile (see 'loff_t max' in fs/read_write.c / do_sendfile()). */ 586 586 # if defined MAX_LFS_FILESIZE … … 592 592 # endif 593 593 #endif 594 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,11)594 #if RTLNX_VER_MIN(2,6,11) 595 595 sb->s_time_gran = 1; /* This might be a little optimistic for windows hosts, where it should be 100. */ 596 596 #endif 597 597 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) 599 599 sb->s_d_op = &vbsf_dentry_ops; 600 600 #endif … … 629 629 * We must free the inode info structure here. 630 630 */ 631 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,36)631 #if RTLNX_VER_MIN(2,6,36) 632 632 static void vbsf_evict_inode(struct inode *inode) 633 633 #else … … 642 642 * Flush stuff. 643 643 */ 644 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,36)644 #if RTLNX_VER_MIN(2,6,36) 645 645 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) 647 647 clear_inode(inode); 648 648 # else … … 673 673 hence we can't do anything here, and let lookup/whatever with the 674 674 job to properly fill then [inode] */ 675 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,25)675 #if RTLNX_VER_MAX(2,6,25) 676 676 static void vbsf_read_inode(struct inode *inode) 677 677 { … … 696 696 * Get file system statistics. 697 697 */ 698 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,18)698 #if RTLNX_VER_MIN(2,6,18) 699 699 static 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) 701 701 static int vbsf_statfs(struct super_block *sb, struct kstatfs *stat) 702 702 #else … … 704 704 #endif 705 705 { 706 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,18)706 #if RTLNX_VER_MIN(2,6,18) 707 707 struct super_block *sb = dentry->d_inode->i_sb; 708 708 #endif … … 716 716 stat->f_type = UINT32_C(0x786f4256); /* 'VBox' little endian */ 717 717 stat->f_bsize = pVolInfo->ulBytesPerAllocationUnit; 718 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,73)718 #if RTLNX_VER_MIN(2,5,73) 719 719 stat->f_frsize = pVolInfo->ulBytesPerAllocationUnit; 720 720 #endif … … 731 731 stat->f_fsid.val[1] = 0; 732 732 stat->f_namelen = 255; 733 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,36)733 #if RTLNX_VER_MIN(2,6,36) 734 734 stat->f_flags = 0; /* not valid */ 735 735 #endif … … 746 746 static int vbsf_remount_fs(struct super_block *sb, int *flags, char *data) 747 747 { 748 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,23)748 #if RTLNX_VER_MIN(2,4,23) 749 749 struct vbsf_super_info *pSuperInfo = pSuperInfo = VBSF_GET_SUPER_INFO(sb); 750 750 struct vbsf_inode_info *sf_i; … … 774 774 /*unlock_new_inode(iroot); */ 775 775 return 0; 776 #else /* LINUX_VERSION_CODE< 2.4.23 */776 #else /* < 2.4.23 */ 777 777 return -ENOSYS; 778 #endif /* LINUX_VERSION_CODE< 2.4.23 */778 #endif /* < 2.4.23 */ 779 779 } 780 780 … … 786 786 * the the 'szTag' option value it sets on its mount. 787 787 */ 788 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3,0)788 #if RTLNX_VER_MAX(3,3,0) 789 789 static int vbsf_show_options(struct seq_file *m, struct vfsmount *mnt) 790 790 #else … … 792 792 #endif 793 793 { 794 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3,0)794 #if RTLNX_VER_MAX(3,3,0) 795 795 struct super_block *sb = mnt->mnt_sb; 796 796 #else … … 845 845 */ 846 846 static 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) 848 848 .clear_inode = vbsf_clear_inode, 849 849 #else 850 850 .evict_inode = vbsf_evict_inode, 851 851 #endif 852 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,25)852 #if RTLNX_VER_MAX(2,6,25) 853 853 .read_inode = vbsf_read_inode, 854 854 #endif … … 865 865 *********************************************************************************************************************************/ 866 866 867 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,4)867 #if RTLNX_VER_MIN(2,5,4) 868 868 869 869 static int vbsf_read_super_26(struct super_block *sb, void *data, int flags) … … 879 879 } 880 880 881 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18) 881 # if RTLNX_VER_MIN(2,6,39) 882 static 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) 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 /* < 2.6.18 */ 882 894 static struct super_block *vbsf_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) 883 895 { … … 885 897 return get_sb_nodev(fs_type, flags, data, vbsf_read_super_26); 886 898 } 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 900 900 901 901 /** … … 905 905 .owner = THIS_MODULE, 906 906 .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 908 910 .get_sb = vbsf_get_sb, 909 # else910 .mount = sf_mount,911 911 # endif 912 912 .kill_sb = kill_anon_super 913 913 }; 914 914 915 #else /* LINUX_VERSION_CODE< 2.5.4 */915 #else /* < 2.5.4 */ 916 916 917 917 static struct super_block *vbsf_read_super_24(struct super_block *sb, void *data, int flags) … … 931 931 static DECLARE_FSTYPE(g_vboxsf_fs_type, "vboxsf", vbsf_read_super_24, 0); 932 932 933 #endif /* LINUX_VERSION_CODE< 2.5.4 */933 #endif /* < 2.5.4 */ 934 934 935 935 … … 1054 1054 * Module parameters. 1055 1055 */ 1056 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,52)1056 #if RTLNX_VER_MIN(2,5,52) 1057 1057 module_param_named(follow_symlinks, g_fFollowSymlinks, int, 0); 1058 1058 MODULE_PARM_DESC(follow_symlinks,
Note:
See TracChangeset
for help on using the changeset viewer.