@drewdevault@fosstodon.org
@drewdevault@fosstodon.org avatar

drewdevault

@drewdevault@fosstodon.org

I write code

Natural language proficiency:
★★★★★ 🇺🇸
★★★☆☆ 🇯🇵
★★☆☆☆ 🇳🇱
★★☆☆☆ 🤟
★☆☆☆☆ 🇫🇷

Does not want to talk to you about cryptocurrency or AI

This profile is from a federated server and may be incomplete. Browse more on the original instance.

drewdevault, to random
@drewdevault@fosstodon.org avatar

I needed a break from Real Work, so I'm speedrunning writing a Unix-ish operating system

Day 3

drewdevault,
@drewdevault@fosstodon.org avatar

Did nanosleep(2)

drewdevault,
@drewdevault@fosstodon.org avatar

To implement nanosleep I just improved the wait queues a bit until nanosleep could be done in 33 lines of code

drewdevault,
@drewdevault@fosstodon.org avatar

Will probably have to change a bit once I implement signals and have to deal with EINTR

drewdevault,
@drewdevault@fosstodon.org avatar

Call it 32 lines, that assert belongs somewhere else

drewdevault,
@drewdevault@fosstodon.org avatar

Block device files are now mounted, not that you can open them

drewdevault,
@drewdevault@fosstodon.org avatar

Right, now you can open them

drewdevault,
@drewdevault@fosstodon.org avatar

I think that's everything for day 13:

  • O_CREAT support for openat
  • Character and block devices, incl /dev/null, zero, full, and block devices and partitions
  • Populate /dev with devices on boot
  • Add idle task to scheduler
  • New syscall: nanosleep

Next, in no particular order:

  • Flesh out files a bit more (e.g. enforce O_RDONLY)
  • Flesh out filesystem syscalls (mkdir, fstatat, etc)
  • Signals & waitpid
  • pipe(2), dup(2)
  • Start writing a libc
  • Port a shell
drewdevault,
@drewdevault@fosstodon.org avatar

Once I get all of those done, it's time to write a blog post about it and resume other projects!

drewdevault,
@drewdevault@fosstodon.org avatar

@lanodan I could port rc (and I might) but I'd like to do an ash derivative

drewdevault,
@drewdevault@fosstodon.org avatar

@JayT quite so

drewdevault,
@drewdevault@fosstodon.org avatar

@okflo oh god now I have to port doom to it

drewdevault,
@drewdevault@fosstodon.org avatar

Ended up with some extra free time tonight and did a couple more syscalls: unlinkat, mkdirat

Remaining filesystem-related syscalls are the stat family of calls, rmdirat (or AT_REMOVEDIR I guess), chmod/chown/chgrp, readlinkat, linkat, symlinkat, and utimensat.

drewdevault,
@drewdevault@fosstodon.org avatar
drewdevault,
@drewdevault@fosstodon.org avatar

Implemented a bunch of openat flags this morning: RDONLY/WRONLY/RDWR is now enforced, and O_DIRECTORY, O_APPEND, O_TRUNC, and O_EXCL are now supported

I chose to diverge from POSIX on O_DIRECTORY because I think it's kind of lame, but I could change my mind if this comes back to bite me when I start porting real-world software

drewdevault,
@drewdevault@fosstodon.org avatar

Also implemented an inode cache and reference counting for inodes 😃

drewdevault,
@drewdevault@fosstodon.org avatar

The cache currently serves just to make sure that there is a 1:1 correspondence between inode numbers and inode data structures (so that if several files hold a reference to the same inode they all remain in sync), it does not persist inodes after all references are released... yet. A broader cache system that keeps cached data in unused RAM is planned for the future.

drewdevault,
@drewdevault@fosstodon.org avatar

Signals 🤮

drewdevault,
@drewdevault@fosstodon.org avatar

waitpid

drewdevault,
@drewdevault@fosstodon.org avatar

@f4grx they're a better design, using O_DIRECTORY etc, imho. Particularly when it comes to implementing mountpoints. Simplifies things if you don't start from the assumption that you're always walking from the root

drewdevault,
@drewdevault@fosstodon.org avatar

many process, much wait

drewdevault,
@drewdevault@fosstodon.org avatar

@mxk what is sync_fd()? Do you mean fsync?

drewdevault,
@drewdevault@fosstodon.org avatar

@mxk I haven't implemented fsync and presently all writes are committed to disk before write(2) et al returns to userspace, so I'm not sure. I might know more when I get to that.

drewdevault,
@drewdevault@fosstodon.org avatar

@mxk @bugaevc I made it so that you can only open directories with O_DIRECTORY and they can only be O_RDONLY

drewdevault,
@drewdevault@fosstodon.org avatar

@bugaevc @mxk I guess that makes sense. We'll see what people are doing in the wild when I start porting software and it trips over this

drewdevault,
@drewdevault@fosstodon.org avatar

Okay, about done for today. Summary of day 14 writing a Unix clone:

New syscalls: exit, waitpid

Improvements to openat: enforces read/write mode, supports O_DIRECTORY, O_APPEND, O_TRUNC, O_EXCL, and O_CLOEXEC

Added an inode cache

Optimized the MMU code for fork and process clean-up (still no CoW, though)

And laid some groundwork for signals, which I have been dreading from the start.

https://git.sr.ht/~sircmpwn/bunnix

  • All
  • Subscribed
  • Moderated
  • Favorites
  • provamag3
  • kavyap
  • DreamBathrooms
  • InstantRegret
  • magazineikmin
  • thenastyranch
  • ngwrru68w68
  • Youngstown
  • everett
  • slotface
  • rosin
  • ethstaker
  • Durango
  • GTA5RPClips
  • megavids
  • cubers
  • modclub
  • mdbf
  • khanakhh
  • vwfavf
  • osvaldo12
  • cisconetworking
  • tester
  • Leos
  • tacticalgear
  • anitta
  • normalnudes
  • JUstTest
  • All magazines