1 : /*
2 : * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 : * Use of this source code is governed by a BSD-style license that can be
4 : * found in the LICENSE file.
5 : */
6 :
7 : #include <string.h>
8 : #include <sys/utsname.h>
9 :
10 : #include "native_client/src/shared/platform/nacl_log.h"
11 : #include "native_client/src/trusted/platform_qualify/kernel_version.h"
12 : #include "native_client/src/trusted/platform_qualify/nacl_os_qualify.h"
13 :
14 :
15 : #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32
16 :
17 : /*
18 : * The 64-bit Mac kernel bug was fixed in kernel version 10.8.0, which
19 : * is in Mac OS X 10.6.8.
20 : */
21 : static const char *kMinimumKernelVersion = "10.8";
22 :
23 : static int KernelVersionIsBuggy(const char *version) {
24 : int res;
25 : if (!NaClCompareKernelVersions(version, kMinimumKernelVersion, &res)) {
26 : NaClLog(LOG_ERROR, "KernelVersionIsBuggy: "
27 : "Couldn't parse kernel version: %s\n", version);
28 : return 1;
29 : }
30 : return res < 0;
31 : }
32 :
33 : #endif
34 :
35 : /*
36 : * Returns 1 if the operating system can run Native Client modules.
37 : */
38 : int NaClOsIsSupported(void) {
39 : #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32
40 : struct utsname info;
41 : if (uname(&info) != 0) {
42 : NaClLog(LOG_ERROR, "NaClOsIsSupported: uname() failed\n");
43 : return 0;
44 : }
45 : if (strcmp(info.machine, "x86_64") == 0 &&
46 : KernelVersionIsBuggy(info.release)) {
47 : NaClLog(LOG_ERROR,
48 : "NaClOsIsSupported: "
49 : "This system is running an old 64-bit Mac OS X kernel. "
50 : "This kernel version is buggy and can crash when running "
51 : "Native Client's x86-32 sandbox. "
52 : "The fix is to upgrade to Mac OS X 10.6.8 or later, or, as a "
53 : "workaround, to switch to using a 32-bit kernel, which will "
54 : "be capable of running Native Client. For more information, see "
55 : "http://code.google.com/p/nativeclient/issues/detail?id=1712\n");
56 : return 0;
57 : }
58 : #endif
59 266 : return 1;
60 : }
61 :
62 :
63 : /*
64 : * Returns 1 if the operating system is a 64-bit version of
65 : * Windows. For now, all of these versions are not supported.
66 : */
67 : int NaClOsIs64BitWindows(void) {
68 0 : return 0;
69 : }
|