Index: trunk/src/VBox/Runtime/r3/linux/RTSystemQueryDmiString-linux.cpp
===================================================================
--- trunk/src/VBox/Runtime/r3/linux/RTSystemQueryDmiString-linux.cpp	(revision 26608)
+++ trunk/src/VBox/Runtime/r3/linux/RTSystemQueryDmiString-linux.cpp	(revision 26608)
@@ -0,0 +1,102 @@
+/* $Id$ */
+/** @file
+ * IPRT - RTSystemQueryDmiString, linux ring-3.
+ */
+
+/*
+ * Copyright (C) 2010 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <iprt/system.h>
+#include "internal/iprt.h"
+
+#include <iprt/err.h>
+#include <iprt/assert.h>
+#include <iprt/linux/sysfs.h>
+
+#include <errno.h>
+
+
+RTDECL(int) RTSystemQueryDmiString(RTSYSDMISTR enmString, char *pszBuf, size_t cbBuf)
+{
+    AssertPtrReturn(pszBuf, VERR_INVALID_POINTER);
+    AssertReturn(cbBuf > 0, VERR_INVALID_PARAMETER);
+    *pszBuf = '\0';
+    AssertReturn(enmString > RTSYSDMISTR_INVALID && enmString < RTSYSDMISTR_END, VERR_INVALID_PARAMETER);
+
+    const char *pszSysFsName;
+    switch (enmString)
+    {
+        case RTSYSDMISTR_PRODUCT_NAME:      pszSysFsName = "devices/virtual/dmi/id/product_name"; break;
+        case RTSYSDMISTR_PRODUCT_VERSION:   pszSysFsName = "devices/virtual/dmi/id/product_version"; break;
+        case RTSYSDMISTR_PRODUCT_UUID:      pszSysFsName = "devices/virtual/dmi/id/product_uuid"; break;
+        case RTSYSDMISTR_PRODUCT_SERIAL:    pszSysFsName = "devices/virtual/dmi/id/product_serial"; break;
+        default:
+            return VERR_NOT_SUPPORTED;
+    }
+
+    int rc;
+    int fd = RTLinuxSysFsOpen(pszSysFsName);
+    if (fd >= 0)
+    {
+        /* Note! This will return VERR_BUFFER_OVERFLOW even if there is a
+                 trailing newline that we don't care about. */
+        size_t cbRead;
+        rc = RTLinuxSysFsReadFile(fd, pszBuf, cbBuf - 1, &cbRead);
+        if (RT_SUCCESS(rc) || rc == VERR_BUFFER_OVERFLOW)
+        {
+            pszBuf[cbRead] = '\0';
+            while (cbRead > 0 && pszBuf[cbRead - 1] == '\n')
+                pszBuf[--cbRead] = '\0';
+        }
+        RTLinuxSysFsClose(fd);
+    }
+    else
+    {
+        rc = RTErrConvertFromErrno(errno);
+        switch (rc)
+        {
+            case VINF_SUCCESS:
+                AssertFailed();
+            case VERR_FILE_NOT_FOUND:
+            case VERR_PATH_NOT_FOUND:
+            case VERR_IS_A_DIRECTORY:
+                rc = VERR_NOT_SUPPORTED;
+                break;
+            case VERR_PERMISSION_DENIED:
+            case VERR_ACCESS_DENIED:
+                rc = VERR_ACCESS_DENIED;
+                break;
+        }
+    }
+
+    return rc;
+}
+RT_EXPORT_SYMBOL(RTSystemQueryDmiString);
+
+
Index: trunk/src/VBox/Runtime/r3/linux/sysfs.cpp
===================================================================
--- trunk/src/VBox/Runtime/r3/linux/sysfs.cpp	(revision 26344)
+++ trunk/src/VBox/Runtime/r3/linux/sysfs.cpp	(revision 26608)
@@ -208,4 +208,37 @@
     pszBuf[cchRead >= 0 ? cchRead : 0] = '\0';
     return cchRead;
+}
+
+
+RTDECL(int) RTLinuxSysFsReadFile(int fd, void *pvBuf, size_t cbBuf, size_t *pcbRead)
+{
+    int     rc;
+    ssize_t cbRead = read(fd, pvBuf, cbBuf);
+    if (cbRead >= 0)
+    {
+        if (pcbRead)
+            *pcbRead = cbRead;
+        if ((size_t)cbRead < cbBuf)
+            rc = VINF_SUCCESS;
+        else
+        {
+            /* Check for EOF */
+            char    ch;
+            off_t   off     = lseek(fd, 0, SEEK_CUR);
+            ssize_t cbRead2 = read(fd, &ch, 1);
+            if (cbRead2 == 0)
+                rc = VINF_SUCCESS;
+            else if (cbRead2 > 0)
+            {
+                lseek(fd, off, SEEK_SET);
+                rc = VERR_BUFFER_OVERFLOW;
+            }
+            else
+                rc = RTErrConvertFromErrno(errno);
+        }
+    }
+    else
+        rc = RTErrConvertFromErrno(errno);
+    return rc;
 }
 
