Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: ports/gambc_ppapi/main.c

Issue 150413008: Initial support for gambit-scheme v4.7.0 Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Add support for pnacl Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ports/gambc_ppapi/index.html ('k') | ports/gambc_ppapi/manifest.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2013 The Native Client Authors. All rights reserved. 1 /* Copyright (c) 2013 The Native Client Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. */ 3 * found in the LICENSE file. */
4 4
5 #include <assert.h> 5 #include <assert.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <libtar.h>
8 #include <limits.h> 7 #include <limits.h>
9 #include <stdio.h> 8 #include <stdio.h>
10 #include <stdlib.h> 9 #include <stdlib.h>
11 #include <string.h> 10 #include <string.h>
12 #include <sys/mount.h> 11 #include <sys/mount.h>
12 #include <sys/stat.h>
13 #include <unistd.h> 13 #include <unistd.h>
14 14
15 #include "ppapi_simple/ps_main.h" 15 #include "ppapi_simple/ps_main.h"
16 16
17 int lua_main(int argc, char **argv); 17 int gambc_main(int argc, char **argv);
18 18
19 static int setup_unix_environment(const char* tarfile) { 19 static int setup_unix_environment() {
20 int ret = umount("/"); 20 int ret = umount("/");
21 if (ret) { 21 if (ret) {
22 printf("unmounting root fs failed\n"); 22 printf("unmounting root fs failed\n");
23 return 1; 23 return 1;
24 } 24 }
25 ret = mount("", "/", "memfs", 0, NULL); 25 ret = mount("", "/", "memfs", 0, NULL);
26 if (ret) { 26 if (ret) {
27 printf("mounting root fs failed\n"); 27 printf("mounting root fs failed\n");
28 return 1; 28 return 1;
29 } 29 }
30 30
31 mkdir("/home", 0777); 31 mkdir("/home", 0777);
32 mkdir("/tmp", 0777); 32 mkdir("/tmp", 0777);
33 mkdir("/bin", 0777); 33 mkdir("/bin", 0777);
34 mkdir("/etc", 0777); 34 mkdir("/etc", 0777);
35 mkdir("/mnt", 0777); 35 mkdir("/mnt", 0777);
36 mkdir("/mnt/http", 0777); 36 mkdir("/mnt/http", 0777);
37 mkdir("/mnt/html5", 0777); 37 mkdir("/mnt/html5", 0777);
38 38
39 const char* data_url = getenv("DATA_URL"); 39 const char* data_url = getenv("DATA_URL");
40 if (!data_url) 40 if (!data_url)
41 data_url = "./"; 41 data_url = "./scm";
42 42
43 ret = mount(data_url, "/mnt/http", "httpfs", 0, 43 ret = mount(data_url, "/mnt/http", "httpfs", 0,
44 "allow_cross_origin_requests=true,allow_credentials=false"); 44 "allow_cross_origin_requests=true,allow_credentials=false");
45 if (ret) { 45 if (ret) {
46 printf("mounting http filesystem failed\n"); 46 printf("mounting http filesystem failed\n");
47 return 1; 47 return 1;
48 } 48 }
49 49
50 // Ignore failures from mounting html5fs. For example, it will always 50 // Ignore failures from mounting html5fs. For example, it will always
51 // fail in incognito mode. 51 // fail in incognito mode.
52 mount("/", "/mnt/html5", "html5fs", 0, ""); 52 mount("/", "/mnt/html5", "html5fs", 0, "");
53 53
54 // Extra tar achive from http filesystem.
55 if (tarfile) {
56 TAR* tar;
57 char filename[PATH_MAX];
58 strcpy(filename, "/mnt/http/");
59 strcat(filename, tarfile);
60 ret = tar_open(&tar, filename, NULL, O_RDONLY, 0, 0);
61 if (ret) {
62 printf("error opening: %s\n", filename);
63 return 1;
64 }
65
66 ret = tar_extract_all(tar, "/");
67 if (ret) {
68 printf("error extracting: %s\n", filename);
69 return 1;
70 }
71
72 ret = tar_close(tar);
73 assert(ret == 0);
74 }
75
76 // Setup environment 54 // Setup environment
77 setenv("HOME", "/home", 1); 55 setenv("HOME", "/home", 1);
78 setenv("PATH", "/bin", 1); 56 setenv("PATH", "/bin", 1);
79 setenv("USER", "user", 1); 57 setenv("USER", "user", 1);
80 setenv("LOGNAME", "user", 1); 58 setenv("LOGNAME", "user", 1);
81 return 0; 59 return 0;
82 } 60 }
83 61
84 int lua_ppapi_main(int argc, char **argv) { 62 int gambc_ppapi_main(int argc, char **argv) {
85 if (setup_unix_environment("luadata.tar")) 63 if (setup_unix_environment())
86 return 1; 64 return 1;
87 65
88 chdir("/lua-5.2.2-tests"); 66 return gambc_main(argc, argv);
89
90 return lua_main(argc, argv);
91 } 67 }
92 68
93 PPAPI_SIMPLE_REGISTER_MAIN(lua_ppapi_main) 69 PPAPI_SIMPLE_REGISTER_MAIN(gambc_ppapi_main)
OLDNEW
« no previous file with comments | « ports/gambc_ppapi/index.html ('k') | ports/gambc_ppapi/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698