1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4# Kselftest framework requirement - SKIP code is 4. 5ksft_skip=4 6 7DBGFS=/sys/kernel/debug/damon 8 9if [ $EUID -ne 0 ]; 10then 11 echo "Run as root" 12 exit $ksft_skip 13fi 14 15if [ ! -d "$DBGFS" ] 16then 17 echo "$DBGFS not found" 18 exit $ksft_skip 19fi 20 21for f in attrs target_ids monitor_on 22do 23 if [ ! -f "$DBGFS/$f" ] 24 then 25 echo "$f not found" 26 exit 1 27 fi 28done 29 30permission_error="Operation not permitted" 31for f in attrs target_ids monitor_on 32do 33 status=$( cat "$DBGFS/$f" 2>&1 ) 34 if [ "${status#*$permission_error}" != "$status" ]; then 35 echo "Permission for reading $DBGFS/$f denied; maybe secureboot enabled?" 36 exit $ksft_skip 37 fi 38done 39