]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Change to common source file not applicable to open-vm-tools.
authorKruti Pendharkar <kp025370@broadcom.com>
Tue, 22 Apr 2025 08:53:45 +0000 (01:53 -0700)
committerKruti Pendharkar <kp025370@broadcom.com>
Tue, 22 Apr 2025 08:53:45 +0000 (01:53 -0700)
open-vm-tools/lib/misc/hostname.c

index 376f7bc422bcce2c0854cee362d025bc4563fe57..09c59030be913f70831f1d950d906e79e967299e 100644 (file)
@@ -1,5 +1,6 @@
 /*********************************************************
- * Copyright (C) 2007-2017 VMware, Inc. All rights reserved.
+ * Copyright (c) 2007-2025 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
 #include <winsock.h>
 #endif
 
+#include <hostType.h>
+#include <strutil.h>
+#include <vm_basic_defs.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <ctype.h>
 
 #include "vmware.h"
 #include "str.h"
@@ -201,6 +207,24 @@ Hostinfo_HostName(void)
 
    char *result = NULL;
 
+#ifdef VMX86_SERVER
+   if (HostType_OSIsSimulator()) {
+      FILE *f = fopen("/var/run/vmware/HostSim_HostName.txt", "r");
+
+      if (f != NULL) {
+         char name[255] = {0};
+
+         (void)!fread(name, 1, sizeof(name) - 1, f); // ignore the result
+         fclose(f);
+
+         if (strlen(name) > 0 && Unicode_IsStringValidUTF8(name) == TRUE) {
+            result = StrUtil_TrimWhitespace(name);
+            return result;
+         }
+      }
+   }
+#endif
+
    if ((uname(&un) == 0) && (*un.nodename != '\0')) {
       char *p;
       int error;