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 280 : NaClErrorCode NaClAppLoadFileFromFilename(struct NaClApp *nap,
17 : const char *filename) {
18 : struct NaClDesc *nd;
19 : NaClErrorCode err;
20 :
21 280 : NaClFileNameForValgrind(filename);
22 :
23 280 : nd = (struct NaClDesc *) NaClDescIoDescOpen(filename, NACL_ABI_O_RDONLY,
24 : 0666);
25 280 : if (NULL == nd) {
26 1 : return LOAD_OPEN_ERROR;
27 : }
28 :
29 279 : NaClAppLoadModule(nap, nd, NULL, NULL);
30 277 : err = NaClWaitForLoadModuleStatus(nap);
31 277 : NaClDescUnref(nd);
32 277 : nd = NULL;
33 :
34 277 : if (err != LOAD_OK) {
35 10 : return err;
36 : }
37 :
38 267 : return err;
39 : }
|