@@ -430,30 +430,48 @@ fn is_on_nfs_mount(_path: &Path) -> bool {
430
430
false
431
431
}
432
432
433
+ #[ cfg( all( unix, not( target_os = "solaris" ) ) ) ]
434
+ const LOCK_SH : i32 = libc:: LOCK_SH ;
435
+ #[ cfg( all( unix, target_os = "solaris" ) ) ]
436
+ const LOCK_SH : i32 = 1 ;
437
+ #[ cfg( all( unix, not( target_os = "solaris" ) ) ) ]
438
+ const LOCK_EX : i32 = libc:: LOCK_EX ;
439
+ #[ cfg( all( unix, target_os = "solaris" ) ) ]
440
+ const LOCK_EX : i32 = 2 ;
441
+ #[ cfg( all( unix, not( target_os = "solaris" ) ) ) ]
442
+ const LOCK_NB : i32 = libc:: LOCK_NB ;
443
+ #[ cfg( all( unix, target_os = "solaris" ) ) ]
444
+ const LOCK_NB : i32 = 4 ;
445
+ #[ cfg( all( unix, not( target_os = "solaris" ) ) ) ]
446
+ const LOCK_UN : i32 = libc:: LOCK_UN ;
447
+ #[ cfg( all( unix, target_os = "solaris" ) ) ]
448
+ const LOCK_UN : i32 = 8 ;
449
+
433
450
#[ cfg( unix) ]
434
451
mod sys {
452
+ use crate :: util:: flock:: { LOCK_EX , LOCK_NB , LOCK_SH , LOCK_UN } ;
435
453
use std:: fs:: File ;
436
454
use std:: io:: { Error , Result } ;
437
455
use std:: os:: unix:: io:: AsRawFd ;
438
456
439
457
pub ( super ) fn lock_shared ( file : & File ) -> Result < ( ) > {
440
- flock ( file, libc :: LOCK_SH )
458
+ flock ( file, LOCK_SH )
441
459
}
442
460
443
461
pub ( super ) fn lock_exclusive ( file : & File ) -> Result < ( ) > {
444
- flock ( file, libc :: LOCK_EX )
462
+ flock ( file, LOCK_EX )
445
463
}
446
464
447
465
pub ( super ) fn try_lock_shared ( file : & File ) -> Result < ( ) > {
448
- flock ( file, libc :: LOCK_SH | libc :: LOCK_NB )
466
+ flock ( file, LOCK_SH | LOCK_NB )
449
467
}
450
468
451
469
pub ( super ) fn try_lock_exclusive ( file : & File ) -> Result < ( ) > {
452
- flock ( file, libc :: LOCK_EX | libc :: LOCK_NB )
470
+ flock ( file, LOCK_EX | LOCK_NB )
453
471
}
454
472
455
473
pub ( super ) fn unlock ( file : & File ) -> Result < ( ) > {
456
- flock ( file, libc :: LOCK_UN )
474
+ flock ( file, LOCK_UN )
457
475
}
458
476
459
477
pub ( super ) fn error_contended ( err : & Error ) -> bool {
@@ -493,18 +511,18 @@ mod sys {
493
511
l_pid : 0 ,
494
512
l_pad : [ 0 , 0 , 0 , 0 ] ,
495
513
} ;
496
- flock. l_type = if flag & libc :: LOCK_UN != 0 {
514
+ flock. l_type = if flag & LOCK_UN != 0 {
497
515
libc:: F_UNLCK
498
- } else if flag & libc :: LOCK_EX != 0 {
516
+ } else if flag & LOCK_EX != 0 {
499
517
libc:: F_WRLCK
500
- } else if flag & libc :: LOCK_SH != 0 {
518
+ } else if flag & LOCK_SH != 0 {
501
519
libc:: F_RDLCK
502
520
} else {
503
521
panic ! ( "unexpected flock() operation" )
504
522
} ;
505
523
506
524
let mut cmd = libc:: F_SETLKW ;
507
- if ( flag & libc :: LOCK_NB ) != 0 {
525
+ if ( flag & LOCK_NB ) != 0 {
508
526
cmd = libc:: F_SETLK ;
509
527
}
510
528
0 commit comments