brintos

brintos / linux-shallow public Read only

0
0
Text · 943 B · dda3a87 Raw
53 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4# Kselftest framework requirement - SKIP code is 4.5ksft_skip=46 7DBGFS=$(grep debugfs /proc/mounts --max-count 1 | awk '{print $2}')8if [ "$DBGFS" = "" ]9then10	echo "debugfs not mounted"11	exit $ksft_skip12fi13 14DBGFS+="/damon"15 16if [ $EUID -ne 0 ];17then18	echo "Run as root"19	exit $ksft_skip20fi21 22if [ ! -d "$DBGFS" ]23then24	echo "$DBGFS not found"25	exit $ksft_skip26fi27 28if [ -f "$DBGFS/monitor_on_DEPRECATED" ]29then30	monitor_on_file="monitor_on_DEPRECATED"31else32	monitor_on_file="monitor_on"33fi34 35for f in attrs target_ids "$monitor_on_file"36do37	if [ ! -f "$DBGFS/$f" ]38	then39		echo "$f not found"40		exit 141	fi42done43 44permission_error="Operation not permitted"45for f in attrs target_ids "$monitor_on_file"46do47	status=$( cat "$DBGFS/$f" 2>&1 )48	if [ "${status#*$permission_error}" != "$status" ]; then49		echo "Permission for reading $DBGFS/$f denied; maybe secureboot enabled?"50		exit $ksft_skip51	fi52done53