1
1
// SPDX-License-Identifier: GPL-2.0-only
2
2
3
- use std:: fs:: { read_dir, write} ;
3
+ use std:: fs:: { create_dir_all , read_dir, write} ;
4
4
use std:: os:: unix:: ffi:: OsStrExt ;
5
5
use std:: os:: unix:: fs:: symlink;
6
6
use std:: { thread, time} ;
@@ -9,7 +9,7 @@ use log::debug;
9
9
10
10
use crate :: cmdline:: CmdlineOptions ;
11
11
use crate :: mount:: mount_apivfs;
12
- use crate :: { mkdir , Result } ;
12
+ use crate :: Result ;
13
13
14
14
fn write_file < C : AsRef < [ u8 ] > > ( path : & str , content : C ) -> Result < ( ) > {
15
15
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<()> {
27
27
28
28
mount_apivfs ( "/sys/kernel/config" , "configfs" ) ?;
29
29
30
- mkdir ( "/sys/kernel/config/usb_gadget/9pfs" ) ?;
30
+ create_dir_all ( "/sys/kernel/config/usb_gadget/9pfs" ) ?;
31
31
32
32
write_file ( "/sys/kernel/config/usb_gadget/9pfs/idVendor" , "0x1d6b" ) ?;
33
33
write_file ( "/sys/kernel/config/usb_gadget/9pfs/idProduct" , "0x0109" ) ?;
34
34
35
- mkdir ( "/sys/kernel/config/usb_gadget/9pfs/strings/0x409" ) ?;
35
+ create_dir_all ( "/sys/kernel/config/usb_gadget/9pfs/strings/0x409" ) ?;
36
36
write_file (
37
37
"/sys/kernel/config/usb_gadget/9pfs/strings/0x409/serialnumber" ,
38
38
"01234567" ,
@@ -46,12 +46,12 @@ fn setup_9pfs_gadget(device: &String) -> Result<()> {
46
46
"9PFS Gadget" ,
47
47
) ?;
48
48
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" ) ?;
51
51
52
52
let function = format ! ( "/sys/kernel/config/usb_gadget/9pfs/functions/usb9pfs.{device}" ) ;
53
53
let link = format ! ( "/sys/kernel/config/usb_gadget/9pfs/configs/c.1/usb9pfs.{device}" ) ;
54
- mkdir ( & function) ?;
54
+ create_dir_all ( & function) ?;
55
55
symlink ( & function, & link) ?;
56
56
57
57
debug ! (
0 commit comments