os_write_file

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

os_write_file

Post by Troy Martin »

I need a system call to write a file to a FAT12 disk, but I don't know how to do that. I was thinking it could take a filename in SI, data starting memory address in AX, and data size in BX. I don't know what BX should be in multiples of, maybe 512-byte sectors.

Thanks!

Troy
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: os_write_file

Post by piranha »

My method is using file handles, thus allowing the kernel itself to deal with the nitty-gritty details. My write_file call is (FILE *f, char *buffer, size_t length).

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: os_write_file

Post by Troy Martin »

I think I may have written my post unclearly. I need some code to write a file to a FAT12 disk or a tutorial on how to do that.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Re: os_write_file

Post by xyjamepa »

I think you mean that you want to implement FAT12 file system in your os,
if this's right take a look at this...
The man who follows the crowd will usually get no further than the crowd.
The man who walks alone is likely to find himself in places
no one has ever been before.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: os_write_file

Post by Troy Martin »

I have reading files and loading programs from FAT12-formatted disks, but not writing. I've got a nice .pdf I found and WordPad open (my OS is in 16-bit assembly) so I'm going to wing it and hope it turns out okay. I'll post it if it works :)
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: os_write_file

Post by jal »

Troy Martin wrote:I have reading files and loading programs from FAT12-formatted disks, but not writing.
The added difficulty when writing a file is that if you are writing beyond its current size (in terms of blocks), you need to find some new space on the disk, by locating it in the FAT and updating the FAT-chain for that file. Good luck.


JAL
Post Reply