DosSetFSInfo: Difference between revisions
Appearance
m Ak120 moved page OS2 API:CPI:DosSetFSInfo to DosSetFSInfo |
mNo edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Sets information for a file system device. | Sets information for a file system device. | ||
==Syntax== | ==Syntax== | ||
DosSetFSInfo(disknum, infolevel, pBuf, cbBuf) | |||
==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. | ||
:Level 2 Information - Level 2 information is returned in the format of an [[FSINFO]] structure. | |||
; pBuf (PVOID) - input : Address of the storage area where the system gets the new file system information. | ;cbBuf (ULONG) - input : The length, in bytes, of pBuf. | ||
==Return Code== | ==Return Code== | ||
;ulrc (APIRET) - returns:DosSetFSInfo returns one of the following values: | |||
* 0 NO_ERROR | |||
DosSetFSInfo returns one of the following values: | * 15 ERROR_INVALID_DRIVE | ||
* 82 ERROR_CANNOT_MAKE | |||
* 0 | * 122 ERROR_INSUFFICIENT_BUFFER | ||
* 15 | * 123 ERROR_INVALID_NAME | ||
* 82 | * 124 ERROR_INVALID_LEVEL | ||
* 122 | * 154 ERROR_LABEL_TOO_LONG | ||
* 123 | |||
* 124 | |||
* 154 | |||
==Remarks== | ==Remarks== | ||
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 54: | 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 */ | |||
strcpy(FSInfoBuf.szVolLabel, "MYDISK"); /* Change vol label to MYDISK */ | |||
FSInfoBuf.cch = (BYTE) strlen(FSInfoBuf.szVolLabel); | |||
strcpy(FSInfoBuf.szVolLabel, "MYDISK"); /* Change vol label to MYDISK */ | |||
FSInfoBuf.cch = (BYTE) strlen(FSInfoBuf.szVolLabel); | |||
rc = DosSetFSInfo(DriveNumber, /* Drive number */ | 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) { | if (rc != NO_ERROR) { | ||
printf("DosSetFSInfo error: return code = %u\n", rc); | |||
return 1; | |||
} | } | ||
return NO_ERROR; | |||
return NO_ERROR; | |||
} | } | ||
</PRE> | |||
==Related Functions== | ==Related Functions== | ||
* [[ | * [[DosQueryCurrentDisk]] | ||
* [[ | * [[DosQueryFSInfo]] | ||
* [[ | * [[DosQuerySysInfo]] | ||
* [[ | * [[DosSetDefaultDisk]] | ||
[[Category: | [[Category:Dos]] |
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; }