* 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>
* fhandler_tape.cc (fhandler_dev_tape::open): Fix memory allocation.

View File

@ -403,6 +403,8 @@ public:
int dup (fhandler_base *child);
int ioctl (unsigned int cmd, void *buf);
void fixup_after_fork (HANDLE);
};
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 ();
this->unit = unit;
set_need_fork_fixup ();
}
fhandler_dev_raw::~fhandler_dev_raw (void)
{
if (devbufsiz >= 1L)
cfree (devbuf);
if (devbufsiz > 1L)
delete [] devbuf;
clear ();
}
@ -139,7 +140,7 @@ fhandler_dev_raw::open (const char *path, int flags, mode_t)
if (ret)
{
if (devbufsiz > 1L)
devbuf = (char *) cmalloc (HEAP_BUF, devbufsiz);
devbuf = new char [devbufsiz];
}
else
devbufsiz = 0;
@ -444,21 +445,28 @@ fhandler_dev_raw::dup (fhandler_base *child)
fhc->devbufsiz = devbufsiz;
if (devbufsiz > 1L)
{
fhc->devbuf = (char *) cmalloc (HEAP_BUF, devbufsiz);
memcpy (fhc->devbuf, devbuf, devbufend);
}
fhc->devbufstart = devbufstart;
fhc->devbufend = devbufend;
fhc->devbuf = new char [devbufsiz];
fhc->devbufstart = 0;
fhc->devbufend = 0;
fhc->eom_detected = eom_detected;
fhc->eof_detected = eof_detected;
fhc->lastblk_to_read = lastblk_to_read;
fhc->lastblk_to_read = 0;
fhc->varblkop = varblkop;
fhc->unit = unit;
}
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
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;
else if (!devbuf || op->rd_parm != devbufsiz)
{
char *buf = (char *) cmalloc (HEAP_BUF, op->rd_parm);
if (devbuf)
char *buf = new char [op->rd_parm];
if (devbufsiz > 1L)
{
memcpy (buf, devbuf + devbufstart, devbufend - devbufstart);
devbufend -= devbufstart;
cfree (devbuf);
delete [] devbuf;
}
else
devbufend = 0;

View File

@ -89,7 +89,7 @@ fhandler_dev_tape::open (const char *path, int flags, mode_t)
varblkop = get.mt_dsreg == 0;
if (devbufsiz > 1L)
devbuf = (char *) cmalloc (HEAP_BUF, devbufsiz);
devbuf = new char [devbufsiz];
/* The following rewind in position 0 solves a problem which appears
* 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;
ret = NO_ERROR;
}
char *buf = (char *) cmalloc (HEAP_BUF, size);
if (!buf)
char *buf = NULL;
if (size > 1L && !(buf = new char [size]))
{
ret = ERROR_OUTOFMEMORY;
break;
}
if (devbuf)
if (devbufsiz > 1L && size > 1L)
{
memcpy(buf,devbuf + devbufstart, devbufend - devbufstart);
memcpy(buf, devbuf + devbufstart,
devbufend - devbufstart);
devbufend -= devbufstart;
cfree (devbuf);
}
else
devbufend = 0;
if (devbufsiz > 1L)
delete [] devbuf;
devbufstart = 0;
devbuf = buf;
devbufsiz = size;