* fhandler.h (fhandler_dev_raw): Add definition for method

`fixup_after_fork'.
        * fhandler_raw.cc (fhandler_dev_raw::fhandler_dev_raw): Add
        `set_need_fixup_after_fork' call.
        (fhandler_dev_raw::~fhandler_dev_raw): Revert to user space
        allocation.
        (fhandler_dev_raw::open): Ditto.
        (fhandler_dev_raw::dup): Ditto. Reset buffer pointer.
        (fhandler_dev_raw::fixup_after_fork): New function.
        * fhandler_tape.cc (fhandler_dev_tape::open): Revert to user space
        memory allocation.
        (fhandler_dev_tape::ioctl): Ditto. Change behaviour on MTSETBLK when
        new size is 1.
This commit is contained in:
Corinna Vinschen 2000-10-31 22:20:59 +00:00
parent 8e32a18e79
commit 7cccedf8de
4 changed files with 47 additions and 19 deletions

View File

@ -1,3 +1,19 @@
Tue Oct 31 22:39:00 2000 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (fhandler_dev_raw): Add definition for method
`fixup_after_fork'.
* fhandler_raw.cc (fhandler_dev_raw::fhandler_dev_raw): Add
`set_need_fixup_after_fork' call.
(fhandler_dev_raw::~fhandler_dev_raw): Revert to user space
allocation.
(fhandler_dev_raw::open): Ditto.
(fhandler_dev_raw::dup): Ditto. Reset buffer pointer.
(fhandler_dev_raw::fixup_after_fork): New function.
* fhandler_tape.cc (fhandler_dev_tape::open): Revert to user space
memory allocation.
(fhandler_dev_tape::ioctl): Ditto. Change behaviour on MTSETBLK when
new size is 1.
Tue Oct 31 20:56:00 2000 Corinna Vinschen <corinna@vinschen.de> Tue Oct 31 20:56:00 2000 Corinna Vinschen <corinna@vinschen.de>
* fhandler_tape.cc (fhandler_dev_tape::open): Fix memory allocation. * fhandler_tape.cc (fhandler_dev_tape::open): Fix memory allocation.

View File

@ -403,6 +403,8 @@ public:
int dup (fhandler_base *child); int dup (fhandler_base *child);
int ioctl (unsigned int cmd, void *buf); int ioctl (unsigned int cmd, void *buf);
void fixup_after_fork (HANDLE);
}; };
class fhandler_dev_floppy: public fhandler_dev_raw class fhandler_dev_floppy: public fhandler_dev_raw

View File

@ -117,12 +117,13 @@ fhandler_dev_raw::fhandler_dev_raw (DWORD devtype, const char *name, int unit) :
{ {
clear (); clear ();
this->unit = unit; this->unit = unit;
set_need_fork_fixup ();
} }
fhandler_dev_raw::~fhandler_dev_raw (void) fhandler_dev_raw::~fhandler_dev_raw (void)
{ {
if (devbufsiz >= 1L) if (devbufsiz > 1L)
cfree (devbuf); delete [] devbuf;
clear (); clear ();
} }
@ -139,7 +140,7 @@ fhandler_dev_raw::open (const char *path, int flags, mode_t)
if (ret) if (ret)
{ {
if (devbufsiz > 1L) if (devbufsiz > 1L)
devbuf = (char *) cmalloc (HEAP_BUF, devbufsiz); devbuf = new char [devbufsiz];
} }
else else
devbufsiz = 0; devbufsiz = 0;
@ -444,21 +445,28 @@ fhandler_dev_raw::dup (fhandler_base *child)
fhc->devbufsiz = devbufsiz; fhc->devbufsiz = devbufsiz;
if (devbufsiz > 1L) if (devbufsiz > 1L)
{ fhc->devbuf = new char [devbufsiz];
fhc->devbuf = (char *) cmalloc (HEAP_BUF, devbufsiz); fhc->devbufstart = 0;
memcpy (fhc->devbuf, devbuf, devbufend); fhc->devbufend = 0;
}
fhc->devbufstart = devbufstart;
fhc->devbufend = devbufend;
fhc->eom_detected = eom_detected; fhc->eom_detected = eom_detected;
fhc->eof_detected = eof_detected; fhc->eof_detected = eof_detected;
fhc->lastblk_to_read = lastblk_to_read; fhc->lastblk_to_read = 0;
fhc->varblkop = varblkop; fhc->varblkop = varblkop;
fhc->unit = unit; fhc->unit = unit;
} }
return ret; return ret;
} }
void
fhandler_dev_raw::fixup_after_fork (HANDLE)
{
if (devbufsiz > 1L)
devbuf = new char [devbufsiz];
devbufstart = 0;
devbufend = 0;
lastblk_to_read = 0;
}
int int
fhandler_dev_raw::ioctl (unsigned int cmd, void *buf) fhandler_dev_raw::ioctl (unsigned int cmd, void *buf)
{ {
@ -488,12 +496,12 @@ fhandler_dev_raw::ioctl (unsigned int cmd, void *buf)
ret = ERROR_INVALID_PARAMETER; ret = ERROR_INVALID_PARAMETER;
else if (!devbuf || op->rd_parm != devbufsiz) else if (!devbuf || op->rd_parm != devbufsiz)
{ {
char *buf = (char *) cmalloc (HEAP_BUF, op->rd_parm); char *buf = new char [op->rd_parm];
if (devbuf) if (devbufsiz > 1L)
{ {
memcpy (buf, devbuf + devbufstart, devbufend - devbufstart); memcpy (buf, devbuf + devbufstart, devbufend - devbufstart);
devbufend -= devbufstart; devbufend -= devbufstart;
cfree (devbuf); delete [] devbuf;
} }
else else
devbufend = 0; devbufend = 0;

View File

@ -89,7 +89,7 @@ fhandler_dev_tape::open (const char *path, int flags, mode_t)
varblkop = get.mt_dsreg == 0; varblkop = get.mt_dsreg == 0;
if (devbufsiz > 1L) if (devbufsiz > 1L)
devbuf = (char *) cmalloc (HEAP_BUF, devbufsiz); devbuf = new char [devbufsiz];
/* The following rewind in position 0 solves a problem which appears /* The following rewind in position 0 solves a problem which appears
* in case of multi volume archives: The last ReadFile on first medium * in case of multi volume archives: The last ReadFile on first medium
@ -349,20 +349,22 @@ fhandler_dev_tape::ioctl (unsigned int cmd, void *buf)
size = get.mt_maxblksize; size = get.mt_maxblksize;
ret = NO_ERROR; ret = NO_ERROR;
} }
char *buf = (char *) cmalloc (HEAP_BUF, size); char *buf = NULL;
if (!buf) if (size > 1L && !(buf = new char [size]))
{ {
ret = ERROR_OUTOFMEMORY; ret = ERROR_OUTOFMEMORY;
break; break;
} }
if (devbuf) if (devbufsiz > 1L && size > 1L)
{ {
memcpy(buf,devbuf + devbufstart, devbufend - devbufstart); memcpy(buf, devbuf + devbufstart,
devbufend - devbufstart);
devbufend -= devbufstart; devbufend -= devbufstart;
cfree (devbuf);
} }
else else
devbufend = 0; devbufend = 0;
if (devbufsiz > 1L)
delete [] devbuf;
devbufstart = 0; devbufstart = 0;
devbuf = buf; devbuf = buf;
devbufsiz = size; devbufsiz = size;