1 : /*
2 : * Copyright (c) 2013 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 "native_client/src/trusted/service_runtime/load_file.h"
8 :
9 : #include "native_client/src/trusted/desc/nacl_desc_base.h"
10 : #include "native_client/src/trusted/desc/nacl_desc_io.h"
11 : #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h"
12 : #include "native_client/src/trusted/service_runtime/nacl_valgrind_hooks.h"
13 : #include "native_client/src/trusted/service_runtime/sel_ldr.h"
14 :
15 :
16 262 : NaClErrorCode NaClAppLoadFileFromFilename(struct NaClApp *nap,
17 262 : const char *filename) {
18 262 : struct NaClDesc *nd;
19 262 : NaClErrorCode err;
20 :
21 262 : NaClFileNameForValgrind(filename);
22 :
23 262 : nd = (struct NaClDesc *) NaClDescIoDescOpen(filename, NACL_ABI_O_RDONLY,
24 : 0666);
25 262 : if (NULL == nd) {
26 1 : return LOAD_OPEN_ERROR;
27 : }
28 :
29 259 : NaClAppLoadModule(nap, nd, NULL, NULL);
30 259 : err = NaClWaitForLoadModuleStatus(nap);
31 259 : NaClDescUnref(nd);
32 259 : nd = NULL;
33 :
34 259 : if (err != LOAD_OK) {
35 6 : return err;
36 : }
37 :
38 253 : return err;
39 260 : }
|