A Special Filesystem? | Coding the ProcFS File System | Raspberry Pi GPIO Driver Development

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ก.ย. 2024

ความคิดเห็น • 55

  • @rustyelectron
    @rustyelectron 3 ปีที่แล้ว +47

    Please keep on uploading. I love these tutorials.

    • @LowLevelLearning
      @LowLevelLearning  3 ปีที่แล้ว +2

      Glad you like them!

    • @qqri_
      @qqri_ 26 วันที่ผ่านมา

      @@LowLevelLearning can you please make device driver for some IPS displays by reading their manual ?

  • @TECHN01200
    @TECHN01200 ปีที่แล้ว +4

    Finally, a decent, relatively modern, resource with examples on driver development.

  • @ryanjl9
    @ryanjl9 2 ปีที่แล้ว +32

    I don't think your write function is safe. If they provide 1024 bytes, or greater, you're going to copy 1024 bytes into a buffer of 1024 bytes. However, when you use '%s' in the printk function, it's going to continue printing until it hits a NULL character. Ultimately if you're expecting a string value, or something that is NULL terminated, then you should always add 1 to buffer size. Great video though

  • @krzysztofadamski2884
    @krzysztofadamski2884 3 ปีที่แล้ว +23

    You're going with somewhat classic but somewhat obsolete way of teaching/learning kernel development where you make a module creating a procfs file. This isn't best choice in my opinion as nowadays, it is quite unlikely that a typical driver would ever create a procfs file. Sysfs file, on the other hand - sure. Debugfs file - also. But not a procfs.. not anymore :)
    Now with sysfs you have this added bonus that it handles more things for you and you wouldn't do this bug on read callback. In your code, you always return 7 so the cat doesn't know if it did read the whole file or not - the read syscall never returns the EOF condition. This is why real procfs code in the kernel uses seq_operations abstraction to hanlde that nicely.
    The easiest thing you could do, however, is to check the offset argument, if it's non zero, you know its the 2nd read call and you can return 0 instead of 7. This still isn't fully correct but at least you won't get many "hello" messages anymore.

  • @AJMansfield1
    @AJMansfield1 2 ปีที่แล้ว +9

    Your `printk` call in `lll_write` would result in a kernel infoleak vulnerability. If the user passes input longer than the buffer, there won't be any null bytes left at the end from the initial zero-fill and the `%s` may continue reading off the end of the buffer. To avoid this in ordinary C code, one would use the 'variable precision' form to allow you to specify the maximum length as an additional argument:
    printk("You said '%.*s'!
    ", size, data_buffer)
    Even better, though, would be to use the "escaped raw buffer" format -- provided as an extension for `printk` not present in ordinary `printf` -- to avoid writing newlines, control characters, or other garbage from the user into the kernel message log:
    printk("You said '%*pE'!
    ", size, data_buffer)

  • @simonedallai48
    @simonedallai48 3 ปีที่แล้ว +2

    thanks I hope it is the second video of a long series, then also examining the whole issue of interrupts ....... sincere congratulations!

  • @UmmadikTas
    @UmmadikTas 3 ปีที่แล้ว +7

    This is so good. I wish these series were available last year :( Could you also recommend some reading material? Thank you

  • @Mouta77
    @Mouta77 2 ปีที่แล้ว +3

    wow! we need more videos like this!!! Thanks for your work!

  • @anneallison6402
    @anneallison6402 3 หลายเดือนก่อน

    I really love your explanation style. Hope you could make more advanced videos, you seem to have so much knowledge

  • @hashomi0596
    @hashomi0596 2 ปีที่แล้ว +1

    Oh man. Thank you so much. Kernel modules were a black box for me.

  • @Sladen70
    @Sladen70 2 ปีที่แล้ว +1

    Keep it up friend, you are making an impact on learners like me :)

  • @jackyli6716
    @jackyli6716 5 หลายเดือนก่อน

    Thanks your tutorial, that's really cool! keep up!bro.

  • @mancio92M
    @mancio92M 3 ปีที่แล้ว +1

    beautiful tutorial
    very clear explanation
    very clear and readable code

  • @bharadwajn.k9185
    @bharadwajn.k9185 3 ปีที่แล้ว +1

    Sir your channel should get more support. your vids are so usefull. Keep making these contents. THANK YOUU🙏🙏

  • @yonatanbeyn8557
    @yonatanbeyn8557 3 ปีที่แล้ว +2

    Great!!! Learning a lot !!!!

  • @chandpriyankara
    @chandpriyankara 2 ปีที่แล้ว +2

    return simple_read_from_buffer(user, size, off, "Hello!
    " , 7); to avoid lot of Hello!'s

  • @tintran6288
    @tintran6288 ปีที่แล้ว

    that was wonderful

  • @Bagasl
    @Bagasl 2 ปีที่แล้ว

    Amazing tutorials, thank you

  • @jokarjapan
    @jokarjapan ปีที่แล้ว

    Million like , we need more videos

  • @HerrHeisenheim
    @HerrHeisenheim 3 ปีที่แล้ว +1

    Very interesting series, please continue. I need to find something useful that would require a kernel module just to try it out.
    For those wondering, /proc is not a magic keyword, it's simply a special filesystem mounted by the kernel. You can see that by typing `mount`, among other such special FS (/sys, ...).
    @LLL do you plan on making a video that explains how to create a kernel module that can be mounted like this?

  • @yajurrai6491
    @yajurrai6491 3 ปีที่แล้ว +1

    Nice.. Keep uploading raspberry pi pico videos :)

    • @LowLevelLearning
      @LowLevelLearning  3 ปีที่แล้ว +2

      Will do, once I figure out how to get this damn OLED screen to work D:

  • @williamsquires3070
    @williamsquires3070 2 ปีที่แล้ว +1

    What if something went wrong and crashed? How would you debug the kernel-level code?

  • @juuamjskn2420
    @juuamjskn2420 3 ปีที่แล้ว +1

    Thanks

  • @adambeedle
    @adambeedle 3 ปีที่แล้ว +1

    Nice tutorial mate 👍

  • @umitsen1757
    @umitsen1757 3 ปีที่แล้ว

    Many thanks bro

  • @izardymiranda7790
    @izardymiranda7790 2 ปีที่แล้ว +1

    How did you get the broadcom datasheets?I Didn't found them even in the Broadcom's site :(

  • @GilbertLaurel
    @GilbertLaurel 3 ปีที่แล้ว

    nice! please do more kernel driver tutorials

  • @srivathsa3387
    @srivathsa3387 3 ปีที่แล้ว +1

    Thanks man! For the tutorials they are awesome. I just want to what do you do for living. Are you kernel developer ?

    • @LowLevelLearning
      @LowLevelLearning  3 ปีที่แล้ว +2

      I am not a kernel developer, just embedded developer and a reader of stackoverflow LOL

  • @damn_right_man8606
    @damn_right_man8606 2 ปีที่แล้ว

    Loving it

  • @rabiahussain4953
    @rabiahussain4953 3 ปีที่แล้ว +1

    please keep on uploading, how to write keyboard, mouse drivers and much more and what interview question can interviewer ask?

  • @parsishashank
    @parsishashank 3 ปีที่แล้ว +2

    Hello,
    I have an question here
    How the procfs will fetch the exact data from the hardware
    For example: /proc/meminfo will reflect the memory details.
    Will procfs resides in primary memory rather than secondary memory?
    If not can you please explain with example 🙂

    • @krzysztofadamski2884
      @krzysztofadamski2884 3 ปีที่แล้ว +1

      Here's how it does this:
      elixir.bootlin.com/linux/latest/source/fs/proc/meminfo.c#L32

  • @Dygear
    @Dygear 3 ปีที่แล้ว

    Thanks!

    • @LowLevelLearning
      @LowLevelLearning  3 ปีที่แล้ว +1

      @mark coming in with the crazy support. Thank you so much my dude!

  • @dijkstra4678
    @dijkstra4678 2 ปีที่แล้ว

    Very nice

  • @mathiasensimon
    @mathiasensimon 2 ปีที่แล้ว

    I understand it barely but great series

  • @yuriidudko2813
    @yuriidudko2813 2 ปีที่แล้ว

    amazing

  • @poketopa1234
    @poketopa1234 3 หลายเดือนก่อน

    Did anyone catch the bug/reason why the file has many "hello"s when catted?

  • @pup4301
    @pup4301 3 ปีที่แล้ว

    I know this is off topic but I was wondering if you know how to pass internet over usb gadget for a raspberry pi zero?

  • @HanWae363
    @HanWae363 ปีที่แล้ว

    Can you show us how to make a build target for a platform? For C/Rust

  • @FatPinkSlug
    @FatPinkSlug ปีที่แล้ว

    Because these are file system constructs, does this mean the driver speed is bottlenecked by the sdd/hdd speed?

  • @williamsquires3070
    @williamsquires3070 2 ปีที่แล้ว

    (@5:00) - don’t you have to put \o (lowercase oh) to do an octal literal? Otherwise, you’ll just get 666 (base 10), which isn’t the same. You could also do \b000110110110 for binary, or \x1B6 for hexadecimal.

    • @navire_
      @navire_ 2 ปีที่แล้ว

      Putting a '0' before a number formats it to octal, like '0b' for binary and '0x' for hex values

  • @n0kodoko143
    @n0kodoko143 2 ปีที่แล้ว

    2/3 👍

  • @roughedge-machineworks
    @roughedge-machineworks ปีที่แล้ว +1

    now.. how do we do this in rust.. :P

  • @cutiepie0608
    @cutiepie0608 3 ปีที่แล้ว

    make[1]: *** /lib/modules/5.10.17-v7l+/build: No such file or directory. Stop.
    I m getting above error when give make all command, can anyone help to remove this error?