Jump to content

DosSetFSInfo: Difference between revisions

From EDM2
Ak120 (talk | contribs)
Ak120 (talk | contribs)
mNo edit summary
 
Line 2: Line 2:


==Syntax==
==Syntax==
<PRE>
DosSetFSInfo(disknum, infolevel, pBuf, cbBuf)
#define INCL_DOSFILEMGR
#include <os2.h>


ULONG    disknum;
ULONG    infolevel;
PVOID    pBuf;
ULONG    cbBuf;
APIRET    ulrc;      /*  Return Code. */
ulrc = DosSetFSInfo(disknum, infolevel, pBuf, cbBuf);
</PRE>
==Parameters==
==Parameters==
;disknum (ULONG) - input : Logical drive number. Zero means the default drive, 1 means drive A, 2 means drive B, 3 means drive C, and so on. This represents the file system driver (FSD) for the media currently in that drive. A value of 0xFFFF means that pBuf contains the ASCIIZ path name of the FSD.
;disknum (ULONG) - input : Logical drive number. Zero means the default drive, 1 means drive A, 2 means drive B, 3 means drive C, and so on. This represents the file system driver (FSD) for the media currently in that drive. A value of 0xFFFF means that pBuf contains the ASCIIZ path name of the FSD.
;infolevel (ULONG) - input : Level of file information to be set. Only a value of 2 (FSIL_VOLSER) may be specified.  
;infolevel (ULONG) - input : Level of file information to be set. Only a value of 2 (FSIL_VOLSER) may be specified.
;pBuf (PVOID) - input : Address of the storage area where the system gets the new file system information.
;pBuf (PVOID) - input : Address of the storage area where the system gets the new file system information.
:Level 2 Information - Level 2 information is returned in the format of an [[FSINFO]] structure.
:Level 2 Information - Level 2 information is returned in the format of an [[FSINFO]] structure.
; cbBuf (ULONG) - input : The length, in bytes, of pBuf.
;cbBuf (ULONG) - input : The length, in bytes, of pBuf.


==Return Code==
==Return Code==
ulrc (APIRET) - returns
;ulrc (APIRET) - returns:DosSetFSInfo returns one of the following values:
DosSetFSInfo returns one of the following values:
* 0  NO_ERROR
* 0  NO_ERROR  
* 15  ERROR_INVALID_DRIVE
* 15  ERROR_INVALID_DRIVE  
* 82  ERROR_CANNOT_MAKE
* 82  ERROR_CANNOT_MAKE  
* 122 ERROR_INSUFFICIENT_BUFFER
* 122 ERROR_INSUFFICIENT_BUFFER  
* 123 ERROR_INVALID_NAME
* 123 ERROR_INVALID_NAME  
* 124 ERROR_INVALID_LEVEL
* 124 ERROR_INVALID_LEVEL  
* 154 ERROR_LABEL_TOO_LONG
* 154 ERROR_LABEL_TOO_LONG


Line 35: Line 24:
Trailing blanks supplied at the time the volume label is defined are not returned by DosQueryFSInfo.
Trailing blanks supplied at the time the volume label is defined are not returned by DosQueryFSInfo.


File-system information can be set only if the volume is opened in a mode that allows write access.  
File-system information can be set only if the volume is opened in a mode that allows write access.


==Example Code==
==Example Code==
Line 47: Line 36:


int main(VOID) {
int main(VOID) {
  ULONG  DriveNumber  = 1;                /* Drive 1=A: 2=B: 3=C: ... */
  VOLUMELABEL FSInfoBuf = {0};              /* File system info buffer */
  APIRET  rc            = NO_ERROR;          /* Return code */


ULONG   DriveNumber  = 1;                    /* Drive 1=A: 2=B: 3=C: ... */
   strcpy(FSInfoBuf.szVolLabel, "MYDISK");    /* Change vol label to MYDISK */
VOLUMELABEL FSInfoBuf = {0};                  /* File system info buffer */
  FSInfoBuf.cch = (BYTE) strlen(FSInfoBuf.szVolLabel);
APIRET  rc            = NO_ERROR;            /* Return code */
 
strcpy(FSInfoBuf.szVolLabel, "MYDISK");    /* Change vol label to MYDISK */
FSInfoBuf.cch = (BYTE) strlen(FSInfoBuf.szVolLabel);
 
rc = DosSetFSInfo(DriveNumber,            /* Drive number */
                  FSIL_VOLSER,            /* Level of information being set */
                  &FSInfoBuf,            /* Address of input buffer */
                  sizeof(VOLUMELABEL) );  /* Buffer size */
if (rc != NO_ERROR) {
  printf("DosSetFSInfo error: return code = %u\n", rc);
  return 1;
}


return NO_ERROR;
  rc = DosSetFSInfo(DriveNumber,            /* Drive number */
                    FSIL_VOLSER,            /* Level of information being set */
                    &FSInfoBuf,            /* Address of input buffer */
                    sizeof(VOLUMELABEL) );  /* Buffer size */
  if (rc != NO_ERROR) {
    printf("DosSetFSInfo error: return code = %u\n", rc);
    return 1;
  }
  return NO_ERROR;
}
}
</PRE>
</PRE>

Latest revision as of 22:08, 27 April 2019

Sets information for a file system device.

Syntax

DosSetFSInfo(disknum, infolevel, pBuf, cbBuf)

Parameters

disknum (ULONG) - input
Logical drive number. Zero means the default drive, 1 means drive A, 2 means drive B, 3 means drive C, and so on. This represents the file system driver (FSD) for the media currently in that drive. A value of 0xFFFF means that pBuf contains the ASCIIZ path name of the FSD.
infolevel (ULONG) - input
Level of file information to be set. Only a value of 2 (FSIL_VOLSER) may be specified.
pBuf (PVOID) - input
Address of the storage area where the system gets the new file system information.
Level 2 Information - Level 2 information is returned in the format of an FSINFO structure.
cbBuf (ULONG) - input
The length, in bytes, of pBuf.

Return Code

ulrc (APIRET) - returns
DosSetFSInfo returns one of the following values:
  • 0 NO_ERROR
  • 15 ERROR_INVALID_DRIVE
  • 82 ERROR_CANNOT_MAKE
  • 122 ERROR_INSUFFICIENT_BUFFER
  • 123 ERROR_INVALID_NAME
  • 124 ERROR_INVALID_LEVEL
  • 154 ERROR_LABEL_TOO_LONG

Remarks

Trailing blanks supplied at the time the volume label is defined are not returned by DosQueryFSInfo.

File-system information can be set only if the volume is opened in a mode that allows write access.

Example Code

This example shows how to label the disk in drive "A" as "MYDISK". Before running this program, make sure that there is a disk in the drive.

#define INCL_DOSFILEMGR         /* File Manager values */
#define INCL_DOSERRORS          /* DOS Error values */
#include <os2.h>
#include <stdio.h>
#include <string.h>

int main(VOID) {
  ULONG   DriveNumber   = 1;                 /* Drive 1=A: 2=B: 3=C: ... */
  VOLUMELABEL FSInfoBuf = {0};               /* File system info buffer */
  APIRET  rc            = NO_ERROR;          /* Return code */

  strcpy(FSInfoBuf.szVolLabel, "MYDISK");    /* Change vol label to MYDISK */
  FSInfoBuf.cch = (BYTE) strlen(FSInfoBuf.szVolLabel);

  rc = DosSetFSInfo(DriveNumber,            /* Drive number */
                    FSIL_VOLSER,            /* Level of information being set */
                    &FSInfoBuf,             /* Address of input buffer */
                    sizeof(VOLUMELABEL) );  /* Buffer size */
  if (rc != NO_ERROR) {
    printf("DosSetFSInfo error: return code = %u\n", rc);
    return 1;
  }
  return NO_ERROR;
}

Related Functions