Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ jobs:
grep '] rust_selftests: All tests passed. Congratulations!$' qemu-stdout.log
grep '] rust_selftests: Rust self tests (exit)$' qemu-stdout.log

- run: |
grep '] rust_debugfs: Rust debugfs sample (init)$' qemu-stdout.log
grep '] rust_debugfs: Rust debugfs sample (exit)$' qemu-stdout.log
grep '^Debugfs file read count: 2$' qemu-stdout.log

# Report
- run: |
cat ${{ env.BUILD_DIR }}.config
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kernel-arm-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1782,6 +1782,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m
# CONFIG_STRICT_DEVMEM is not set

#
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kernel-arm-release.config
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m
# CONFIG_STRICT_DEVMEM is not set

#
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/kernel-arm64-debug-thinlto.config
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ CONFIG_DCACHE_WORD_ACCESS=y
#
# Pseudo filesystems
#
# CONFIG_PROC_FS is not set
CONFIG_PROC_FS=y
# CONFIG_PROC_CHILDREN is not set
# CONFIG_SYSFS is not set
# CONFIG_HUGETLBFS is not set
Expand Down Expand Up @@ -1439,6 +1439,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m

#
# arm64 Debugging
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/kernel-arm64-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ CONFIG_DCACHE_WORD_ACCESS=y
#
# Pseudo filesystems
#
# CONFIG_PROC_FS is not set
CONFIG_PROC_FS=y
# CONFIG_PROC_CHILDREN is not set
# CONFIG_SYSFS is not set
# CONFIG_HUGETLBFS is not set
Expand Down Expand Up @@ -1434,6 +1434,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m

#
# arm64 Debugging
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/kernel-arm64-release-thinlto.config
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ CONFIG_DCACHE_WORD_ACCESS=y
#
# Pseudo filesystems
#
# CONFIG_PROC_FS is not set
CONFIG_PROC_FS=y
# CONFIG_PROC_CHILDREN is not set
# CONFIG_SYSFS is not set
# CONFIG_HUGETLBFS is not set
Expand Down Expand Up @@ -1216,7 +1216,10 @@ CONFIG_FRAME_POINTER=y
# Generic Kernel Debugging Instruments
#
# CONFIG_MAGIC_SYSRQ is not set
# CONFIG_DEBUG_FS is not set
CONFIG_DEBUG_FS=y
CONFIG_DEBUG_FS_ALLOW_ALL=y
# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set
# CONFIG_DEBUG_FS_ALLOW_NONE is not set
CONFIG_HAVE_ARCH_KGDB=y
# CONFIG_KGDB is not set
CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y
Expand Down Expand Up @@ -1357,6 +1360,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m

#
# arm64 Debugging
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/kernel-arm64-release.config
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ CONFIG_DCACHE_WORD_ACCESS=y
#
# Pseudo filesystems
#
# CONFIG_PROC_FS is not set
CONFIG_PROC_FS=y
# CONFIG_PROC_CHILDREN is not set
# CONFIG_SYSFS is not set
# CONFIG_HUGETLBFS is not set
Expand Down Expand Up @@ -1211,7 +1211,10 @@ CONFIG_FRAME_POINTER=y
# Generic Kernel Debugging Instruments
#
# CONFIG_MAGIC_SYSRQ is not set
# CONFIG_DEBUG_FS is not set
CONFIG_DEBUG_FS=y
CONFIG_DEBUG_FS_ALLOW_ALL=y
# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set
# CONFIG_DEBUG_FS_ALLOW_NONE is not set
CONFIG_HAVE_ARCH_KGDB=y
# CONFIG_KGDB is not set
CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y
Expand Down Expand Up @@ -1352,6 +1355,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m

#
# arm64 Debugging
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/kernel-ppc64le-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1310,9 +1310,9 @@ CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1
CONFIG_MAGIC_SYSRQ_SERIAL=y
CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE=""
CONFIG_DEBUG_FS=y
# CONFIG_DEBUG_FS_ALLOW_ALL is not set
CONFIG_DEBUG_FS_ALLOW_ALL=y
# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set
CONFIG_DEBUG_FS_ALLOW_NONE=y
# CONFIG_DEBUG_FS_ALLOW_NONE is not set
CONFIG_HAVE_ARCH_KGDB=y
CONFIG_KGDB=y
CONFIG_KGDB_HONOUR_BLOCKLIST=y
Expand Down Expand Up @@ -1494,6 +1494,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m
CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y
# CONFIG_STRICT_DEVMEM is not set

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/kernel-ppc64le-release.config
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,10 @@ CONFIG_FRAME_WARN=2048
# Generic Kernel Debugging Instruments
#
# CONFIG_MAGIC_SYSRQ is not set
# CONFIG_DEBUG_FS is not set
CONFIG_DEBUG_FS=y
CONFIG_DEBUG_FS_ALLOW_ALL=y
# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set
# CONFIG_DEBUG_FS_ALLOW_NONE is not set
CONFIG_HAVE_ARCH_KGDB=y
CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y
# CONFIG_UBSAN is not set
Expand Down Expand Up @@ -1456,6 +1459,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m
CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y
# CONFIG_STRICT_DEVMEM is not set

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/kernel-riscv64-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,10 @@ CONFIG_FRAME_POINTER=y
# Generic Kernel Debugging Instruments
#
# CONFIG_MAGIC_SYSRQ is not set
# CONFIG_DEBUG_FS is not set
CONFIG_DEBUG_FS=y
CONFIG_DEBUG_FS_ALLOW_ALL=y
# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set
# CONFIG_DEBUG_FS_ALLOW_NONE is not set
CONFIG_HAVE_ARCH_KGDB=y
CONFIG_HAVE_ARCH_KGDB_QXFER_PKT=y
# CONFIG_KGDB is not set
Expand Down Expand Up @@ -1288,6 +1291,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m
# CONFIG_STRICT_DEVMEM is not set

#
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/kernel-riscv64-release.config
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,10 @@ CONFIG_FRAME_POINTER=y
# Generic Kernel Debugging Instruments
#
# CONFIG_MAGIC_SYSRQ is not set
# CONFIG_DEBUG_FS is not set
CONFIG_DEBUG_FS=y
CONFIG_DEBUG_FS_ALLOW_ALL=y
# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set
# CONFIG_DEBUG_FS_ALLOW_NONE is not set
CONFIG_HAVE_ARCH_KGDB=y
CONFIG_HAVE_ARCH_KGDB_QXFER_PKT=y
# CONFIG_UBSAN is not set
Expand Down Expand Up @@ -1204,6 +1207,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m
# CONFIG_STRICT_DEVMEM is not set

#
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/kernel-x86_64-debug-thinlto.config
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ CONFIG_DCACHE_WORD_ACCESS=y
#
# Pseudo filesystems
#
# CONFIG_PROC_FS is not set
CONFIG_PROC_FS=y
# CONFIG_PROC_CHILDREN is not set
CONFIG_KERNFS=y
CONFIG_SYSFS=y
Expand Down Expand Up @@ -1222,9 +1222,9 @@ CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1
CONFIG_MAGIC_SYSRQ_SERIAL=y
CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE=""
CONFIG_DEBUG_FS=y
# CONFIG_DEBUG_FS_ALLOW_ALL is not set
CONFIG_DEBUG_FS_ALLOW_ALL=y
# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set
CONFIG_DEBUG_FS_ALLOW_NONE=y
# CONFIG_DEBUG_FS_ALLOW_NONE is not set
CONFIG_HAVE_ARCH_KGDB=y
CONFIG_KGDB=y
CONFIG_KGDB_HONOUR_BLOCKLIST=y
Expand Down Expand Up @@ -1443,6 +1443,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m
CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y
# CONFIG_STRICT_DEVMEM is not set

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/kernel-x86_64-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ CONFIG_DCACHE_WORD_ACCESS=y
#
# Pseudo filesystems
#
# CONFIG_PROC_FS is not set
CONFIG_PROC_FS=y
# CONFIG_PROC_CHILDREN is not set
CONFIG_KERNFS=y
CONFIG_SYSFS=y
Expand Down Expand Up @@ -1217,9 +1217,9 @@ CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1
CONFIG_MAGIC_SYSRQ_SERIAL=y
CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE=""
CONFIG_DEBUG_FS=y
# CONFIG_DEBUG_FS_ALLOW_ALL is not set
CONFIG_DEBUG_FS_ALLOW_ALL=y
# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set
CONFIG_DEBUG_FS_ALLOW_NONE=y
# CONFIG_DEBUG_FS_ALLOW_NONE is not set
CONFIG_HAVE_ARCH_KGDB=y
CONFIG_KGDB=y
CONFIG_KGDB_HONOUR_BLOCKLIST=y
Expand Down Expand Up @@ -1446,6 +1446,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m
CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y
# CONFIG_STRICT_DEVMEM is not set

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/kernel-x86_64-release-thinlto.config
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,10 @@ CONFIG_STACK_VALIDATION=y
# Generic Kernel Debugging Instruments
#
# CONFIG_MAGIC_SYSRQ is not set
# CONFIG_DEBUG_FS is not set
CONFIG_DEBUG_FS=y
CONFIG_DEBUG_FS_ALLOW_ALL=y
# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set
# CONFIG_DEBUG_FS_ALLOW_NONE is not set
CONFIG_HAVE_ARCH_KGDB=y
CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y
# CONFIG_UBSAN is not set
Expand Down Expand Up @@ -1399,6 +1402,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m
CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y
# CONFIG_STRICT_DEVMEM is not set

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/kernel-x86_64-release.config
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,10 @@ CONFIG_STACK_VALIDATION=y
# Generic Kernel Debugging Instruments
#
# CONFIG_MAGIC_SYSRQ is not set
# CONFIG_DEBUG_FS is not set
CONFIG_DEBUG_FS=y
CONFIG_DEBUG_FS_ALLOW_ALL=y
# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set
# CONFIG_DEBUG_FS_ALLOW_NONE is not set
CONFIG_HAVE_ARCH_KGDB=y
CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y
# CONFIG_UBSAN is not set
Expand Down Expand Up @@ -1394,6 +1397,7 @@ CONFIG_SAMPLE_RUST_SEMAPHORE_C=m
CONFIG_SAMPLE_RUST_RANDOM=m
CONFIG_SAMPLE_RUST_HOSTPROGS=y
CONFIG_SAMPLE_RUST_SELFTESTS=m
CONFIG_SAMPLE_RUST_DEBUGFS=m
CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y
# CONFIG_STRICT_DEVMEM is not set

Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/qemu-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,17 @@ busybox insmod rust_module_parameters_loadable_custom.ko \
busybox rmmod rust_module_parameters_loadable_default.ko
busybox rmmod rust_module_parameters_loadable_custom.ko

busybox insmod rust_debugfs.ko
busybox mkdir proc
busybox mount -t proc proc /proc
busybox mkdir debugfs
busybox mount -t debugfs debugfs /debugfs
export RUST_SEQ_MINOR=$(busybox cat /proc/misc | busybox grep rust_debugfs | busybox cut -d ' ' -f 1)
busybox mknod /dev/rust_debugfs0 c 10 $RUST_SEQ_MINOR
busybox cat /dev/rust_debugfs0
busybox cat /dev/rust_debugfs0
busybox cat /debugfs/rust_debugfs_debug/rust_debugfs
busybox rm /dev/rust_debugfs0
busybox rmmod rust_debugfs.ko

busybox reboot -f
1 change: 1 addition & 0 deletions .github/workflows/qemu-initramfs.desc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ file /rust_stack_probing.ko samples/rust/rust_stack_probing.ko 0755
file /rust_semaphore.ko samples/rust/rust_semaphore.ko 0755 0 0
file /rust_semaphore_c.ko samples/rust/rust_semaphore_c.ko 0755 0 0
file /rust_selftests.ko samples/rust/rust_selftests.ko 0755 0 0
file /rust_debugfs.ko samples/rust/rust_debugfs.ko 0755 0 0

file /rust_module_parameters_loadable_default.ko samples/rust/rust_module_parameters_loadable_default.ko 0755 0 0
file /rust_module_parameters_loadable_custom.ko samples/rust/rust_module_parameters_loadable_custom.ko 0755 0 0
12 changes: 12 additions & 0 deletions fs/debugfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,18 @@ static void remove_one(struct dentry *victim)
simple_release_fs(&debugfs_mount, &debugfs_mount_count);
}

void debugfs_remove_with_callback(struct dentry *dentry,
void (*callback)(struct dentry *))
{
if (IS_ERR_OR_NULL(dentry))
return;

simple_pin_fs(&debug_fs_type, &debugfs_mount, &debugfs_mount_count);
simple_recursive_removal(dentry, callback);
simple_release_fs(&debugfs_mount, &debugfs_mount_count);
}
EXPORT_SYMBOL_GPL(debugfs_remove_with_callback);

/**
* debugfs_remove - recursively removes a directory
* @dentry: a pointer to a the dentry of the directory to be removed. If this
Expand Down
2 changes: 2 additions & 0 deletions include/linux/debugfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ struct dentry *debugfs_create_automount(const char *name,

void debugfs_remove(struct dentry *dentry);
#define debugfs_remove_recursive debugfs_remove
void debugfs_remove_with_callback(struct dentry *dentry,
void (*callback)(struct dentry *));

const struct file_operations *debugfs_real_fops(const struct file *filp);

Expand Down
1 change: 1 addition & 0 deletions rust/bindings/bindings_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/amba/bus.h>
#include <linux/cdev.h>
#include <linux/clk.h>
#include <linux/debugfs.h>
#include <linux/errname.h>
#include <linux/file.h>
#include <linux/fs.h>
Expand Down
Loading