VOGONS


First post, by ErikGG

User metadata
Rank Member
Rank
Member

-size 4025,127,16513,1700

870MB = 4025 * 127 * 16513 *1700
or
870MB = 127 * 16513 *1700 * 512

Well I thought I figured it out :

http://en.wikipedia.org/wiki/Cylinder-head-sector

but nothing is lesser from the trueth.

Need help on this, as I'm currently building it into D.O.G.

Erik.

Read the new FAQ.doc

Reply 1 of 13, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

ignore the 16513
that is the total "size" of the hdd
you will get 880 MB in marketing terms 😉

Water flows down the stream
How to ask questions the smart way!

Reply 2 of 13, by ErikGG

User metadata
Rank Member
Rank
Member

So
4025 * 127 * 1700 = 829MB

how should the heads part be calculated or is it something that is currently ignored?

I guess 16513 heads is a bit unrealistic, isn't it?

The sectorsperhead must be below the 256?

Erik.

Read the new FAQ.doc

Reply 3 of 13, by MiniMax

User metadata
Rank Moderator
Rank
Moderator

I took at look in dos_programs.cpp and drive_fat.cpp.

drive_fat.cpp defines a fatDrive function that reads:

fatDrive::fatDrive(const char *sysFilename,
Bit32u bytesector, Bit32u cylsector, Bit32u headscyl, Bit32u cylinders,
Bit32u startSector)

and programs_dos.cpp contains these bits for the MOUNT command:

if (type=="floppy") {
str_size="512,1,2847,2847";/* All space free */
mediaid=0xF0; /* Floppy 1.44 media */

} else if (type=="dir") {
str_size="512,127,16513,1700";
mediaid=0xF8; /* Hard Disk */

} else if (type=="cdrom") {
str_size="650,127,16513,1700";
mediaid=0xF8; /* Hard Disk */

But exactly what these numbers represent is a mystery to me. 😒

DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Fedora 32

Reply 4 of 13, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

hmm, just to save you some time, CVS and thus I think the next version of Dosbox has a new size option called autosize. helps a lot 😀

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 5 of 13, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

The str_size= things seem wrong.
How it should read, for example a 1440floppy: 512, 1, 2880, freesize
512 (bytes per sector)
1 (sectors per cluster)
2880 (total sectors, ==80*18*2, 80=cylinders, 18=sectors, 2=heads)
-> total size=512*1*2880= ~1.4mb

and similar for harddisks, just that spc!=1 for them due to their size.

Constraints:
spc between 1 and 254
bps almost always 512, except for cdroms (2048 or 2352 or whatever)
total sectors between 1 and 65535

The freesize parameter is (should be) in mb.

Reply 6 of 13, by MiniMax

User metadata
Rank Moderator
Rank
Moderator

sectors per cluster?? I understand the cylinders * heads * sectors per tracks => total number of sectors (80 * 2 * 18 = 2880). But why the cluster thing?

DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Fedora 32

Reply 7 of 13, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Maybe ask microsoft. Clusters are a logical entity, to keep the fat
small or something like that. c/h/s are physical entities.

Reply 8 of 13, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Instead of "total sectors" it should read "total clusters" in the above lists,
that seems to make a bit more sense.

Reply 9 of 13, by MiniMax

User metadata
Rank Moderator
Rank
Moderator

No. Still don't make sense.

http://en.wikipedia.org/wiki/Cluster_%28file_system%29

Edit: Ahh - or maybe it does. It is one thing to be able to define a disk in terms of C/H/S but it is a different thing if said disk will be fully usable by a FAT16 file system since the FAT works with numbered clusters. And that cluster-number need to fit in a 16 bit number: total clusters between 1 and 65535

So the extra non-CHS parameter probably provides information to DOSBox on how to interpret the File Allocation Table on the image and to calculate the starting point of the first sector in a cluster.

Edit 2: I think that the 127 in the code above means 127 sectors per cluster. With a sector size of 512 bytes, that gives a cluster-size of 35,512, very close to a 32 KB cluster-size which should be okay for a FAT16 file system?

Last edited by MiniMax on 2007-06-29, 20:38. Edited 1 time in total.

DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Fedora 32

Reply 10 of 13, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

c/h/s fully define the geometry of the disk, but being able to reference every
sector would require a very large fat. Thus sectors are grouped into clusters.

The cluster value specified is not used (the "real" value is derived from the
boot sector or so) but only saved to be returned by some dos function (1b/1c).

Reply 11 of 13, by ErikGG

User metadata
Rank Member
Rank
Member

After some digging through the DOSBox source this is what I concluded :

First proc mount in dos_programs.cpp :

cmd->FindString("-size",str_size,true);
char number[20];const char * scan=str_size.c_str();
Bitu index=0;Bitu count=0;
/* Parse the str_size string */
while (*scan) {
if (*scan==',') {
number[index]=0;sizes[count++]=atoi(number);
index=0;
} else number[index++]=*scan;
scan++;
}
number[index]=0;sizes[count++]=atoi(number);

Secondly proc mount also in dos_programs.cpp :

				/* Give a warning when mount c:\ or the / */
#if defined (WIN32) || defined(OS2)
if( (temp_line == "c:\\") || (temp_line == "C:\\")) WriteOut(MSG_Get("PROGRAM_MOUNT_WARNING_WIN"));
#else
if(temp_line == "/") WriteOut(MSG_Get("PROGRAM_MOUNT_WARNING_OTHER"));
#endif
newdrive=new localDrive(temp_line.c_str(),sizes[0],bit8size,sizes[2],sizes[3],mediaid);
}
} else {
WriteOut(MSG_Get("PROGRAM_MOUNT_ILL_TYPE"),type.c_str());
return;
}

Third localdrive in drive_local.cpp :

localDrive::localDrive(const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid) {
strcpy(basedir,startdir);
sprintf(info,"local directory %s",startdir);
allocation.bytes_sector=_bytes_sector;
allocation.sectors_cluster=_sectors_cluster;
allocation.total_clusters=_total_clusters;
allocation.free_clusters=_free_clusters;
allocation.mediaid=_mediaid;

dirCache.SetBaseDir(basedir);
}

Fourth in drive_local.cpp :

bool localDrive::AllocationInfo(Bit16u * _bytes_sector,Bit8u * _sectors_cluster,Bit16u * _total_clusters,Bit16u * _free_clusters) {
/* Always report 100 mb free should be enough */
/* Total size is always 1 gb */
*_bytes_sector=allocation.bytes_sector;
*_sectors_cluster=allocation.sectors_cluster;
*_total_clusters=allocation.total_clusters;
*_free_clusters=allocation.free_clusters;
return true;
};

Fifth in the DIR command in shell_cmds.cpp :

/* Show the summary of results */
FormatNumber(byte_count,numformat);
WriteOut(MSG_Get("SHELL_CMD_DIR_BYTES_USED"),file_count,numformat);
Bit8u drive=dta.GetSearchDrive();
//TODO Free Space
Bitu free_space=1024*1024*100;
if (Drives[drive]) {
Bit16u bytes_sector;Bit8u sectors_cluster;Bit16u total_clusters;Bit16u free_clusters;
Drives[drive]->AllocationInfo(&bytes_sector,&sectors_cluster,&total_clusters,&free_clusters);
[u][b]free_space=bytes_sector*sectors_cluster*free_clusters;[/b][/u]
}
FormatNumber(free_space,numformat);
WriteOut(MSG_Get("SHELL_CMD_DIR_BYTES_FREE"),dir_count,numformat);
dos.dta(save_dta);
}

So we can conclude from the CMD Dir that
free_space=bytes_sector*sectors_cluster*free_clusters;
and that the numbers aren't restricted besides their varsize.

Edit : also the autosize is a neet feature but I guess the size function still exists? Never checked.

Erik.

Read the new FAQ.doc

Reply 12 of 13, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

-size is still there, but it's a lot easier to just type "imgmount c xyz.img" imo

Reply 13 of 13, by ErikGG

User metadata
Rank Member
Rank
Member

True if your typing it manually, I aint.... 😉

But then you need to know how to create an img, this remembers me, I still need to add bochs image creator to D.O.G.'s plugins... So much to add and to do ...

I'm going to fiddle around with it some more, hope I have some results this evening implementing the feature.

Erik.

Read the new FAQ.doc