OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Aug 22, 2018 2:20 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Can't put files onto my virtual floppy disk? [solved]
PostPosted: Thu Jun 07, 2018 8:48 pm 
Offline
User avatar

Joined: Wed Jun 06, 2018 9:15 pm
Posts: 15
EDIT: I should have put this, but forgot about it... here is a pastebin link to my boot sector x86 Assembly program if it would help. https://pastebin.com/mDHXwLyE

So I'm in a little situation with my operating system; if this is explained in the wiki, then please redirect me to that wiki page. I've looked it over, again and again, but I cannot find a solution to my problem on it. Anyway, on with the question.

I should preface this with saying that I'm building this operating system on Windows, using no GNU tools expect DD - I believe that will be useful for anyone that might know what to do. Now then, I made a virtual floppy drive, (using: "fsutil file createnew .\floppy.vfd 1474560") and can successfully burn the FIRST STAGE of the boot loader onto it. (using: "dd if=.\Boot.bin of=.\floppy.vfd") And now this is where the question comes in.

I have a program called ImDisk, which I'm trying to use to mount the disk, so that I can put the files onto the disk. But when I try to mount it, it cannot recognize that there is any valid disk. What's even weirder is that I cannot format the disk. If I format the disk with FAT, (What I'm trying to put on the floppy disk in the first place.) and try to burn the FIRST STAGE of the boot loader onto the disk, my tools completely reject in every way possible; because VirtualBox cannot use it, it says it's 'unsupported.' So I cannot mount it to put files onto it, because it Windows cannot recognize the filesystem on the drive. But if I format it, all my tools reject it.

I'm at a massive stand still... So my question now becomes, how can I put files into my disk without mounting it? This is a massive pain. I'm trying so hard not to install a Linux distribution on my PC, but this is annoying. Thanks, seriously.


Last edited by MSDOSDudeNot on Fri Jun 08, 2018 10:38 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? (strange ??
PostPosted: Thu Jun 07, 2018 9:49 pm 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 887
Checkout my BootProg.
No extra tools needed (just NASM and a C compiler).


Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? (strange ??
PostPosted: Thu Jun 07, 2018 10:01 pm 
Offline
Member
Member

Joined: Mon Jul 25, 2016 6:54 pm
Posts: 120
Location: Adelaide, Australia
I think the problem is just that with no BIOS parameter block on your floppy image, ImDisk doesn't actually know what to do with it.


Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? (strange ??
PostPosted: Fri Jun 08, 2018 2:16 pm 
Offline
User avatar

Joined: Wed Jun 06, 2018 9:15 pm
Posts: 15
StudlyCaps wrote:
I think the problem is just that with no BIOS parameter block on your floppy image, ImDisk doesn't actually know what to do with it.


That could be the issue, but I've tried other mounting drivers, and the same thing happens. If I were to format the drive through Windows, the way it wants it to be formated, everything works; everything recognizes the drive. But if I do it not, nothing recognizes the drive, at all.

I should have mentioned that I also have the BIOS parameter block already setup on the floppy disk drive image. So that could not possible be the problem.


Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? (strange ??
PostPosted: Fri Jun 08, 2018 2:58 pm 
Offline
User avatar

Joined: Wed Jun 06, 2018 9:15 pm
Posts: 15
I need to add something else to this. I wrote this post, so that I could ask this question, before I went to sleep, so I forgot some information. I already made an edit above, and now here is another one, but not as an edit to the original post.

I should also have mentioned that everything works fine if I use a virtual machine running Windows XP. I can mount the image, and use the debug command to write to the sectors, and add files to it. But the issue with it, I have to way to many more steps just to test the new code, and that will become a hassle, really fast. So I'm in addition asking this question, so that I can avoid that if at all possible. Thanks.


Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? (strange ??
PostPosted: Fri Jun 08, 2018 5:58 pm 
Offline
Member
Member

Joined: Sat Jul 02, 2016 7:02 am
Posts: 96
I am not sure if you willingly left some portion of the dd command, but that command, as it is pasted, truncates the output file. The option 'conv=notrunc' is needed to prevent the truncation.

With that out of the way, I would format the disk, and then perform a field-by-field copy of the boot-sector binary into the vfd by using a hex editor (hxd is nice). After each field copied, the file could be tested with vbox for problems. It is tedious, but it can narrow down the problem.


Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? (strange ??
PostPosted: Fri Jun 08, 2018 7:26 pm 
Offline
User avatar

Joined: Wed Jun 06, 2018 9:15 pm
Posts: 15
linuxyne wrote:
I am not sure if you willingly left some portion of the dd command, but that command, as it is pasted, truncates the output file. The option 'conv=notrunc' is needed to prevent the truncation.

With that out of the way, I would format the disk, and then perform a field-by-field copy of the boot-sector binary into the vfd by using a hex editor (hxd is nice). After each field copied, the file could be tested with vbox for problems. It is tedious, but it can narrow down the problem.


The command doesn't truncate it; at least not that I can see. The bytes of the file are not changing. I'm using the DD from: http://www.chrysocome.net/dd - and I even searched for how to burn it to the floppy disk drive. Every time I add the command parameter 'conv=notrunc', it said that there is no command 'conv=notrunc'. And I'm watching the size of the image, it stays the same, it's not getting truncated. Unless it's getting truncated 'internally' and not 'externally'.

Not sure if this would help, but here are some pictures of what I mean.

Pay close attention to the size of the 'floppy.vfd' file.

https://imgur.com/sQQrfbz
And then, after entering the command I used in the original post:
https://imgur.com/hMcKj5v
The bytes of the file are still the same. I'm not sure how it's getting truncated. Unless I'm missing something, here...

This is me trying to burn it to the first sector of the floppy disk the 'conv=notrunc' command parameter: (And other command parameters.)
https://imgur.com/6DpF2z6


Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? (strange ??
PostPosted: Fri Jun 08, 2018 7:55 pm 
Offline
Member
Member

Joined: Sat Jul 02, 2016 7:02 am
Posts: 96
Thanks for the details. I do not think you missed anything - the dd program you use does not do any CONVersions. It says as much on its website. I was under the impression that it is the same as the GNU Coreutils dd, which does truncate the output file if conv=notrunc is not specified.

I would also check if the file is not sparse, though I am not familiar with Windows tools. IIRC, Right Click -> Properties would show the two types of file sizes for a sparse file. In your case, it is likely that both the sizes are same (or that it reports only a single size if the file is not a sparse file at all).

Other than that, the earlier suggestion of creating a valid disk using ImDisk and then manually copying over the fields of the boot sector can help narrow down the issue.

You could also try Bochs or QEMU to see if they report any problems with the disk.

Since it is a small file, may be you could upload it somewhere for us to see?


Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? (strange ??
PostPosted: Fri Jun 08, 2018 8:59 pm 
Offline
User avatar

Joined: Wed Jun 06, 2018 9:15 pm
Posts: 15
Yes, it's not a sparse file; at least from what I can see of the file. Windows says that the 'Size' and the 'Size on disk' is exactly the following: 1.40 MB (1,474,560 bytes)

If I use ImDisk to make a working floppy disk, it all works fine. But after I create it, Windows wants me format it. So if I do format it with FAT, then Windows recognized it fine. I can add files all I want. But it adds a bunch of extra stuff onto the disk's first sector. If I try to burn by boot loader onto that drive, then that's where crap hits the fan. My testing programs, mainly VirtualBox, crashes when booting from 'Host Drive (Drive Letter):'. Nothing else will boot it, either But, if I do the above, and do not format the drive, the VirtualBox loads and it works all dandy fine. Yet I cannot format the drive, for the reasons above. And it's a never ending nightmare. lol

Also, QEMU and Bochs are not going to boot my Host Drive. I'm trying everything I can right now. They're just not having any.

Here is some more pictures on what I mean, because I think putting these out there as evidence can help with finding the answer.

Now after I made a fresh drive and mounted it to 'A:', I tried booting it in VirtualBox, and well, this worked, but I cannot do anything: https://imgur.com/LMdSbg2

Now I is more burning the first sector with a disk editing tool called SectEdit:
What a fresh FAT format looks like: https://imgur.com/7vm9CtT

Then I burned it: https://imgur.com/Xhjf8h4

Now VirtualBox crashes horribly by booting from 'Host Drive A:' https://imgur.com/CAzxdb5

And yes, I uploaded the 'floppy.vfd' file, it's up for download: https://ufile.io/7qkfv


Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? (strange ??
PostPosted: Fri Jun 08, 2018 9:22 pm 
Offline
Member
Member

Joined: Sat Jul 02, 2016 7:02 am
Posts: 96
Thanks again.

The image https://imgur.com/Xhjf8h4 shows that the BPB is not in its expected position.

I am not sure how to connect that to the sharing violation error that vbox shows. Sharing violation is when a new open conflicts with the share permissions that an earlier open allows.


Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? (strange ??
PostPosted: Fri Jun 08, 2018 9:49 pm 
Offline
User avatar

Joined: Wed Jun 06, 2018 9:15 pm
Posts: 15
I'll play around with the position of the BPB, but the wiki says that the first three bytes are to just past the disk description. The forth byte in that image is the start of the OEM label/ID; it should be, away. So I'm not sure, honestly.

Also, keep in mind, and for anyone that see's this post, everything I'm mention that won't work for me right now, works perfectly perfectly on Windows XP (32-bit). My host machine is 64-bit. Maybe that's the problem. I just want to avoid having to share and switch between a virtual machine and all that over and over. Oh, and I should also mention that in the Windows XP virtual machine, the shared folders does not work right. Windows Explorer freezes for nearly 15-20 seconds, (In the virtual machine.) then I try to move or add a file, and Windows Explorer freezes...again. (In the virtual machine.) So that's not happening.


Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? (strange ??
PostPosted: Fri Jun 08, 2018 10:02 pm 
Offline
Member
Member

Joined: Sat Jul 02, 2016 7:02 am
Posts: 96
MSDOSDudeNot wrote:
I'll play around with the position of the BPB, but the wiki says that the first three bytes are to just past the disk description.

If you check the image or the binary, it consumes 4 bytes instead of 3.

Is there any particular reason the vfd needs to be used as a host drive?
vbox and other emulators should be able to parse the file as a floppy image on their own.
The use of ImDisk can be restricted to copying files alone.


Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? (strange ??
PostPosted: Fri Jun 08, 2018 10:37 pm 
Offline
User avatar

Joined: Wed Jun 06, 2018 9:15 pm
Posts: 15
My main reason is so that I can copy the boot files, and then just read the files from the disk. I do not know how it would behave if I just burned the boot files onto the disk. I don't know of any other way to copy files to a disk. If you know, please let me know. I'd love to know. :)

I also fixed the problem. I was thinking to myself, "Hm, I'll look at the very begin and step through what I wrote." Then I studied the first three instructions. I decided to change the directive 'WORD' to the directive 'SHORT', and suddenly, Windows recognized it, and ImDisk can use it now. And the reason it's like that is because I noticed that SectEdit was doing some weird offsetting to the boot loader. If I open it with a hex editor, it shows that it's only taking up three bytes before the OEM label/ID. So my bad for that.


Top
 Profile  
 
 Post subject: Re: Can't put files onto my virtual floppy disk? [solved]
PostPosted: Fri Jun 08, 2018 11:36 pm 
Offline
Member
Member

Joined: Sat Jul 02, 2016 7:02 am
Posts: 96
MSDOSDudeNot wrote:
My main reason is so that I can copy the boot files, and then just read the files from the disk. I do not know how it would behave if I just burned the boot files onto the disk. I don't know of any other way to copy files to a disk. If you know, please let me know. I'd love to know. :)


I understand now :). As long as a filesystem is involved, one cannot avoid attaching/mounting it in order to modify or access the files it manages. Moreover, using a vfd requires you to mount/unmount it through the ImDisk every time a change to the boot files is needed. Instead of that, keeping the vfd mounted and forcing the emulator to utilize the host drive, allows for a more efficient workflow.


MSDOSDudeNot wrote:
I also fixed the problem.

Nice.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group