Mail Archives: djgpp/2000/11/09/12:59:12
> From: ad354 AT FreeNet DOT Carleton DOT CA (James Owens)
> Newsgroups: comp.os.msdos.djgpp
> Date: 9 Nov 2000 14:58:39 GMT
>
> Here are what seem to be the relevant bits of volumelabel():
>
> /*---------------------------------------------------------------------------
> If not previously labelled, write a new label. Otherwise just rename,
> since MS-DOS 2.x has a bug that damages the FAT when the old label is
> deleted.
> ---------------------------------------------------------------------------*/
> regs.h.ah = 0x17; /* FCB rename */
>
> F_intdosx(®s, ®s, &sregs);
> if (regs.h.al) {
> Trace((stderr, "Unable to change volume name (AL = %x)\n",
> regs.h.al));
> retv = 1;
>
>
> F_intdosx is defined thus (for non-Watcom compilers):
>
> # define F_intdosx(ir,or,sr) intdosx(ir, or, sr)
Are you sure that the above definition of F_intdosx is used for DJGPP?
If so, that's the bug, right there: intdosx cannot be used in DJGPP to
call DOS functions that need pointers to buffers. (In this case,
function 17h needs a pointer to the FCB, where the old and the new
names are stored.) Unless the code you didn't show uses dosmemput to
copy the FCB into the transfer buffer, and loads the address of the
transfer buffer into DS:DX, this code won't work.
I suggest to rewrite this function for DJGPP as follows (you can read
the details in sections 18.2, 18.4, and 18.5 of the FAQ):
#include <dpmi.h>
#include <go32.h>
...
__dpmi_regs r;
dosmemput(FCB, 0x22, __tb);
r.h.ah = 0x17;
r.x.ds = __tb >> 4;
r.x.dx = __tb & 15;
__dpmi_int(0x21, &r);
if (r.h.al) {
Trace((stderr, "Unable to change volume name (AL = %x)\n",
regs.h.al));
retv = 1;
Here FCB should be the buffer where the code creates the File Control
Block (it is no doubt done somewhere in the part that you omitted),
and 0x22 is the size of the FCB that matters for this function.
WARNING: I didn't test this code, so it might be buggy.
- Raw text -