~henrix/ubuntu/precise/open-vm-dkms/lp-1416003

« back to all changes in this revision

Viewing changes to lib/user/hostinfoPosix.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-10-23 15:32:00 UTC
  • mfrom: (1.1.2 upstream) (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20081023153200-gc1bfx89hj35c799
Tags: 2008.10.10-123053-2
* Correcting typo in dh_installinit call.
* Downgrading depends on module-assistant to recommends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
#include <mach/mach.h>
56
56
#include <mach/mach_time.h>
57
57
#include <sys/sysctl.h>
 
58
#elif defined(__FreeBSD__)
 
59
#include <sys/sysctl.h>
 
60
#if !defined(RLIMIT_AS)
 
61
#  if defined(RLIMIT_VMEM)
 
62
#     define RLIMIT_AS RLIMIT_VMEM
 
63
#  else
 
64
#     define RLIMIT_AS RLIMIT_RSS
 
65
#  endif
 
66
#endif
58
67
#else
59
68
#if !defined(USING_AUTOCONF) || defined(HAVE_SYS_VFS_H)
60
69
#include <sys/vfs.h>
67
76
#endif
68
77
#endif
69
78
#endif
70
 
#if defined(__FreeBSD__)
71
 
#include <sys/types.h>
72
 
#include <sys/sysctl.h>
73
 
#endif
74
79
 
75
80
#include "vmware.h"
76
81
#include "hostType.h"
110
115
 * Local functions
111
116
 */
112
117
 
113
 
#if !defined(__APPLE__)
 
118
#if !defined(__APPLE__) && !defined(__FreeBSD__)
114
119
static char *HostinfoGetCpuInfo(int nCpu, char *name);
115
120
#if !defined(VMX86_SERVER)
116
121
static Bool HostinfoGetMemInfo(char *name, unsigned int *value);
254
259
   mach_timebase_info_data_t *ptr;
255
260
   static Atomic_Ptr atomic; /* Implicitly initialized to NULL. --mbellon */
256
261
 
257
 
#if defined(VMX86_DEBUG)
258
 
   SyncMutex *lck;
259
 
 
260
 
   static Atomic_Ptr lckStorage;
261
 
   static VmTimeType lastTimeRead;
262
 
#endif
263
 
 
264
262
   /* Insure that the time base values are correct. */
265
263
   ptr = (mach_timebase_info_data_t *) Atomic_ReadPtr(&atomic);
266
264
 
278
276
      ptr = (mach_timebase_info_data_t *) Atomic_ReadPtr(&atomic);
279
277
   }
280
278
 
281
 
#if defined(VMX86_DEBUG)
282
 
   /* assert that mach_absolute_time is always increasing */
283
 
   lck = SyncMutex_CreateSingleton(&lckStorage);
284
 
   SyncMutex_Lock(lck);
285
 
 
286
 
   raw = mach_absolute_time();
287
 
 
288
 
   ASSERT(raw >= lastTimeRead);
289
 
   lastTimeRead = raw;
290
 
 
291
 
   SyncMutex_Unlock(lck);
292
 
#else
293
 
   raw = mach_absolute_time();
294
 
#endif
 
279
   raw = mach_absolute_time();
295
280
 
296
281
   if ((ptr->numer == 1) && (ptr->denom == 1)) {
297
282
      /* The scaling values are unity, save some time/arithmetic */
301
286
      return ((double) raw) * (((double) ptr->numer) / ((double) ptr->denom));
302
287
   }
303
288
}
304
 
#else
 
289
#endif
305
290
 
306
291
 
307
292
/*
308
293
 *-----------------------------------------------------------------------------
309
294
 *
310
 
 * HostinfoSystemTimerUS --
 
295
 * HostinfoRawSystemTimerUS --
311
296
 *
312
 
 *      Obtain the system timer for non-Mac systems.
 
297
 *      Obtain the raw system timer value.
313
298
 *
314
299
 * Results:
315
300
 *      Relative time in microseconds or zero if a failure.
320
305
 *-----------------------------------------------------------------------------
321
306
 */
322
307
 
323
 
static VmTimeType
324
 
HostinfoSystemTimerUS(void)
 
308
VmTimeType
 
309
Hostinfo_RawSystemTimerUS(void)
325
310
{
 
311
#if defined(__APPLE__)
 
312
   return HostinfoMacAbsTimeNS() / 1000ULL;
 
313
#else
326
314
#if defined(VMX86_SERVER)
327
315
   if (HostType_OSIsPureVMK()) {
328
316
      uint64 uptime;
349
337
#if defined(VMX86_SERVER)
350
338
   }
351
339
#endif /* ifdef VMX86_SERVER */
 
340
#endif /* ifdef __APPLE__ */
352
341
}
353
 
#endif
354
342
 
355
343
 
356
344
/*
363
351
 *      Don't send a time obtained this way to another process and expect
364
352
 *      a relative time measurement to be correct.
365
353
 *
 
354
 *      This timer is documented to never go backwards.
 
355
 *
366
356
 * Results:
367
357
 *      Relative time in microseconds or zero if a failure.
368
358
 *
378
368
VmTimeType
379
369
Hostinfo_SystemTimerUS(void)
380
370
{
381
 
#if defined(__APPLE__)
382
 
   return HostinfoMacAbsTimeNS() / 1000ULL;
383
 
#else
384
371
   SyncMutex *lck;
385
372
   VmTimeType curTime;
386
373
   VmTimeType newTime;
390
377
   static VmTimeType lastTimeRead;
391
378
   static VmTimeType lastTimeReset;
392
379
 
393
 
   curTime = HostinfoSystemTimerUS();
 
380
   /* Get and take lock. */
 
381
   lck = SyncMutex_CreateSingleton(&lckStorage);
 
382
   SyncMutex_Lock(lck);
 
383
 
 
384
   curTime = Hostinfo_RawSystemTimerUS();
394
385
 
395
386
   if (curTime == 0) {
396
 
      return 0;
 
387
      newTime = 0;
 
388
      goto exit;
397
389
   }
398
390
 
399
 
   /* Get and take lock. */
400
 
   lck = SyncMutex_CreateSingleton(&lckStorage);
401
 
   SyncMutex_Lock(lck);
402
 
 
403
391
   /*
404
392
    * Don't let time be negative or go backward.  We do this by
405
393
    * tracking a base and moving foward from there.
415
403
 
416
404
   lastTimeRead = newTime;
417
405
 
 
406
exit:
418
407
   /* Release lock. */
419
408
   SyncMutex_Unlock(lck);
420
409
 
421
410
   return newTime;
422
 
#endif
423
411
}
424
412
 
425
413
/*
459
447
   }
460
448
 
461
449
   return 0;
462
 
#else
 
450
#elif defined(__linux__)
463
451
   int res;
464
452
   double uptime;
465
 
   FILE *f;
466
 
 
467
 
   f = Posix_Fopen("/proc/uptime", "r");
468
 
   if (!f) {
469
 
      Warning(LGPFX" Failed to open /proc/uptime: %s\n", Msg_ErrString());
 
453
   int fd;
 
454
   char buf[256];
 
455
 
 
456
   static Atomic_Int fdStorage = { -1 };
 
457
 
 
458
   fd = Atomic_ReadInt(&fdStorage);
 
459
 
 
460
   /* Do we need to open the file the first time through? */
 
461
   if (UNLIKELY(fd == -1)) {
 
462
      fd = open("/proc/uptime", O_RDONLY);
 
463
 
 
464
      if (fd == -1) {
 
465
         Warning(LGPFX" Failed to open /proc/uptime: %s\n", Msg_ErrString());
 
466
         return 0;
 
467
      }
 
468
 
 
469
      /* Try to swap ours in. If we lose the race, close our fd */
 
470
      if (Atomic_ReadIfEqualWriteInt(&fdStorage, -1, fd) != -1) {
 
471
         close(fd);
 
472
      }
 
473
 
 
474
      /* Get the winning fd - either ours or theirs, doesn't matter anymore */
 
475
      fd = Atomic_ReadInt(&fdStorage);
 
476
   }
 
477
 
 
478
   ASSERT(fd != -1);
 
479
 
 
480
   res = pread(fd, buf, sizeof buf - 1, 0);
 
481
   if (res == -1) {
 
482
      Warning(LGPFX" Failed to pread /proc/uptime: %s\n", Msg_ErrString());
470
483
      return 0;
471
484
   }
 
485
   ASSERT(res < sizeof buf);
 
486
   buf[res] = '\0';
472
487
 
473
 
   res = fscanf(f, "%lf", &uptime);
474
 
   fclose(f);
475
 
   if (res != 1) {
 
488
   if (sscanf(buf, "%lf", &uptime) != 1) {
476
489
      Warning(LGPFX" Failed to parse /proc/uptime\n");
477
490
      return 0;
478
491
   }
 
492
 
479
493
   return uptime * 1000 * 1000;
 
494
#else
 
495
NOT_IMPLEMENTED();
480
496
#endif
481
497
}
482
498
 
483
499
 
484
 
 
485
500
/*
486
501
 *-----------------------------------------------------------------------------
487
502
 *
682
697
   uint32 out;
683
698
   size_t outSize = sizeof out;
684
699
 
 
700
#if __FreeBSD__version >= 500019
685
701
   if (sysctlbyname("kern.smp.cpus", &out, &outSize, NULL, 0) == -1) {
686
702
      return -1;
687
703
   }
 
704
#else
 
705
   if (sysctlbyname("machdep.smp_cpus", &out, &outSize, NULL, 0) == -1) {
 
706
      if (errno == ENOENT) {
 
707
         out = 1;
 
708
      } else {
 
709
         return -1;
 
710
      }
 
711
   }
 
712
#endif
688
713
 
689
714
   return out;
690
715
#else
762
787
Hostinfo_GetRatedCpuMhz(int32 cpuNumber, // IN
763
788
                        uint32 *mHz)     // OUT
764
789
{
765
 
#if defined(__APPLE__)
 
790
#if defined(__APPLE__) || defined(__FreeBSD__)
 
791
 
 
792
#  if defined(__APPLE__)
 
793
#     define CPUMHZ_SYSCTL_NAME "hw.cpufrequency_max"
 
794
#  elif __FreeBSD__version >= 50011
 
795
#     define CPUMHZ_SYSCTL_NAME "hw.clockrate"
 
796
#  endif
 
797
 
 
798
#  if defined(CPUMHZ_SYSCTL_NAME)
766
799
   uint32 hz;
767
800
   size_t hzSize = sizeof hz;
768
801
 
769
802
   // 'cpuNumber' is ignored: Intel Macs are always perfectly symetric.
770
803
 
771
 
   if (sysctlbyname("hw.cpufrequency_max", &hz, &hzSize, NULL, 0) == -1) {
 
804
   if (sysctlbyname(CPUMHZ_SYSCTL_NAME, &hz, &hzSize, NULL, 0) == -1) {
772
805
      return FALSE;
773
806
   }
774
807
 
775
808
   *mHz = hz / 1000000;
776
809
   return TRUE;
 
810
#  else
 
811
   return FALSE;
 
812
#  endif
777
813
#else
778
814
   float fMhz = 0;
779
815
   char *readVal = HostinfoGetCpuInfo(cpuNumber, "cpu MHz");
811
847
char *
812
848
Hostinfo_GetCpuDescription(uint32 cpuNumber) // IN
813
849
{
814
 
#if defined(__APPLE__)
 
850
#if defined(__APPLE__) || defined(__FreeBSD__)
 
851
#  if defined(__APPLE__)
 
852
#     define CPUDESC_SYSCTL_NAME "machdep.cpu.brand_string"
 
853
#  else
 
854
#     define CPUDESC_SYSCTL_NAME "hw.model"
 
855
#  endif
 
856
 
815
857
   char *desc;
816
858
   size_t descSize;
817
859
 
818
860
   // 'cpuNumber' is ignored: Intel Macs are always perfectly symetric.
819
861
 
820
 
   if (sysctlbyname("machdep.cpu.brand_string", NULL, &descSize, NULL, 0)
 
862
   if (sysctlbyname(CPUDESC_SYSCTL_NAME, NULL, &descSize, NULL, 0)
821
863
          == -1) {
822
864
      return NULL;
823
865
   }
827
869
      return NULL;
828
870
   }
829
871
 
830
 
   if (sysctlbyname("machdep.cpu.brand_string", desc, &descSize, NULL, 0)
 
872
   if (sysctlbyname(CPUDESC_SYSCTL_NAME, desc, &descSize, NULL, 0)
831
873
          == -1) {
832
874
      free(desc);
833
875
      return NULL;
838
880
#ifdef VMX86_SERVER
839
881
   if (HostType_OSIsVMK()) {
840
882
      char mName[48];
 
883
 
 
884
      // VMKernel treats mName as an in/out parameter so terminate it.
 
885
      mName[0] = '\0';
841
886
      if (VMKernel_GetCPUModelName(mName, cpuNumber, sizeof(mName)) == VMK_OK) {
842
887
         mName[sizeof(mName) - 1] = '\0';
843
888
         return strdup(mName);
851
896
 
852
897
 
853
898
#if !defined(__APPLE__)
 
899
#if !defined(__FreeBSD__)
854
900
/*
855
901
 *----------------------------------------------------------------------
856
902
 *
911
957
   fclose(f);
912
958
   return value; 
913
959
}
914
 
 
915
 
 
916
 
#if !defined(VMX86_SERVER)
 
960
#endif /* __FreeBSD__ */
 
961
 
917
962
/*
918
963
 *----------------------------------------------------------------------
919
964
 *
1014
1059
 *      Retrieve system information on a Linux system.
1015
1060
 *    
1016
1061
 * Results:
1017
 
 *      TRUE on success: '*totalRam' and '*freeRam' are set if not NULL
 
1062
 *      TRUE on success: '*totalRam', '*freeRam', '*totalSwap' and '*freeSwap'
 
1063
 *                       are set if not NULL
1018
1064
 *      FALSE on failure
1019
1065
 *
1020
1066
 * Side effects:
1028
1074
 */
1029
1075
 
1030
1076
static Bool
1031
 
HostinfoSysinfo(uint64 *totalRam, // OUT: Total RAM in bytes
1032
 
                uint64 *freeRam)  // OUT: Free RAM in bytes
 
1077
HostinfoSysinfo(uint64 *totalRam,  // OUT: Total RAM in bytes
 
1078
                uint64 *freeRam,   // OUT: Free RAM in bytes
 
1079
                uint64 *totalSwap, // OUT: Total swap in bytes
 
1080
                uint64 *freeSwap)  // OUT: Free swap in bytes
1033
1081
{
1034
1082
#ifdef HAVE_SYSINFO
1035
1083
   // Found in linux/include/kernel.h for a 2.5.6 kernel --hpreg
1070
1118
   if (freeRam) {
1071
1119
      *freeRam = (uint64)si.freeram * si.mem_unit;
1072
1120
   }
 
1121
   if (totalSwap) {
 
1122
      *totalSwap = (uint64)si.totalswap * si.mem_unit;
 
1123
   }
 
1124
   if (freeSwap) {
 
1125
      *freeSwap = (uint64)si.freeswap * si.mem_unit;
 
1126
   }
1073
1127
 
1074
1128
   return TRUE;
1075
1129
#else // ifdef HAVE_SYSINFO
1076
1130
   NOT_IMPLEMENTED();
1077
1131
#endif // ifdef HAVE_SYSINFO
1078
1132
}
1079
 
#endif // ifndef VMX86_SERVER
1080
1133
#endif // ifndef __APPLE__
1081
1134
 
1082
1135
 
 
1136
#if defined(__linux__) || defined(__FreeBSD__) || defined(sun)
1083
1137
/*
1084
1138
 *-----------------------------------------------------------------------------
1085
1139
 *
1086
 
 * Hostinfo_GetMemoryInfoInPages --
 
1140
 * HostinfoGetLinuxMemoryInfoInPages --
1087
1141
 *
1088
1142
 *      Obtain the minimum memory to be maintained, total memory available, and
1089
 
 *      free memory available on the host in pages.
 
1143
 *      free memory available on the host (Linux or COS) in pages.
1090
1144
 *
1091
1145
 * Results:
1092
1146
 *      TRUE on success: '*minSize', '*maxSize' and '*currentSize' are set
1099
1153
 */
1100
1154
 
1101
1155
Bool
1102
 
Hostinfo_GetMemoryInfoInPages(unsigned int *minSize,     // OUT
1103
 
                              unsigned int *maxSize,     // OUT
1104
 
                              unsigned int *currentSize) // OUT
 
1156
HostinfoGetLinuxMemoryInfoInPages(unsigned int *minSize,     // OUT
 
1157
                                  unsigned int *maxSize,     // OUT
 
1158
                                  unsigned int *currentSize) // OUT
1105
1159
{
1106
 
#if defined(__APPLE__)
1107
 
   mach_msg_type_number_t count;
1108
 
   vm_statistics_data_t stat;
1109
 
   kern_return_t error;
1110
 
 
1111
 
   /*
1112
 
    * Largely inspired by
1113
 
    * darwinsource-10.4.5/top-15/libtop.c::libtop_p_vm_sample().
1114
 
    */
1115
 
 
1116
 
   count = HOST_VM_INFO_COUNT;
1117
 
   error = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&stat,
1118
 
                           &count);
1119
 
   if (error != KERN_SUCCESS || count != HOST_VM_INFO_COUNT) {
1120
 
      Warning("%s: Unable to retrieve host vm stats.\n", __FUNCTION__);
1121
 
      return FALSE;
1122
 
   }
1123
 
 
1124
 
   // XXX Figure out this value.
1125
 
   *minSize = 128;
1126
 
 
1127
 
   // XXX Hopefully this includes cached memory as well. We should check.
1128
 
   *currentSize = stat.free_count;
1129
 
 
1130
 
   /*
1131
 
    * Includes kernel memory. This is the same amount as reported by the
1132
 
    * "hw.physmem" sysctl, which is itself slightly lower than the amount
1133
 
    * reported by the "hw.memsize" sysctl, which is the physical RAM size.
1134
 
    */
1135
 
   *maxSize =   stat.free_count
1136
 
              + stat.wire_count + stat.active_count + stat.inactive_count;
1137
 
 
1138
 
   return TRUE;
1139
 
#elif defined(VMX86_SERVER)
1140
 
   uint64 total; 
1141
 
   uint64 free;
1142
 
   VMK_ReturnStatus status;
1143
 
 
1144
 
   if (VmkSyscall_Init(FALSE, NULL, 0)) {
1145
 
      status = CosVmnix_GetMemSize(&total, &free);
1146
 
      if (status == VMK_OK) {
1147
 
         *minSize = 128;
1148
 
         *maxSize = total / PAGE_SIZE;
1149
 
         *currentSize = free / PAGE_SIZE;
1150
 
 
1151
 
         return TRUE;
1152
 
      }
1153
 
   }
1154
 
 
1155
 
   return FALSE;
1156
 
#else 
1157
1160
   uint64 total; 
1158
1161
   uint64 free;
1159
1162
   unsigned int cached = 0;
1174
1177
    * leave that to be done in serverd/MUI.
1175
1178
    */
1176
1179
 
1177
 
   if (HostinfoSysinfo(&total, &free) == FALSE) {
 
1180
   if (HostinfoSysinfo(&total, &free, NULL, NULL) == FALSE) {
1178
1181
      return FALSE;
1179
1182
   }
1180
1183
 
1198
1201
   }
1199
1202
 
1200
1203
   return TRUE;
1201
 
#endif
1202
 
}
 
1204
}
 
1205
 
 
1206
 
 
1207
/*
 
1208
 *-----------------------------------------------------------------------------
 
1209
 *
 
1210
 * HostinfoGetSwapInfoInPages --
 
1211
 *
 
1212
 *      Obtain the total swap and free swap on the host (Linux or COS) in pages.
 
1213
 *
 
1214
 * Results:
 
1215
 *      TRUE on success: '*totalSwap' and '*freeSwap' are set if not NULL
 
1216
 *      FALSE on failure
 
1217
 *
 
1218
 * Side effects:
 
1219
 *      None
 
1220
 *
 
1221
 *-----------------------------------------------------------------------------
 
1222
 */
 
1223
 
 
1224
Bool
 
1225
Hostinfo_GetSwapInfoInPages(unsigned int *totalSwap,     // OUT
 
1226
                            unsigned int *freeSwap)      // OUT
 
1227
{
 
1228
   uint64 total; 
 
1229
   uint64 free;
 
1230
 
 
1231
   if (HostinfoSysinfo(NULL, NULL, &total, &free) == FALSE) {
 
1232
      return FALSE;
 
1233
   }
 
1234
 
 
1235
   if (totalSwap != NULL) {
 
1236
      *totalSwap = total / PAGE_SIZE;
 
1237
   }
 
1238
 
 
1239
   if (freeSwap != NULL) {
 
1240
      *freeSwap = free / PAGE_SIZE;
 
1241
   }
 
1242
 
 
1243
   return TRUE;
 
1244
}
 
1245
#endif
 
1246
 
 
1247
 
 
1248
/*
 
1249
 *-----------------------------------------------------------------------------
 
1250
 *
 
1251
 * Hostinfo_GetMemoryInfoInPages --
 
1252
 *
 
1253
 *      Obtain the minimum memory to be maintained, total memory available, and
 
1254
 *      free memory available on the host in pages.
 
1255
 *
 
1256
 * Results:
 
1257
 *      TRUE on success: '*minSize', '*maxSize' and '*currentSize' are set
 
1258
 *      FALSE on failure
 
1259
 *
 
1260
 * Side effects:
 
1261
 *      None
 
1262
 *
 
1263
 *-----------------------------------------------------------------------------
 
1264
 */
 
1265
 
 
1266
Bool
 
1267
Hostinfo_GetMemoryInfoInPages(unsigned int *minSize,     // OUT
 
1268
                              unsigned int *maxSize,     // OUT
 
1269
                              unsigned int *currentSize) // OUT
 
1270
{
 
1271
#if defined(__APPLE__)
 
1272
   mach_msg_type_number_t count;
 
1273
   vm_statistics_data_t stat;
 
1274
   kern_return_t error;
 
1275
   uint64_t memsize;
 
1276
   size_t memsizeSize = sizeof memsize;
 
1277
 
 
1278
   /*
 
1279
    * Largely inspired by
 
1280
    * darwinsource-10.4.5/top-15/libtop.c::libtop_p_vm_sample().
 
1281
    */
 
1282
 
 
1283
   count = HOST_VM_INFO_COUNT;
 
1284
   error = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&stat,
 
1285
                           &count);
 
1286
   if (error != KERN_SUCCESS || count != HOST_VM_INFO_COUNT) {
 
1287
      Warning("%s: Unable to retrieve host vm stats.\n", __FUNCTION__);
 
1288
      return FALSE;
 
1289
   }
 
1290
 
 
1291
   // XXX Figure out this value.
 
1292
   *minSize = 128;
 
1293
 
 
1294
   /*
 
1295
    * XXX Hopefully this includes cached memory as well. We should check.
 
1296
    * No. It returns only completely used pages.
 
1297
    */
 
1298
   *currentSize = stat.free_count;
 
1299
 
 
1300
   /*
 
1301
    * Adding up the stat values does not sum to 100% of physical memory.
 
1302
    * The correct value is available from sysctl so we do that instead.
 
1303
    */
 
1304
   if (sysctlbyname("hw.memsize", &memsize, &memsizeSize, NULL, 0) == -1) {
 
1305
      Warning("%s: Unable to retrieve host vm hw.memsize.\n", __FUNCTION__);
 
1306
      return FALSE;
 
1307
   }
 
1308
 
 
1309
   *maxSize = memsize / PAGE_SIZE;
 
1310
   return TRUE;
 
1311
#elif defined(VMX86_SERVER)
 
1312
   uint64 total; 
 
1313
   uint64 free;
 
1314
   VMK_ReturnStatus status;
 
1315
 
 
1316
   if (VmkSyscall_Init(FALSE, NULL, 0)) {
 
1317
      status = CosVmnix_GetMemSize(&total, &free);
 
1318
      if (status == VMK_OK) {
 
1319
         *minSize = 128;
 
1320
         *maxSize = total / PAGE_SIZE;
 
1321
         *currentSize = free / PAGE_SIZE;
 
1322
 
 
1323
         return TRUE;
 
1324
      }
 
1325
   }
 
1326
 
 
1327
   return FALSE;
 
1328
#else
 
1329
   return HostinfoGetLinuxMemoryInfoInPages(minSize, maxSize, currentSize);
 
1330
#endif
 
1331
}
 
1332
 
 
1333
 
 
1334
#ifdef VMX86_SERVER
 
1335
/*
 
1336
 *-----------------------------------------------------------------------------
 
1337
 *
 
1338
 * Hostinfo_GetCOSMemoryInfoInPages --
 
1339
 *
 
1340
 *      Obtain the minimum memory to be maintained, total memory available, and
 
1341
 *      free memory available on the COS in pages.
 
1342
 *
 
1343
 * Results:
 
1344
 *      TRUE on success: '*minSize', '*maxSize' and '*currentSize' are set
 
1345
 *      FALSE on failure
 
1346
 *
 
1347
 * Side effects:
 
1348
 *      None
 
1349
 *
 
1350
 *-----------------------------------------------------------------------------
 
1351
 */
 
1352
 
 
1353
Bool
 
1354
Hostinfo_GetCOSMemoryInfoInPages(unsigned int *minSize,     // OUT
 
1355
                                 unsigned int *maxSize,     // OUT
 
1356
                                 unsigned int *currentSize) // OUT
 
1357
{
 
1358
   if (HostType_OSIsPureVMK()) {
 
1359
      return FALSE;
 
1360
   } else {
 
1361
      return HostinfoGetLinuxMemoryInfoInPages(minSize, maxSize, currentSize);
 
1362
   }
 
1363
}
 
1364
#endif
1203
1365
 
1204
1366
 
1205
1367
/*
1547
1709
 
1548
1710
   if ((Posix_Getpwuid_r(getuid(), &pw, buffer, sizeof buffer, &ppw) == 0) &&
1549
1711
       (ppw != NULL)) {
1550
 
      if (pw.pw_name) {
1551
 
         name = Unicode_Duplicate(pw.pw_name);
 
1712
      if (ppw->pw_name) {
 
1713
         name = Unicode_Duplicate(ppw->pw_name);
1552
1714
      }
1553
1715
   }
1554
1716