Write() Syscall | 32 Bit OS Dev (in C)
Вставка
- Опубліковано 4 лип 2024
- Expanding the write() syscall to work for open()-ed files and File Descriptors (FDs).
Brain was a bit slow on this one, hope that improves.
Errata:
- memcpy32() is wrong, it does not fill out the correct len % 4 number of bytes, or the right bytes at all in dest, from src. It was later changed to be:
for i = 0; i less than len / 4; i++
((uint32_t *)dst)[i] = ((uint32_t *)src)[i];
i *= 4; // NEW
for j = 0; j less than len % 4; i++, j++ // NEW
((uint8_t *)dst)[i] = ((uint8_t *)src)[i];
return dst;
Notes:
- One thing I should've added was a function to add a disk block to a file's data: allocate and add a bit in the data bitmap, and add that bit's disk block to the file's extents, extending the last extent currently used in the file. There is already code to do that in fs_impl.h/create_file() I think, but it would also be used in the write() syscall and possibly other places, so it should be extracted out into a function to make easier changes later.
Next video:
- adding a (buggy) read() syscall, to check that write() actually writes data to files
OS Dev playlist:
• Amateur Makes an OS
Git Repos:
Sourcehut: git.sr.ht/~queso_fuego/quesos
Github mirror: github.com/queso-fuego/amateuros
Repo state at the start of this video:
git clone -n github.com/queso-fuego/amateuros
cd amateuros
git checkout ea5f42df00c755d004780db0e47619a5b0d7e534
Join the Community Discord: / discord
Contact:
queso_fuego.srht.site/contact.html
- Let me know if there's anything specific you'd like to see!
Outline:
0:00 basic write() logic
2:07 start implementing write()
23:39 add helper function to update inode on disk
44:32 add no. of pages allocated to file table entries
57:01 add test for write()
Questions about setup/software/etc.?
Check the FAQ: queso_fuego.srht.site/about.html
Music credits:
City Life by Artificial.Music | / artificial-music
Music promoted by www.chosic.com/free-music/all/
Creative Commons CC BY 3.0
creativecommons.org/licenses/...
#writesyscall #kerneldev #cprogramming - Наука та технологія
Still had 3 or 4 videos from February on the harddrive, this one and those should be out this week or next.
UEFI related things will be after, while I think of how to get back to OS dev and other things.
Doing a lot better mentally these days, getting more sleep, food, and exercise, and I'll try to be more consistent with uploads.
Thank you all for your patience
You are awesome my friend. Cheers. 👍
You are a very great youtuber
The Cheesy Legend returns. 👍
You and ThatOSDev make the best osdev videos. More people should know about these 2 channels.
Definitely, his EFI videos especially have been a great inspiration
Big thanks all around. The way I see it, It's not a channel without those who follow. Cheers 👍
very good job