Skip to content

Commit eaa283d

Browse files
authored
Rollup merge of rust-lang#148322 - oxidecomputer:ea-flock-illumos, r=ChrisDenton
Enable file locking support in illumos rust-lang#132977 introduced an allow-list of targets supporting file locking, but forgot to add illumos to it (which introduced support for it in ~2015). `File::lock` and friends are now stable, and the ecosystem is slowly replacing custom libc calls with the standard library. Crucially, in 1.91 both Cargo and bootstrap switched to `File::lock`, both breaking build directory locking. This PR enables file locking on illumos. Fixes rust-lang#146312.
2 parents 3605e14 + 3d9c69b commit eaa283d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

library/std/src/fs/tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rand::RngCore;
55
target_os = "freebsd",
66
target_os = "linux",
77
target_os = "netbsd",
8+
target_os = "illumos",
89
target_vendor = "apple",
910
))]
1011
use crate::assert_matches::assert_matches;
@@ -14,6 +15,7 @@ use crate::char::MAX_LEN_UTF8;
1415
target_os = "freebsd",
1516
target_os = "linux",
1617
target_os = "netbsd",
18+
target_os = "illumos",
1719
target_vendor = "apple",
1820
))]
1921
use crate::fs::TryLockError;
@@ -227,6 +229,7 @@ fn file_test_io_seek_and_write() {
227229
target_os = "linux",
228230
target_os = "netbsd",
229231
target_os = "solaris",
232+
target_os = "illumos",
230233
target_vendor = "apple",
231234
))]
232235
fn file_lock_multiple_shared() {
@@ -251,6 +254,7 @@ fn file_lock_multiple_shared() {
251254
target_os = "linux",
252255
target_os = "netbsd",
253256
target_os = "solaris",
257+
target_os = "illumos",
254258
target_vendor = "apple",
255259
))]
256260
fn file_lock_blocking() {
@@ -276,6 +280,7 @@ fn file_lock_blocking() {
276280
target_os = "linux",
277281
target_os = "netbsd",
278282
target_os = "solaris",
283+
target_os = "illumos",
279284
target_vendor = "apple",
280285
))]
281286
fn file_lock_drop() {
@@ -298,6 +303,7 @@ fn file_lock_drop() {
298303
target_os = "linux",
299304
target_os = "netbsd",
300305
target_os = "solaris",
306+
target_os = "illumos",
301307
target_vendor = "apple",
302308
))]
303309
fn file_lock_dup() {

library/std/src/sys/fs/unix.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,7 @@ impl File {
12951295
target_os = "netbsd",
12961296
target_os = "openbsd",
12971297
target_os = "cygwin",
1298+
target_os = "illumos",
12981299
target_vendor = "apple",
12991300
))]
13001301
pub fn lock(&self) -> io::Result<()> {
@@ -1319,6 +1320,7 @@ impl File {
13191320
target_os = "openbsd",
13201321
target_os = "cygwin",
13211322
target_os = "solaris",
1323+
target_os = "illumos",
13221324
target_vendor = "apple",
13231325
)))]
13241326
pub fn lock(&self) -> io::Result<()> {
@@ -1332,6 +1334,7 @@ impl File {
13321334
target_os = "netbsd",
13331335
target_os = "openbsd",
13341336
target_os = "cygwin",
1337+
target_os = "illumos",
13351338
target_vendor = "apple",
13361339
))]
13371340
pub fn lock_shared(&self) -> io::Result<()> {
@@ -1356,6 +1359,7 @@ impl File {
13561359
target_os = "openbsd",
13571360
target_os = "cygwin",
13581361
target_os = "solaris",
1362+
target_os = "illumos",
13591363
target_vendor = "apple",
13601364
)))]
13611365
pub fn lock_shared(&self) -> io::Result<()> {
@@ -1369,6 +1373,7 @@ impl File {
13691373
target_os = "netbsd",
13701374
target_os = "openbsd",
13711375
target_os = "cygwin",
1376+
target_os = "illumos",
13721377
target_vendor = "apple",
13731378
))]
13741379
pub fn try_lock(&self) -> Result<(), TryLockError> {
@@ -1409,6 +1414,7 @@ impl File {
14091414
target_os = "openbsd",
14101415
target_os = "cygwin",
14111416
target_os = "solaris",
1417+
target_os = "illumos",
14121418
target_vendor = "apple",
14131419
)))]
14141420
pub fn try_lock(&self) -> Result<(), TryLockError> {
@@ -1425,6 +1431,7 @@ impl File {
14251431
target_os = "netbsd",
14261432
target_os = "openbsd",
14271433
target_os = "cygwin",
1434+
target_os = "illumos",
14281435
target_vendor = "apple",
14291436
))]
14301437
pub fn try_lock_shared(&self) -> Result<(), TryLockError> {
@@ -1465,6 +1472,7 @@ impl File {
14651472
target_os = "openbsd",
14661473
target_os = "cygwin",
14671474
target_os = "solaris",
1475+
target_os = "illumos",
14681476
target_vendor = "apple",
14691477
)))]
14701478
pub fn try_lock_shared(&self) -> Result<(), TryLockError> {
@@ -1481,6 +1489,7 @@ impl File {
14811489
target_os = "netbsd",
14821490
target_os = "openbsd",
14831491
target_os = "cygwin",
1492+
target_os = "illumos",
14841493
target_vendor = "apple",
14851494
))]
14861495
pub fn unlock(&self) -> io::Result<()> {
@@ -1505,6 +1514,7 @@ impl File {
15051514
target_os = "openbsd",
15061515
target_os = "cygwin",
15071516
target_os = "solaris",
1517+
target_os = "illumos",
15081518
target_vendor = "apple",
15091519
)))]
15101520
pub fn unlock(&self) -> io::Result<()> {

0 commit comments

Comments
 (0)