~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools-precise.sid-merge1

« back to all changes in this revision

Viewing changes to lib/file/filePosix.c

  • Committer: Evan Broder
  • Date: 2010-03-21 23:26:53 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: broder@mit.edu-20100321232653-5a57r7v7ch4o6byv
Merging shared upstream rev into target branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
464
464
   if (getcwd(buffer, FILE_MAXPATH) == NULL) {
465
465
      Msg_Append(MSGID(filePosix.getcwd)
466
466
                 "Unable to retrieve the current working directory: %s. "
467
 
                 "Please check if the directory has been deleted or "
 
467
                 "Check if the directory has been deleted or "
468
468
                 "unmounted.\n",
469
469
                 Msg_ErrString());
470
470
      Warning(LGPFX" %s: getcwd() failed: %s\n", __FUNCTION__,
1293
1293
   }
1294
1294
   return ret;
1295
1295
}
1296
 
#endif
 
1296
 
 
1297
 
 
1298
/*
 
1299
 *----------------------------------------------------------------------
 
1300
 *
 
1301
 * File_GetVMFSMountInfo --
 
1302
 *
 
1303
 *      Acquire the FS mount point info such as fsType, major version,
 
1304
 *      local mount point (/vmfs/volumes/xyz), and for NFS,
 
1305
 *      remote IP and remote mount point for a given file.     
 
1306
 *
 
1307
 * Results:
 
1308
 *      Integer return value and allocated data
 
1309
 *
 
1310
 * Side effects:
 
1311
 *      Only implemented on ESX. Will fail on other platforms. 
 
1312
 *      remoteIP and remoteMountPoint are only populated for files on NFS.   
 
1313
 *
 
1314
 *----------------------------------------------------------------------
 
1315
 */
 
1316
 
 
1317
int 
 
1318
File_GetVMFSMountInfo(ConstUnicode pathName,
 
1319
                     char **fsType,
 
1320
                     uint32 *version,
 
1321
                     char **remoteIP,
 
1322
                     char **remoteMountPoint,
 
1323
                     char **localMountPoint)
 
1324
{
 
1325
   int ret;
 
1326
   int len;
 
1327
   FS_PartitionListResult *fsAttrs;
 
1328
 
 
1329
   *localMountPoint = File_GetUniqueFileSystemID(pathName);
 
1330
 
 
1331
   if (*localMountPoint == NULL) {
 
1332
      return -1;
 
1333
   }
 
1334
 
 
1335
   // Get file IP and mount point
 
1336
   ret = File_GetVMFSAttributes(pathName, &fsAttrs);  
 
1337
   if (ret >= 0 && fsAttrs) { 
 
1338
      *version = fsAttrs->versionNumber;
 
1339
      *fsType = Util_SafeStrdup(fsAttrs->fsType);
 
1340
 
 
1341
      if (strncmp(fsAttrs->fsType, "NFS", sizeof("NFS")) == 0) {
 
1342
         len = strlen(fsAttrs->logicalDevice);
 
1343
         *remoteIP = Util_SafeMalloc(len);
 
1344
         *remoteMountPoint = Util_SafeMalloc(len);
 
1345
         sscanf(fsAttrs->logicalDevice, "%s %s", *remoteIP, *remoteMountPoint);
 
1346
      } else {
 
1347
         *remoteIP = NULL;
 
1348
         *remoteMountPoint = NULL;   
 
1349
      }  
 
1350
   }
 
1351
 
 
1352
   free(fsAttrs);
 
1353
   return ret;
 
1354
}
 
1355
 
 
1356
#endif 
1297
1357
 
1298
1358
 
1299
1359
/*
1789
1849
   ASSERT(path1);
1790
1850
   ASSERT(path2);
1791
1851
 
1792
 
#if defined(VMX86_SERVER)
1793
 
   {
1794
 
      Unicode fs1;
1795
 
      Unicode fs2;
1796
 
 
1797
 
      fs1 = Posix_RealPath(path1);
1798
 
      fs2 = Posix_RealPath(path2);
1799
 
 
1800
 
      /*
1801
 
       * ESX doesn't have real inodes for VMFS disks in User Worlds. So only
1802
 
       * way to check if a file is the same is using real path. So said Satyam.
1803
 
       */
1804
 
 
1805
 
      if (fs1 && Unicode_StartsWith(fs1, VCFS_MOUNT_POINT)) {
1806
 
         Bool res;
1807
 
 
1808
 
         res = (!fs2 || Unicode_Compare(fs1, fs2) != 0) ? FALSE : TRUE;
1809
 
 
1810
 
         Unicode_Free(fs1);
1811
 
         Unicode_Free(fs2);
1812
 
 
1813
 
         return res;
1814
 
      }
1815
 
 
1816
 
      Unicode_Free(fs1);
1817
 
      Unicode_Free(fs2);
1818
 
   }
1819
 
#endif
1820
 
 
1821
1852
   /*
1822
1853
    * First take care of the easy checks.  If the paths are identical, or if
1823
1854
    * the inode numbers don't match, we're done.
2068
2099
 *
2069
2100
 *      Check if the given file is on a VMFS supports such a file size
2070
2101
 *
2071
 
 *      In the case of VMFS3/4, the largest supported file size is
 
2102
 *      In the case of VMFS3, the largest supported file size is
2072
2103
 *         256 * 1024 * B bytes
 
2104
 *      VMFS5 supports larger file sizes.
2073
2105
 *
2074
2106
 *      where B represents the blocksize in bytes
2075
2107
 *
2109
2141
   }
2110
2142
 
2111
2143
   if (strcmp(fsType, "VMFS") == 0) {
2112
 
      if (version >= 3) {
2113
 
         /* Get ready for VMFS4 and perform sanity check on version */
2114
 
         ASSERT(version == 3 || version == 4);
2115
 
 
 
2144
      if (version == 3) {
2116
2145
         maxFileSize = (VMFS3CONST * (uint64) blockSize * 1024);
 
2146
      } else {
 
2147
         /* Get ready for 64 TB on VMFS5 and perform sanity check on version */
 
2148
         ASSERT(version == 5);
 
2149
         maxFileSize = (uint64) 0x400000000000ULL;
2117
2150
      }
2118
2151
 
2119
2152
      if (fileSize <= maxFileSize && maxFileSize != -1) {