11// SPDX-License-Identifier: GPL-2.0-only
22
3- use std:: fs:: { read_dir, write} ;
3+ use std:: fs:: { create_dir_all , read_dir, write} ;
44use std:: os:: unix:: ffi:: OsStrExt ;
55use std:: os:: unix:: fs:: symlink;
66use std:: { thread, time} ;
@@ -9,7 +9,7 @@ use log::debug;
99
1010use crate :: cmdline:: CmdlineOptions ;
1111use crate :: mount:: mount_apivfs;
12- use crate :: { mkdir , Result } ;
12+ use crate :: Result ;
1313
1414fn write_file < C : AsRef < [ u8 ] > > ( path : & str , content : C ) -> Result < ( ) > {
1515 write ( path, content) . map_err ( |e| format ! ( "Failed to write to {path}: {e}" ) . into ( ) )
@@ -27,12 +27,12 @@ fn setup_9pfs_gadget(device: &String) -> Result<()> {
2727
2828 mount_apivfs ( "/sys/kernel/config" , "configfs" ) ?;
2929
30- mkdir ( "/sys/kernel/config/usb_gadget/9pfs" ) ?;
30+ create_dir_all ( "/sys/kernel/config/usb_gadget/9pfs" ) ?;
3131
3232 write_file ( "/sys/kernel/config/usb_gadget/9pfs/idVendor" , "0x1d6b" ) ?;
3333 write_file ( "/sys/kernel/config/usb_gadget/9pfs/idProduct" , "0x0109" ) ?;
3434
35- mkdir ( "/sys/kernel/config/usb_gadget/9pfs/strings/0x409" ) ?;
35+ create_dir_all ( "/sys/kernel/config/usb_gadget/9pfs/strings/0x409" ) ?;
3636 write_file (
3737 "/sys/kernel/config/usb_gadget/9pfs/strings/0x409/serialnumber" ,
3838 "01234567" ,
@@ -46,12 +46,12 @@ fn setup_9pfs_gadget(device: &String) -> Result<()> {
4646 "9PFS Gadget" ,
4747 ) ?;
4848
49- mkdir ( "/sys/kernel/config/usb_gadget/9pfs/configs/c.1" ) ?;
50- mkdir ( "/sys/kernel/config/usb_gadget/9pfs/configs/c.1/strings/0x409" ) ?;
49+ create_dir_all ( "/sys/kernel/config/usb_gadget/9pfs/configs/c.1" ) ?;
50+ create_dir_all ( "/sys/kernel/config/usb_gadget/9pfs/configs/c.1/strings/0x409" ) ?;
5151
5252 let function = format ! ( "/sys/kernel/config/usb_gadget/9pfs/functions/usb9pfs.{device}" ) ;
5353 let link = format ! ( "/sys/kernel/config/usb_gadget/9pfs/configs/c.1/usb9pfs.{device}" ) ;
54- mkdir ( & function) ?;
54+ create_dir_all ( & function) ?;
5555 symlink ( & function, & link) ?;
5656
5757 debug ! (
0 commit comments