@@ -19,12 +19,12 @@ const MAX_PATH: usize = 266;
19
19
static EXIT_ERR : i32 = 1 ;
20
20
21
21
#[ cfg( any(
22
- windows,
23
22
target_os = "freebsd" ,
24
23
target_vendor = "apple" ,
25
24
target_os = "netbsd" ,
26
25
target_os = "openbsd"
27
26
) ) ]
27
+ use crate :: os_str_from_bytes;
28
28
#[ cfg( windows) ]
29
29
use crate :: show_warning;
30
30
@@ -243,6 +243,8 @@ impl MountInfo {
243
243
// TODO: support the case when `GetLastError()` returns `ERROR_MORE_DATA`
244
244
return None ;
245
245
}
246
+ // TODO: This should probably call `OsString::from_wide`, but unclear if
247
+ // terminating zeros need to be striped first.
246
248
let mount_root = LPWSTR2String ( & mount_root_buf) ;
247
249
248
250
let mut fs_type_buf = [ 0u16 ; MAX_PATH ] ;
@@ -273,8 +275,8 @@ impl MountInfo {
273
275
dev_id : volume_name,
274
276
dev_name,
275
277
fs_type : fs_type. unwrap_or_default ( ) ,
276
- mount_root,
277
- mount_dir : String :: new ( ) ,
278
+ mount_root : mount_root . into ( ) , // TODO: We should figure out how to keep an OsString here.
279
+ mount_dir : OsString :: new ( ) ,
278
280
mount_option : String :: new ( ) ,
279
281
remote,
280
282
dummy : false ,
@@ -302,12 +304,11 @@ impl From<StatFs> for MountInfo {
302
304
. to_string_lossy ( )
303
305
. into_owned ( )
304
306
} ;
305
- let mount_dir = unsafe {
307
+ let mount_dir_bytes = unsafe {
306
308
// spell-checker:disable-next-line
307
- CStr :: from_ptr ( & statfs. f_mntonname [ 0 ] )
308
- . to_string_lossy ( )
309
- . into_owned ( )
309
+ CStr :: from_ptr ( & statfs. f_mntonname [ 0 ] ) . to_bytes ( )
310
310
} ;
311
+ let mount_dir = os_str_from_bytes ( mount_dir_bytes) . unwrap ( ) . into_owned ( ) ;
311
312
312
313
let dev_id = mount_dev_id ( & mount_dir) ;
313
314
let dummy = is_dummy_filesystem ( & fs_type, "" ) ;
@@ -318,7 +319,7 @@ impl From<StatFs> for MountInfo {
318
319
dev_name,
319
320
fs_type,
320
321
mount_dir,
321
- mount_root : String :: new ( ) ,
322
+ mount_root : OsString :: new ( ) ,
322
323
mount_option : String :: new ( ) ,
323
324
remote,
324
325
dummy,
0 commit comments