Here is the Linux kernel code base.
❯ ls arch include mm tools Kbuild modules.order block init net usr Kconfig README certs io_uring rust virt MAINTAINERS System.map crypto ipc samples built-in.a Makefile vmlinux Documentation kernel scripts compile_commands.json Module.symvers vmlinux.a drivers lib security COPYING modules.builtin vmlinux.o fs LICENSES sound CREDITS modules.builtin.modinfo
I want to find all code that includes
start_kernel
. In VSCode, I can do this.![notion image](/notion-img?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fs3-us-west-2.amazonaws.com%252Fsecure.notion-static.com%252F1c6dad1b-19f7-4e17-ac19-9e8aa8aa3566%252FUntitled.png%3Ftable%3Dblock%26id%3D0c0112dd-a74c-4ed0-981a-3324e150d32c%26cache%3Dv2)
![notion image](/notion-img?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fs3-us-west-2.amazonaws.com%252Fsecure.notion-static.com%252Fbc16925d-a82d-43b7-a4b2-9c1f7a08c266%252FUntitled.png%3Ftable%3Dblock%26id%3Df2ad0818-8a4b-41a0-9178-be3d419e78b9%26cache%3Dv2)
I don’t want to see the code of architecture other than RISC-V, so I can exclude them.
exclude: arch/[^r]*
This line means to exclude all files in the
arch
folder, except the one that starts with the letter ‘r’.Notice that I still want to see all code including
start_kernel
out of the arch
folder.Or, I can use include to specify multiple architectures specifically.
include: ./[^a]*/**, ./arch/riscv/**
./[^a]*/**
includes all files except those in the folder starting with the letter ‘a’. The only folder that starts with ‘a’ is arch
. So it means to include all files except those in the arch
folder.![notion image](/notion-img?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fs3-us-west-2.amazonaws.com%252Fsecure.notion-static.com%252F871ceb57-a1f5-4f93-b1a7-ca6d4a524c62%252FUntitled.png%3Ftable%3Dblock%26id%3Da0646829-a4c6-4b2d-b6d4-c004cec9e9e1%26cache%3Dv2)