Skip to content

Commit b513e56

Browse files
committed
Add safe rules for ioctl and fcntl
1 parent addc4cd commit b513e56

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

rules/fcntl/tgt_refcount.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) 2022-present INESC-ID.
2+
// Distributed under the MIT license that can be found in the LICENSE file.
3+
4+
use libcc2rs::*;
5+
6+
fn f1(a0: i32, a1: i32, args: &[VaArg]) -> i32 {
7+
panic!(
8+
"fcntl is not supported in the refcount model (fd={}, cmd={}, varargs={})",
9+
a0,
10+
a1,
11+
args.len()
12+
)
13+
}
14+
15+
fn f2(a0: Ptr<u8>, a1: i32, args: &[VaArg]) -> i32 {
16+
panic!(
17+
"open is not supported in the refcount model (path={:?}, flags={}, varargs={})",
18+
a0.to_rust_string(),
19+
a1,
20+
args.len()
21+
)
22+
}

rules/ioctl/tgt_refcount.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) 2022-present INESC-ID.
2+
// Distributed under the MIT license that can be found in the LICENSE file.
3+
4+
use libcc2rs::*;
5+
6+
fn f1(a0: i32, a1: u64, args: &[VaArg]) -> i32 {
7+
panic!(
8+
"ioctl is not supported in the refcount model (fd={}, request={}, varargs={})",
9+
a0,
10+
a1,
11+
args.len()
12+
)
13+
}

rules/src/modules.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub mod deque_tgt_unsafe;
4040
pub mod dirent_tgt_unsafe;
4141
#[path = r#"../errno/tgt_unsafe.rs"#]
4242
pub mod errno_tgt_unsafe;
43+
#[path = r#"../fcntl/tgt_refcount.rs"#]
44+
pub mod fcntl_tgt_refcount;
4345
#[path = r#"../fcntl/tgt_unsafe.rs"#]
4446
pub mod fcntl_tgt_unsafe;
4547
#[path = r#"../fnmatch/tgt_unsafe.rs"#]
@@ -52,6 +54,8 @@ pub mod fstream_tgt_unsafe;
5254
pub mod ifaddrs_tgt_unsafe;
5355
#[path = r#"../initializer_list/tgt_unsafe.rs"#]
5456
pub mod initializer_list_tgt_unsafe;
57+
#[path = r#"../ioctl/tgt_refcount.rs"#]
58+
pub mod ioctl_tgt_refcount;
5559
#[path = r#"../ioctl/tgt_unsafe.rs"#]
5660
pub mod ioctl_tgt_unsafe;
5761
#[path = r#"../iomanip/tgt_unsafe.rs"#]

0 commit comments

Comments
 (0)