Page 1 of 1

os_write_file

Posted: Wed Aug 20, 2008 10:24 am
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

Re: os_write_file

Posted: Wed Aug 20, 2008 12:32 pm
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

Re: os_write_file

Posted: Wed Aug 20, 2008 4:20 pm
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.

Re: os_write_file

Posted: Wed Aug 20, 2008 6:39 pm
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...

Re: os_write_file

Posted: Wed Aug 20, 2008 6:48 pm
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 :)

Re: os_write_file

Posted: Fri Aug 22, 2008 4:18 am
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