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 11// SPDX-License-Identifier: GPL-2.0-only
22
3+ use std:: fs:: read_to_string;
4+
35use nix:: mount:: MsFlags ;
46
5- use crate :: { read_file , Result } ;
7+ use crate :: Result ;
68
79pub struct CmdlineOptions {
810 pub root : Option < String > ,
@@ -67,7 +69,7 @@ fn parse_nfsroot(options: &mut CmdlineOptions) -> Result<()> {
6769 } ;
6870 rootflags. push_str ( ",addr=" ) ;
6971 if !nfsroot. contains ( ':' ) {
70- let pnp = read_file ( "/proc/net/pnp" ) ?;
72+ let pnp = read_to_string ( "/proc/net/pnp" ) ?;
7173 for line in pnp. lines ( ) {
7274 match line. split_once ( ' ' ) {
7375 None => continue ,
Original file line number Diff line number Diff line change 11// SPDX-License-Identifier: GPL-2.0-only
22
33use std:: fs:: OpenOptions ;
4+ use std:: fs:: { read_to_string, OpenOptions } ;
45use std:: mem:: size_of;
56use std:: os:: fd:: IntoRawFd ;
67use std:: path:: Path ;
@@ -12,7 +13,7 @@ use nix::libc::dev_t;
1213use nix:: sys:: stat:: minor;
1314
1415use crate :: cmdline:: CmdlineOptions ;
15- use crate :: { read_file , Result } ;
16+ use crate :: Result ;
1617
1718const DM_VERSION_MAJOR : u32 = 4 ;
1819
@@ -132,7 +133,7 @@ pub fn prepare_dmverity(options: &mut CmdlineOptions) -> Result<bool> {
132133 let mut salt = "" ;
133134 let mut root_hash = "" ;
134135
135- let params = read_file ( "/verity-params" ) ?;
136+ let params = read_to_string ( "/verity-params" ) ?;
136137 for line in params. lines ( ) {
137138 match line. split_once ( '=' ) {
138139 None => continue ,
Original file line number Diff line number Diff line change @@ -46,10 +46,6 @@ pub fn mkdir(dir: &str) -> Result<()> {
4646 Ok ( ( ) )
4747}
4848
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-
5349/*
5450 * Setup stdout/stderr. The kernel will create /dev/console in the
5551 * initramfs, so we can use that.
@@ -152,7 +148,7 @@ fn init() -> Result<()> {
152148
153149 setup_log ( ) ?;
154150
155- let cmdline = read_file ( "/proc/cmdline" ) ?;
151+ let cmdline = read_to_string ( "/proc/cmdline" ) ?;
156152 let mut options = CmdlineOptions {
157153 ..Default :: default ( )
158154 } ;
You can’t perform that action at this time.
0 commit comments