www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/02/22/06:37:17.1

Date: Mon, 22 Feb 1999 13:27:04 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Martin Str|mberg <ams AT ludd DOT luth DOT se>
cc: DJGPP-WORKERS <djgpp-workers AT delorie DOT com>
Subject: Re: FAT32
In-Reply-To: <199902201452.PAA19233@father.ludd.luth.se>
Message-ID: <Pine.SUN.3.91.990222132640.15762D-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

On Sat, 20 Feb 1999, Martin Str|mberg wrote:

> @@ -100,26 +102,70 @@
>  
>    if (!cdrom_calls_used)
>    {
> -    /* Get free space info from DOS.  */
> -    regs.h.ah = 0x36;		/* DOS Get Free Disk Space call */
> -    regs.h.dl = drive_number + 1;
> -    __dpmi_int(0x21, &regs);
> +      /* Get free space info from DOS.  */
> +      regs.h.ah = 0x36;		/* DOS Get Free Disk Space call */
> +      regs.h.dl = drive_number + 1;
> +      __dpmi_int(0x21, &regs);

Please try to stick to the same whitespace style as in the original
sources.  The above hunk of changes seems to be due to different
amount of whitespace only.  Please avoid that.

> +int main(void)
> +@{
> +  int size;
> +
> +  size = _get_fs_type( 'C' - 'A' + 1 );
> +  if( 0 <= size )
> +  @{
> +    printf("The size of FAT on C: is %d bits.\n", size);
> +  @}
> +
> +  exit(0);
> +@}

This example should use _get_fat_size, not _get_fs_type.

> +/* Returns: 0 == error; 1 == result_str filled in. */
> +int 
> +_get_fs_type( const int drive /* drive number (1=A:). */
> +	    , char *const result_str  /* String to put result in. At least 9 chars long. */

Maybe it's better to return 0 in case of success, -1 otherwise.  It
seems to be more consistent with other library functions which work by
side-effect.

Also, please set errno to ENOSYS if the DOS version is below 4, and to
whatever __doserr_to_errno returns if the version is 4+ but the 216900
call fails.  The docs should mention that errno is set in case of
failure.

> +This function tries to extract the file system type of the drive
> +number @var{drive}, 1 == A:, 2 == B:, etc.

Please document the default drive accessible as zero (both for
_get_fs_type and _get_fat_size).

> +This function will not succeed on DOS version < 4 and is known to have
> +trouble detecting the file system type of disks formatted with a later
> +version of DOS than on the version it is run on. 

I suggest to say a couple of words describing the ``trouble''
mentioned here.  People would like to know what to expect, and perhaps
also how to avoid that.

> +      /* Have we checked this drive for FAT32 yet and it isn't removable? */ 
> +      if( checked & mask
> +       && !( removable & mask ) )
> +      {
> +	return( ( fat32 & mask ) != 0 );
> +      }

Sigh.  Static variables such as `checked', `removable', etc. should be
recomputed if the program rewrites its image and is then restarted
(the case in point is Emacs).  Otherwise, if Emacs is built on a
system with FAT32, the executable will be dumped with the current
drive's bit set in `checked', and will then think that the same drive
on any other system is also FAT32.

To solve this, use the __bss_count variable (see e.g. `putenv.c' or
`_use_lfn.c' in the library sources for examples of its usage).

> +RAM disks.  (This doesn't _have_ to be so, but if it's good enough for
> +Andrew Schulman et al (Undocumented DOS, 2nd edition), we can use this
> +as well.)

Copying comments into Texinfo requires some work ;-):

  This doesn't @emph{have} to be so, but if it's good enough for
  Andrew Schulman et al (@cite{Undocumented DOS, 2nd edition}), we can
  use this as well.)

> +int _media_type( const int drive );
> +@end example
> +
> +@subheading Description
> +
> +This function checks if drive number @var{drive} (. 1 == A:, 2 == B:,
> +etc.) is fixed or removable.

Drive can be zero here as well.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019