]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes in shared code that don't affect open-vm-tools functionality.
authorVMware, Inc <>
Thu, 17 Jun 2010 21:36:57 +0000 (14:36 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 17 Jun 2010 21:36:57 +0000 (14:36 -0700)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/file/filePosix.c
open-vm-tools/lib/include/file.h
open-vm-tools/modules/linux/shared/compat_skbuff.h

index 3615e418b11a07564c666a87c7eab655cc837085..46fd8a17bf9ca66559d59133c6b29df813722226 100644 (file)
@@ -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);
 
index 85e87583a8d6dba545412152dd42285ffefd2185..05582894b0a3fa39ac0eedfcbe0dbb1b0b7395a5 100644 (file)
@@ -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);
index f4623d5d7e090bbb1b72a69d2d3b03b6537e4528..d1a72a5e84d664245fb886082d2619830dbd67c5 100644 (file)
@@ -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)