-
Notifications
You must be signed in to change notification settings - Fork 243
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·53 lines (42 loc) · 1.59 KB
/
setup.sh
File metadata and controls
executable file
·53 lines (42 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Runtime config for the fuzz box: debugfs/kcov perms for trinity, plus
# an iSCSI target with a ramdisk LUN so the login + SCSI CDB paths are
# reachable from any local TCP connect to 127.0.0.1:3260.
set -euo pipefail
# Write a value to a sysfs/configfs attribute, but only if it isn't
# already set to that value. This keeps the script idempotent across
# re-runs (re-writing an already-enabled attribute typically EINVALs).
write_if_changed() {
local path=$1
local value=$2
if [ -r "$path" ] && [ "$(cat "$path")" = "$value" ]; then
return 0
fi
echo "$value" > "$path"
}
setup_iscsi() {
modprobe iscsi_target_mod 2>/dev/null || true
if [ ! -d /sys/kernel/config/target ]; then
echo "setup_iscsi: /sys/kernel/config/target not present (CONFIG_TARGET_CORE off?), skipping"
return 0
fi
local TGT=/sys/kernel/config/target/iscsi/iqn.2026-05.fuzz:t/tpgt_1
mkdir -p "$TGT/np/127.0.0.1:3260"
write_if_changed "$TGT/attrib/authentication" 0
write_if_changed "$TGT/attrib/demo_mode_write_protect" 0
write_if_changed "$TGT/attrib/generate_node_acls" 1
write_if_changed "$TGT/attrib/cache_dynamic_acls" 1
local RD=/sys/kernel/config/target/core/rd_mcp_0/ram0
mkdir -p "$RD"
write_if_changed "$RD/control" 16384
write_if_changed "$RD/enable" 1
mkdir -p "$TGT/lun/lun_0"
ln -sfn "$RD" "$TGT/lun/lun_0/storage"
write_if_changed "$TGT/enable" 1
}
chmod 777 /sys/kernel/debug/
chmod 666 /sys/kernel/debug/kcov
if ! mountpoint -q /sys/kernel/config; then
mount -t configfs none /sys/kernel/config
fi
setup_iscsi