File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change 1
1
// SPDX-License-Identifier: GPL-2.0-only
2
2
3
+ use std:: fs:: read_to_string;
4
+
3
5
use nix:: mount:: MsFlags ;
4
6
5
- use crate :: { read_file , Result } ;
7
+ use crate :: Result ;
6
8
7
9
pub struct CmdlineOptions {
8
10
pub root : Option < String > ,
@@ -67,7 +69,7 @@ fn parse_nfsroot(options: &mut CmdlineOptions) -> Result<()> {
67
69
} ;
68
70
rootflags. push_str ( ",addr=" ) ;
69
71
if !nfsroot. contains ( ':' ) {
70
- let pnp = read_file ( "/proc/net/pnp" ) ?;
72
+ let pnp = read_to_string ( "/proc/net/pnp" ) ?;
71
73
for line in pnp. lines ( ) {
72
74
match line. split_once ( ' ' ) {
73
75
None => continue ,
Original file line number Diff line number Diff line change 1
1
// SPDX-License-Identifier: GPL-2.0-only
2
2
3
3
use std:: fs:: OpenOptions ;
4
+ use std:: fs:: { read_to_string, OpenOptions } ;
4
5
use std:: mem:: size_of;
5
6
use std:: os:: fd:: IntoRawFd ;
6
7
use std:: path:: Path ;
@@ -12,7 +13,7 @@ use nix::libc::dev_t;
12
13
use nix:: sys:: stat:: minor;
13
14
14
15
use crate :: cmdline:: CmdlineOptions ;
15
- use crate :: { read_file , Result } ;
16
+ use crate :: Result ;
16
17
17
18
const DM_VERSION_MAJOR : u32 = 4 ;
18
19
@@ -132,7 +133,7 @@ pub fn prepare_dmverity(options: &mut CmdlineOptions) -> Result<bool> {
132
133
let mut salt = "" ;
133
134
let mut root_hash = "" ;
134
135
135
- let params = read_file ( "/verity-params" ) ?;
136
+ let params = read_to_string ( "/verity-params" ) ?;
136
137
for line in params. lines ( ) {
137
138
match line. split_once ( '=' ) {
138
139
None => continue ,
Original file line number Diff line number Diff line change @@ -46,10 +46,6 @@ pub fn mkdir(dir: &str) -> Result<()> {
46
46
Ok ( ( ) )
47
47
}
48
48
49
- fn read_file ( filename : & str ) -> std:: result:: Result < String , String > {
50
- read_to_string ( filename) . map_err ( |e| format ! ( "Failed to read {filename}: {e}" ) )
51
- }
52
-
53
49
/*
54
50
* Setup stdout/stderr. The kernel will create /dev/console in the
55
51
* initramfs, so we can use that.
@@ -152,7 +148,7 @@ fn init() -> Result<()> {
152
148
153
149
setup_log ( ) ?;
154
150
155
- let cmdline = read_file ( "/proc/cmdline" ) ?;
151
+ let cmdline = read_to_string ( "/proc/cmdline" ) ?;
156
152
let mut options = CmdlineOptions {
157
153
..Default :: default ( )
158
154
} ;
You can’t perform that action at this time.
0 commit comments