From: VMware, Inc <> Date: Thu, 17 Jun 2010 21:36:57 +0000 (-0700) Subject: Changes in shared code that don't affect open-vm-tools functionality. X-Git-Tag: 2010.06.16-268169~98 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a24fcd032abbb3952923884117a9c01050a3d3e;p=thirdparty%2Fopen-vm-tools.git Changes in shared code that don't affect open-vm-tools functionality. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/file/filePosix.c b/open-vm-tools/lib/file/filePosix.c index 3615e418b..46fd8a17b 100644 --- a/open-vm-tools/lib/file/filePosix.c +++ b/open-vm-tools/lib/file/filePosix.c @@ -114,6 +114,11 @@ struct WalkDirContextImpl #endif +/* A string for NFS on ESX file system type */ +#define FS_NFS_ON_ESX "NFS" +/* A string for VMFS on ESX file system type */ +#define FS_VMFS_ON_ESX "VMFS" + /* *----------------------------------------------------------------------------- @@ -1115,46 +1120,6 @@ bail: } -/* - *---------------------------------------------------------------------- - * - * File_GetVMFSVersion -- - * - * Acquire the version number for a given file on a VMFS file system. - * - * Results: - * Integer return value and version number - * - * Side effects: - * Will fail if file is not on VMFS or not enough memory for partition - * query results - * - *---------------------------------------------------------------------- - */ - -static int -File_GetVMFSVersion(ConstUnicode pathName, // IN: Filename to test - uint32 *version) // IN/OUT: version number of VMFS -{ - int ret; - FS_PartitionListResult *fsAttrs = NULL; - - ret = File_GetVMFSAttributes(pathName, &fsAttrs); - - if (ret < 0) { - Log(LGPFX" %s: File_GetVMFSAttributes failed\n", __func__); - } else { - *version = fsAttrs->versionNumber; - } - - if (fsAttrs) { - free(fsAttrs); - } - - return ret; -} - - /* *---------------------------------------------------------------------- * @@ -1195,47 +1160,6 @@ File_GetVMFSBlockSize(ConstUnicode pathName, // IN: File name to test } -/* - *---------------------------------------------------------------------- - * - * File_GetVMFSfsType -- - * - * Acquire the fsType for a given file on a VMFS. - * - * Results: - * Integer return value and fs type - * - * Side effects: - * Will fail if file is not on VMFS or not enough memory for partition - * query results - * - *---------------------------------------------------------------------- - */ - -int -File_GetVMFSfsType(ConstUnicode pathName, // IN: File name to test - char **fsType) // IN/OUT: VMFS fsType -{ - int ret; - FS_PartitionListResult *fsAttrs = NULL; - - ret = File_GetVMFSAttributes(pathName, &fsAttrs); - - if (ret < 0) { - Log(LGPFX" %s: File_GetVMFSAttributes failed\n", __func__); - } else { - *fsType = Util_SafeMalloc(sizeof(char) * FS_PLIST_DEF_MAX_FSTYPE_LEN); - memcpy(*fsType, fsAttrs->fsType, FS_PLIST_DEF_MAX_FSTYPE_LEN); - } - - if (fsAttrs) { - free(fsAttrs); - } - - return ret; -} - - /* *---------------------------------------------------------------------- * @@ -1279,7 +1203,7 @@ File_GetVMFSMountInfo(ConstUnicode pathName, // IN: *version = fsAttrs->versionNumber; *fsType = Util_SafeStrdup(fsAttrs->fsType); - if (strncmp(fsAttrs->fsType, "NFS", sizeof("NFS")) == 0) { + if (strncmp(fsAttrs->fsType, FS_NFS_ON_ESX, sizeof(FS_NFS_ON_ESX)) == 0) { len = strlen(fsAttrs->logicalDevice); *remoteIP = Util_SafeMalloc(len); *remoteMountPoint = Util_SafeMalloc(len); @@ -1297,6 +1221,50 @@ File_GetVMFSMountInfo(ConstUnicode pathName, // IN: #endif +/* + *---------------------------------------------------------------------- + * + * File_SupportsZeroedThick -- + * + * Check if the given file is on an FS supports creation of + * the zeroed-thick files. + * Currently only VMFS on ESX does support zeroed-thick files, but + * this may change in the future. + * + * Results: + * TRUE if FS supports creation of the zeroed-thick files. + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ + +Bool +File_SupportsZeroedThick(ConstUnicode pathName) // IN: File name to test +{ + Bool result = FALSE; + +#if defined(VMX86_SERVER) + /* Right now only VMFS supports ZeroedThick */ + FS_PartitionListResult *fsAttrs = NULL; + + if (File_GetVMFSAttributes(pathName, &fsAttrs) >= 0) { + result = strncmp(fsAttrs->fsType, FS_VMFS_ON_ESX, + sizeof(FS_VMFS_ON_ESX)) == 0; + } else { + Log(LGPFX" %s: File_GetVMFSAttributes failed\n", __func__); + } + + if (fsAttrs) { + free(fsAttrs); + } +#endif + + return result; +} + + /* *---------------------------------------------------------------------- * @@ -2000,46 +1968,34 @@ File_VMFSSupportsFileSize(ConstUnicode pathName, // IN: uint64 fileSize) // IN: { #if defined(VMX86_SERVER) - uint32 version = -1; - uint32 blockSize = -1; uint64 maxFileSize = -1; Bool supported; - char *fsType = NULL; - - if (File_GetVMFSVersion(pathName, &version) < 0) { - Log(LGPFX" %s: File_GetVMFSVersion Failed\n", __func__); - - return FALSE; - } - if (File_GetVMFSBlockSize(pathName, &blockSize) < 0) { - Log(LGPFX" %s: File_GetVMFSBlockSize Failed\n", __func__); + FS_PartitionListResult *fsAttrs = NULL; - return FALSE; - } - if (File_GetVMFSfsType(pathName, &fsType) < 0) { - Log(LGPFX" %s: File_GetVMFSfsType Failed\n", __func__); + if (File_GetVMFSAttributes(pathName, &fsAttrs) < 0) { + Log(LGPFX" %s: File_GetVMFSAttributes Failed\n", __func__); return FALSE; } - if (strcmp(fsType, "VMFS") == 0) { - if (version == 3) { - maxFileSize = (VMFS3CONST * (uint64) blockSize * 1024); + if (strcmp(fsAttrs->fsType, FS_VMFS_ON_ESX) == 0) { + if (fsAttrs->versionNumber == 3) { + maxFileSize = (VMFS3CONST * (uint64) fsAttrs->fileBlockSize * 1024); } else { /* Get ready for 64 TB on VMFS5 and perform sanity check on version */ - ASSERT(version == 5); + ASSERT(fsAttrs->versionNumber == 5); maxFileSize = (uint64) 0x400000000000ULL; } if (fileSize <= maxFileSize && maxFileSize != -1) { - free(fsType); + free(fsAttrs); return TRUE; } else { Log(LGPFX" %s: Requested file size (%"FMT64"d) larger than maximum " "supported filesystem file size (%"FMT64"d)\n", __FUNCTION__, fileSize, maxFileSize); - free(fsType); + free(fsAttrs); return FALSE; } @@ -2051,7 +2007,7 @@ File_VMFSSupportsFileSize(ConstUnicode pathName, // IN: if (fullPath == NULL) { Log(LGPFX" %s: Error acquiring full path\n", __func__); - free(fsType); + free(fsAttrs); return FALSE; } @@ -2060,7 +2016,7 @@ File_VMFSSupportsFileSize(ConstUnicode pathName, // IN: supported = FilePosixCreateTestFileSize(parentPath, fileSize); - free(fsType); + free(fsAttrs); Unicode_Free(fullPath); Unicode_Free(parentPath); diff --git a/open-vm-tools/lib/include/file.h b/open-vm-tools/lib/include/file.h index 85e87583a..05582894b 100644 --- a/open-vm-tools/lib/include/file.h +++ b/open-vm-tools/lib/include/file.h @@ -88,7 +88,6 @@ EXTERN char *FileMacos_DiskDeviceToUniqueID(char const *bsdPath); EXTERN char *FileMacos_UniqueIDToDiskDevice(char const *identifier); #elif defined VMX86_SERVER EXTERN int File_GetVMFSBlockSize(ConstUnicode pathName, uint32 *blockSize); -EXTERN int File_GetVMFSfsType(ConstUnicode pathName, char **fsType); EXTERN int File_GetVMFSMountInfo(ConstUnicode pathName, char **fsType, uint32 *version, @@ -97,6 +96,8 @@ EXTERN int File_GetVMFSMountInfo(ConstUnicode pathName, char **localMountPoint); #endif +EXTERN Bool File_SupportsZeroedThick(ConstUnicode pathName); + EXTERN Bool File_Exists(ConstUnicode pathName); EXTERN int File_Unlink(ConstUnicode pathName); diff --git a/open-vm-tools/modules/linux/shared/compat_skbuff.h b/open-vm-tools/modules/linux/shared/compat_skbuff.h index f4623d5d7..d1a72a5e8 100644 --- a/open-vm-tools/modules/linux/shared/compat_skbuff.h +++ b/open-vm-tools/modules/linux/shared/compat_skbuff.h @@ -36,6 +36,7 @@ #define compat_skb_tail_pointer(skb) skb_tail_pointer(skb) #define compat_skb_end_pointer(skb) skb_end_pointer(skb) #define compat_skb_ip_header(skb) ((struct iphdr *)skb_network_header(skb)) +#define compat_skb_ipv6_header(skb) ((struct ipv6hdr *)skb_network_header(skb)) #define compat_skb_tcp_header(skb) ((struct tcphdr *)skb_transport_header(skb)) #define compat_skb_reset_mac_header(skb) skb_reset_mac_header(skb) #define compat_skb_reset_network_header(skb) skb_reset_network_header(skb) @@ -52,6 +53,7 @@ #define compat_skb_tail_pointer(skb) (skb)->tail #define compat_skb_end_pointer(skb) (skb)->end #define compat_skb_ip_header(skb) (skb)->nh.iph +#define compat_skb_ipv6_header(skb) (skb)->nh.ipv6h #define compat_skb_tcp_header(skb) (skb)->h.th #define compat_skb_reset_mac_header(skb) ((skb)->mac.raw = (skb)->data) #define compat_skb_reset_network_header(skb) ((skb)->nh.raw = (skb)->data)