1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #![allow(unused)]
18 
19 extern crate libc;
20 extern crate tipc;
21 use log::info;
22 use std::io::{stdout, Write};
23 use std::write;
24 use system_state::{SystemState, SystemStateFlag};
25 use trusty_sys::iovec;
26 
main()27 fn main() {
28     trusty_log::init();
29 
30     let message = b"Hello from Rust!\n";
31     unsafe {
32         libc::write(2, message.as_ptr().cast(), message.len());
33     }
34 
35     let message2 = b"Hello from a Rust syscall!\n";
36     let iov = iovec { iov_base: message2.as_ptr() as *mut _, iov_len: message2.len() };
37     unsafe {
38         let _ = trusty_sys::writev(2, &iov, 1);
39     }
40 
41     write!(stdout(), "Hello from the Trusty Rust std!\n");
42 
43     info!("Hello from the log crate!");
44 
45     let state = SystemState::try_connect().expect("Could not connect to system state service");
46 
47     let provisioning_allowed = state
48         .get_flag(SystemStateFlag::ProvisioningAllowed)
49         .expect("Could not get provisioning flag");
50     info!("Provisioning allowed: {}", provisioning_allowed);
51 }
52