Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Varscott11

Couple questions about writing a custom OS

Question

I am attempting to write an OS from scratch and I have come up with a couple questions that somebody can hopefully clarify for me as I cannot continue without the following knowledge.

1).Since a critical function like require is unavailable, can someone point me to general steps needed to write a custom require function.
2).What would be needed to implement a custom filesystem without any libraries from openos.

Any help is greatly appreciated

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 1
  • Solution

1. Require looks if the library has been loaded before and if so it just returns the cached version, otherwise it searches in some predefined paths (usually the current directory, /lib and /usr/lib) for the library, reads the content of the file and uses the load() function to parse and execute the lua code, it caches the returned value from the executed lua / library file (so it is faster if the library is required again) and returns it. You can find the OpenOS implementation in /lib/package.lua

 

2. You don't have to make any library for a custom filesystem. In theory you can do everything with the filesystem component. But many systems implement a object oriented filesystem api and also a way to mount other filesystem component (like /mnt in OpenOS). Again you can look at OpenOS implementation in /lib/filesystem.lua and /boot/90_filesystem.lua.

If you want a custom directory structure you can also do that. OpenOS uses a unix like structure but you can also make your own. If you use Lua BIOS the only requirement is a init.lua in the root directory, but you can also change that by writing a custom BIOS, if you want.

EDIT: You might want to add basic programs to list, copy, rename, delete and edit files and directories and also to go to another directory (like "cd").

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.