diff -Nur vmhgfs-only.orig/compat_fs.h vmhgfs-only/compat_fs.h --- vmhgfs-only.orig/compat_fs.h 2008-03-04 02:45:55.000000000 +0100 +++ vmhgfs-only/compat_fs.h 2008-05-27 21:07:33.000000000 +0200 @@ -84,6 +84,14 @@ # define VMW_EMBED_INODE #endif +/* + * iget() was removed from the VFS as of 2.6.25-rc1. The replacement for iget() + * is iget_locked() which was added in 2.5.17. + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 17) +# define VMW_USE_IGET_LOCKED +#endif + /* * parent_ino was born in 2.5.5. For older kernels, let's use 2.5.5 diff -Nur vmhgfs-only.orig/driver-config.h vmhgfs-only/driver-config.h --- vmhgfs-only.orig/driver-config.h 2008-03-04 02:45:55.000000000 +0100 +++ vmhgfs-only/driver-config.h 2008-05-27 21:09:05.000000000 +0200 @@ -21,6 +21,23 @@ #include #include "compat_version.h" +/* + * I still haven't figured out why the automagic checks in Makefile.kernel + * don't work. They call the script vm_check_build which isn't available + * on any of my systems so `make` is unable to find out whether this features + * need to be included or not. + * + * A simple workaround is to rely on the kernel configuration as shown below. + * If CONFIG_EPOLL is set, we have EPOLL set, basta. + * + * by Alexander Griesser , 2008-03-14 + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) +#ifdef CONFIG_EPOLL +#define VMW_HAVE_EPOLL 1 +#endif +#endif + /* We rely on Kernel Module support. Check here. */ #ifndef CONFIG_MODULES #error "No Module support in this kernel. Please configure with CONFIG_MODULES" @@ -50,6 +67,18 @@ #define _STDINT_H 1 #endif +/* + * Force the uintptr_t definition to come from linux/types.h instead of + * vm_basic_types.h + * + * Backported from open-vm-tools + * by Alexander Griesser , 2008-04-27 + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) +# include +# define _STDINT_H 1 +#endif + #ifndef __KERNEL__ #define __KERNEL__ #endif diff -Nur vmhgfs-only.orig/fsutil.c vmhgfs-only/fsutil.c --- vmhgfs-only.orig/fsutil.c 2008-03-04 02:45:54.000000000 +0100 +++ vmhgfs-only/fsutil.c 2008-05-27 21:15:00.000000000 +0200 @@ -87,7 +87,7 @@ * inode got marked bad inside read_inode, also indicative of a new inode * allocation. */ - inode = iget(sb, ino); + inode = HgfsGetInode(sb, ino); if (inode == NULL) { LOG(4, (KERN_DEBUG "VMware hgfs: HgfsInodeLookup: iget ran out of " "memory and returned NULL\n")); @@ -1000,7 +1000,7 @@ /* Now we have a good inode number, get the inode itself. */ - inode = iget(sb, ino); + inode = HgfsGetInode(sb, ino); if (inode) { /* @@ -1595,3 +1595,97 @@ return -EIO; } } + +/* + *---------------------------------------------------------------------------- + * + * HgfsGetInode -- + * + * This function replaces iget() and should be called instead of it. In newer + * kernels that have removed the iget() interface, GetInode() obtains an inode + * and if it is a new one, then initializes the inode by calling + * HgfsDoReadInode(). In older kernels that support the iget() interface, + * HgfsDoReadInode() is called by iget() internally. + * + * Results: + * A new inode object on success, NULL on error. + * + * Side effects: + * None. + * + * Backported from open-vm-tools + * by Alexander Griesser , 2008-05-14 + *---------------------------------------------------------------------------- + */ + +struct inode * +HgfsGetInode(struct super_block *sb, // IN: file system superblock object + ino_t ino) // IN: inode number to assign to new inode +{ +#ifdef VMW_USE_IGET_LOCKED + struct inode *inode; + + inode = iget_locked(sb, ino); + if (inode && (inode->i_state & I_NEW)) { + HgfsDoReadInode(inode); + unlock_new_inode(inode); + } + return inode; +#else + return iget(sb, ino); +#endif +} + +/* + *---------------------------------------------------------------------------- + * + * HgfsDoReadInode -- + * + * A filesystem wide function that is called to initialize a new inode. + * This is called from two different places depending on the kernel version. + * In older kernels that provide the iget() interface, this function is + * called by the kernel as part of inode initialization (from + * HgfsDoReadInode). In newer kernels that call iget_locked(), this + * function is called by filesystem code to initialize the new inode. + * + * Results: + * None. + * + * Side effects: + * None. + * + * Backported from open-vm-tools + * by Alexander Griesser , 2008-05-14 + *---------------------------------------------------------------------------- + */ +void +HgfsDoReadInode(struct inode *inode) // IN: Inode to initialize +{ + HgfsInodeInfo *iinfo = INODE_GET_II_P(inode); + + /* + * If the vfs inode is not embedded within the HgfsInodeInfo, then we + * haven't yet allocated the HgfsInodeInfo. Do so now. + * + * XXX: We could allocate with GFP_ATOMIC. But instead, we'll do a standard + * allocation and mark the inode "bad" if the allocation fails. This'll + * make all subsequent operations on the inode fail, which is what we want. + */ +#ifndef VMW_EMBED_INODE + iinfo = kmem_cache_alloc(hgfsInodeCache, GFP_KERNEL); + if (!iinfo) { + LOG(4, (KERN_DEBUG "VMware hgfs: HgfsDoReadInode: no memory for " + "iinfo!\n")); + make_bad_inode(inode); + return; + } +#endif + INODE_SET_II_P(inode, iinfo); + INIT_LIST_HEAD(&iinfo->files); + iinfo->isReferencedInode = FALSE; + iinfo->isFakeInodeNumber = FALSE; + iinfo->createdAndUnopened = FALSE; + +} + + diff -Nur vmhgfs-only.orig/fsutil.h vmhgfs-only/fsutil.h --- vmhgfs-only.orig/fsutil.h 2008-03-04 02:45:54.000000000 +0100 +++ vmhgfs-only/fsutil.h 2008-05-27 21:21:17.000000000 +0200 @@ -79,5 +79,7 @@ HgfsOpenMode mode, HgfsHandle *handle); int HgfsStatusConvertToLinux(HgfsStatus hgfsStatus); +struct inode *HgfsGetInode(struct super_block *sb, ino_t ino); +void HgfsDoReadInode(struct inode *inode); #endif // _HGFS_DRIVER_FSUTIL_H_ diff -Nur vmhgfs-only.orig/super.c vmhgfs-only/super.c --- vmhgfs-only.orig/super.c 2008-03-04 02:45:55.000000000 +0100 +++ vmhgfs-only/super.c 2008-05-27 21:22:50.000000000 +0200 @@ -36,7 +36,9 @@ static struct inode *HgfsAllocInode(struct super_block *sb); static void HgfsDestroyInode(struct inode *inode); #endif +#ifndef VMW_USE_IGET_LOCKED static void HgfsReadInode(struct inode *inode); +#endif static void HgfsClearInode(struct inode *inode); static void HgfsPutSuper(struct super_block *sb); #if defined(VMW_STATFS_2618) @@ -52,7 +54,9 @@ .alloc_inode = HgfsAllocInode, .destroy_inode = HgfsDestroyInode, #endif +#ifndef VMW_USE_IGET_LOCKED .read_inode = HgfsReadInode, +#endif .clear_inode = HgfsClearInode, .put_super = HgfsPutSuper, .statfs = HgfsStatfs, @@ -120,6 +124,9 @@ } #endif + + +#ifndef VMW_USE_IGET_LOCKED /* *----------------------------------------------------------------------------- * @@ -140,31 +147,9 @@ static void HgfsReadInode(struct inode *inode) // IN/OUT: VFS inode to fill in { - HgfsInodeInfo *iinfo = INODE_GET_II_P(inode); - - /* - * If the vfs inode is not embedded within the HgfsInodeInfo, then we - * haven't yet allocated the HgfsInodeInfo. Do so now. - * - * XXX: We could allocate with GFP_ATOMIC. But instead, we'll do a standard - * allocation and mark the inode "bad" if the allocation fails. This'll - * make all subsequent operations on the inode fail, which is what we want. - */ -#ifndef VMW_EMBED_INODE - iinfo = kmem_cache_alloc(hgfsInodeCache, GFP_KERNEL); - if (!iinfo) { - LOG(4, (KERN_DEBUG "VMware hgfs: HgfsReadInode: no memory for " - "iinfo!\n")); - make_bad_inode(inode); - return; - } -#endif - INODE_SET_II_P(inode, iinfo); - INIT_LIST_HEAD(&iinfo->files); - iinfo->isReferencedInode = FALSE; - iinfo->isFakeInodeNumber = FALSE; - iinfo->createdAndUnopened = FALSE; + HgfsDoReadInode(inode); } +#endif /* diff -Nur vmhgfs-only.orig/vm_basic_types.h vmhgfs-only/vm_basic_types.h --- vmhgfs-only.orig/vm_basic_types.h 2008-03-04 02:45:54.000000000 +0100 +++ vmhgfs-only/vm_basic_types.h 2008-05-27 21:23:12.000000000 +0200 @@ -24,6 +24,7 @@ #define INCLUDE_ALLOW_VMCORE #define INCLUDE_ALLOW_VMIROM #include "includeCheck.h" +#include "driver-config.h" /* STRICT ANSI means the Xserver build and X defines Bool differently. */ #if !defined(__STRICT_ANSI__) || defined(__FreeBSD__)