Skip to content

Commit e799fda

Browse files
sjp38akpm00
authored andcommitted
selftests/damon/_damon_sysfs: find sysfs mount point from /proc/mounts
_damon_sysfs.py assumes sysfs is mounted at /sys. In some systems, that might not be true. Find the mount point from /proc/mounts file content. Link: https://lkml.kernel.org/r/20240503180318.72798-4-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 732b881 commit e799fda

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tools/testing/selftests/damon/_damon_sysfs.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22

33
import os
44

5-
sysfs_root = '/sys/kernel/mm/damon/admin'
5+
ksft_skip=4
6+
7+
sysfs_root = None
8+
with open('/proc/mounts', 'r') as f:
9+
for line in f:
10+
dev_name, mount_point, dev_fs = line.split()[:3]
11+
if dev_fs == 'sysfs':
12+
sysfs_root = '%s/kernel/mm/damon/admin' % mount_point
13+
break
14+
if sysfs_root is None:
15+
print('Seems sysfs not mounted?')
16+
exit(ksft_skip)
617

718
def write_file(path, string):
819
"Returns error string if failed, or None otherwise"

0 commit comments

Comments
 (0)