Linux Kernel contains only C code?

Aruna Hewapathirane aruna.hewapathirane at gmail.com
Thu Feb 1 11:37:26 EST 2018


> On Fri, Jan 26, 2018 at 1:58 AM, inventsekar <inventsekar at gmail.com>
wrote:
> Hi all, ...

> 1. May i know, other than C language, is there any other programming
language is/are used inside Linux Kernel?!?!
> is there any c++, Perl, python programs are used for peculiar tasks
inside Linux Kernel?!?!

Well, let's find out ? If you open up a shell/terminal and change into the
top level directory of your Linux kernel source and run the command below:

find . -type f -and -printf "%f\n" | grep -io '\.[^.]*$' | sort | uniq -c |
sort -rn ( Breaking this down, find all files+get the filename+pull out the
file extension+sort+only keep unique ext+sort with a stats count)

On my system with the kernel source for Linux-4.15 it shows me what's
below... keep in mind this is the number of 'unique' file extension types
in the kernel source tree. It's long but please keep scrolling all the way
there is useful stuff at the bottom.
25965 .c
 20363 .h
   4074 .txt
   1470 .S
   1437 .dts
   1098 .dtsi
    827 .rst
    211 .gitignore
    207 .json
    200 .sh
     75 .py
     59 .cocci
     57 .svg
     49 .boot
     42 .tc
     39 .pl
     36 .config
     31 .debug
     19 .lds
     15 .conf
     14 .ppm
     14 .fuc
     12 .fuc3
     10 .exceptions
      9 .y
      9 .h_shipped
      9 .c_shipped
      9 .awk
      8 .scr
      8 .l
      8 .html
      8 .dot
      8 .8
      8 .1
      7 .sa
      7 .in
      6 .cpp
      6 .asn1
      5 .xsl
      5 .uc
      5 .po
      5 .inc
      5 .fuc5
      5 .cpu
      4 .tbl
      4 .S_shipped
      4 .map
      4 .ld
      4 .include
      4 .fail
      4 .doc
      3 .smp_defconfig
      3 .pm
      3 .mk
      3 .gdbinit
      3 .csv
      3 .am
      2 .up_defconfig
      2 .um
      2 .ubsan
      2 .seq
      2 .rules
      2 .reg
      2 .powerpc
      2 .postlink
      2 .platforms
      2 .platform
      2 .pbm
      2 .nommu
      2 .megaraid
      2 .kasan
      2 .inl
      2 .inf
      2 .ids
      2 .fax
      2 .FAQ
      2 .build
      2 .arm
      1 .xs
      1 .x86
      1 .x25
      1 .wimax
      1 .WARNING
      1 .vringh
      1 .vim
      1 .vdec2_defconfig
      1 .vdec2
      1 .uni
      1 .txtd
      1 .tex
      1 .syncppp
      1 .sym53c8xx_2
      1 .sym53c8xx
      1 .SRC
      1 .soc
      1 .smp
      1 .select-break
      1 .sed
      1 .script
      1 .sb1000
      1 .rest
      1 .recursion-issue-02
      1 .recursion-issue-01
      1 .readme
      1 .README
      1 .qlge
      1 .qlcnic
      1 .qla4xxx
      1 .qla3xxx
      1 .qla2xxx
      1 .preempt
      1 .PL
      1 .perf
      1 .pass
      1 .ore
      1 .opsp_defconfig
      1 .normal
      1 .nommu_defconfig
      1 .netlink
      1 .net
      1 .ncr53c8xx
      1 .modsign
      1 .modpost
      1 .modinst
      1 .modes
      1 .modbuiltin
      1 .mm
      1 .mISDN
      1 .mips
      1 .megaraid_sas
      1 .md
      1 .mak
      1 .mailmap
      1 .machine
      1 .lpfc
      1 .loopback
      1 .locks
      1 .Locking
      1 .libfdt
      1 .lib
      1 .LIB
      1 .kgdb
      1 .kcov
      1 .ipw2200
      1 .ipw2100
      1 .ips
      1 .iosched
      1 .inc_shipped
      1 .ignore
      1 .i2400m
      1 .hz
      1 .hysdn
      1 .hp300
      1 .host
      1 .HiSax
      1 .hfc-pci
      1 .hex
      1 .headersinst
      1 .glade
      1 .gitattributes
      1 .gigaset
      1 .gif
      1 .generic
      1 .gdbinit_400MHz_32MB
      1 .gdbinit_300MHz_32MB
      1 .gdbinit_200MHz_16MB
      1 .gcc-plugins
      1 .gate
      1 .fuc4
      1 .fuc0s
      1 .freezer
      1 .FPE
      1 .FlashPoint
      1 .feature
      1 .extrawarn
      1 .example
      1 .dtc
      1 .dtbinst
      1 .DOC
      1 .diversion
      1 .dino
      1 .devices
      1 .default
      1 .def
      1 .DAC960
      1 .cycladesZ
      1 .css
      1 .cputype
      1 .copyright
      1 .concap
      1 .common
      1 .cocciconfig
      1 .clean
      1 .checkpatch
      1 .char
      1 .ChangeLog
      1 .cfg
      1 .cert
      1 .cc
      1 .CAPI
      1 .cache
      1 .bus
      1 .buddha
      1 .binfmt
      1 .bc
      1 .avmb1
      1 .audio
      1 .asm-generic
      1 .asm
      1 .arcmsr
      1 .arch
      1 .aic7xxx
      1 .aic79xx
      1 .agh
      1 .ac
      1 .1996-2002
      1 .1995-2002
      1 .1994-2004
      1 .1992-1997
      1 .

Somethings are obvious like we have :

25965 .c files
20363 .h files
4074 .txt files and
1470 .S files.

Somethings are not so obvious like what could possibly be a *.y file or
*.tc file ? If you type in find -name "*.y" in my case i see:

aruna at debian:~/linux-4.15$ find -name "*.y"
./drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y
./drivers/scsi/aic7xxx/aicasm/aicasm_gram.y
./tools/perf/util/expr.y
./tools/perf/util/pmu.y
./tools/perf/util/parse-events.y
./tools/bpf/bpf_exp.y
./scripts/dtc/dtc-parser.y
./scripts/genksyms/parse.y
./scripts/kconfig/zconf.y

Now if I pass that to the 'file' command ...

aruna at debian:~/linux-4.15$ file `find -name "*.y"` // yes you need those
back ticks :)

./drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y: C source, ASCII text
./drivers/scsi/aic7xxx/aicasm/aicasm_gram.y:       C source, ASCII text
./tools/perf/util/expr.y:                          C source, ASCII text
./tools/perf/util/pmu.y:                            C source, ASCII text
./tools/perf/util/parse-events.y:                   C source, ASCII text
./tools/bpf/bpf_exp.y:                           C source, ASCII text
./scripts/dtc/dtc-parser.y:                       C source, ASCII text
./scripts/genksyms/parse.y:                         C source, ASCII text
./scripts/kconfig/zconf.y:                          C source, ASCII text

So 'file' tells us these are C program files ? Lets verify ? If you 'cat'
any of these files you will see it is actual C code. Why does it have a
file extension of .y ?
Valdis or Gregkh may be able to shed some light on that I have no idea :)

Now we do the exact same thing for *.tc files.

aruna at debian:~/linux-4.15$ find -name "*.tc"

<snip>
./tools/testing/selftests/ftrace/test.d/00basic/basic3.tc
./tools/testing/selftests/ftrace/test.d/00basic/basic4.tc
<snip>

and pass this to 'file' and we see.. they seem to be shell scripts ?

aruna at debian:~/linux-4.15$ file `find -name "*.tc"`

<snip>
./tools/testing/selftests/ftrace/test.d/00basic/basic3.tc:
POSIX shell script, ASCII text executable
./tools/testing/selftests/ftrace/test.d/00basic/basic4.tc:
POSIX shell script, ASCII text executable
<snip>

So let's verify again ? By running -->aruna at debian:~/linux-4.15$ cat
./tools/testing/selftests/ftrace/test.d/00basic/basic4.tc

and we see they are shell scripts.

#!/bin/sh
# description: Basic event tracing check
test -f available_events -a -f set_event -a -d events
# check scheduler events are available
grep -q sched available_events && exit_pass || exit_fail

There are many 'interesting' things hidden away down the kernel source
rabbit hole. So explore with a child's curiosity, have lot's of patience
and wash +rinse+repeat as necessary.

Good luck !

Aruna ( to those who are long time kernel hackers and veterans my humble
apologies but I felt this was needed.. )














> 2. I believe some assembly language and shell scripting also used.. how
can I check them? Can you point me which part of the source code contains
the assembly and shell scripting



>
> Best regards
> Sekar
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20180201/9886260c/attachment-0001.html>


More information about the Kernelnewbies mailing list