TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: jari laaksonen
date: 1995-09-23 13:23:14
subject: Bug in Warp Toolkit docs

I posted this way back in July but I didn't see any responses to it, so I'm
posting it again:

The Control Program Guide says that both DosQueryFSInfo and DosSetFSInfo
use FSINFO struct, but the following program shows that DosSetFSInfo uses
VOLUMELABEL struct (if you use FSINFO struct with DosSetFSInfo it returns
154). Under OS/2 2.x both functions used VOLUMELABEL struct.

/* setvol.c
   public domain sample code by Jari Laaksonen, 1995
   fidonet:  2:221/360.20
   internet: jla{at}to.icl.fi
*/

#define INCL_NOPMAPI
#define INCL_DOSFILEMGR
#include 
#include 
#include 

ULONG       DriveNumber;    /* Drive number */
ULONG       FSInfoLevel;    /* File system data type */
ULONG       FSInfoBufSize;  /* File system info buffer size */

int getVolLabel (void)
{
#ifdef __OS2V2X__
  VOLUMELABEL FSInfoBuf;      /* File system info buffer */
#else
  FSINFO      FSInfoBuf;
#endif
  APIRET      rc;             /* Return code */

  FSInfoBufSize = sizeof (FSInfoBuf);

  rc = DosQueryFSInfo (DriveNumber, FSInfoLevel, &FSInfoBuf, FSInfoBufSize);

#ifdef __OS2V2X__
  printf ("Volume Label = %s\n", FSInfoBuf.szVolLabel);
#else
  printf ("Volume Label = %s\n", FSInfoBuf.vol.szVolLabel);
#endif

  printf ("DosQueryFSInfo return code = %d\n", (int)rc);

  return (int) rc;
}

int setVolLabel (char *label)
{
  VOLUMELABEL FSInfoBuf;      /* File system info buffer */
  APIRET      rc;             /* Return code */

  FSInfoBufSize = sizeof (FSInfoBuf);

  strcpy (FSInfoBuf.szVolLabel, label);

  FSInfoBuf.cch = (BYTE) strlen (FSInfoBuf.szVolLabel);
  rc = DosSetFSInfo (DriveNumber, FSInfoLevel, &FSInfoBuf, FSInfoBufSize);

  printf ("DosSetFSInfo return code = %d\n", (int)rc);

  return (int) rc;
}

int main (int argc, char **argv)
{
  int rc;

#ifdef DEBUG
  int i, j;
#endif

  /* Indicate that the caller wants to  change the volume label for the */
  /* specified drive */
  FSInfoLevel = FSIL_VOLSER;

  /* drive A: */
  DriveNumber = 1;

  if (argc == 1)
  {
    rc = getVolLabel();
    return rc;
  }

#ifdef DEBUG
  for (j = 1; j < argc; j++)
    for (i = 0; i < strlen (argv[j]); i++)
      printf ("argv[%d][%d] = %c (%d)\n", j, i, argv[j][i], argv[j][i]);
#endif

  if (argc == 2)
  {
#ifdef DEBUG
    printf ("Volume Label = %s\n", argv[1]);
#endif

    /* The new volume label for logical drive A: */
    if (argv[1][0] == '\"' && argv[1][1] == '\"')
      rc = setVolLabel ("");
    else
      rc = setVolLabel (argv[1]);
  }
  else
  {
    printf ("USAGE: setvol \n");
    return 1;
  }

  return rc;
}

        // Albert  (Team OS/2)         email: jla{at}to.icl.fi

---  UNREG
* Origin: Finland, Ice Hockey World Champion '95 (2:221/360.20)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 221/360 0 220/841 201/2104 109/347 716 3615/50 396/1 270/101 105/103
@PATH: 105/42 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.