* net.cc (getdomainname): Change second argument of getdomainname to size_t.

* fhandler_proc.cc (proc_listing): Add '.' and '..' to directory listing.
(fhandler_proc::open): Change use of mode to flags.  If the file does not exist
already, fail with EROFS if O_CREAT flag is set.  Change EROFS error to EACCES
error when writing to a file.  Use cmalloc to allocate memory for filebuf.
(fhandler_proc::close): Use cfree to free filebuf.
(fhandler_proc::get_proc_fhandler): Properly detect attempts to access unknown
subdir.
* fhandler_process.cc (process_listing): Add '.' and '..' to directory listing.
(fhandler_process::open): Use cmalloc to allocate memory for filebuf.
(fhandler_process::close): Use cfree to free filebuf.
* fhandler_registry.cc (registry_listing): Add .  and '..' to directory
listing.
(fhandler_registry::open): Move check for open for writing before open_key.
Use cmalloc to allocate memory for filebuf.
(fhandler_registry::close): Use cfree to free filebuf.
(fhandler_registry::telldir): Use lower 16 bits of __d_position as position in
directory.
(fhandler_registry::seekdir): Ditto.
* fhandler_virtual.cc (fhandler_virtual::write): Change EROFS error to EACCES
error.
(fhandler_virtual::open): Set the NOHANDLE flag.
(fhandler_virtual::dup): Add call to fhandler_base::dup.  Allocate child's
filebuf using cmalloc.  Copy filebuf from parent to child.
(fhandler_virtual::close): Use cfree to free filebuf.
(fhandler_virtual::~fhandler_virtual): Ditto.
(from Chris Faylor <cgf@redhat.com>).
(fhandler_registry::readdir): Add support for '.' and '..' files in
subdirectories of /proc/registry.
* path.cc (path_conv::check): Do not return ENOENT if a file is not found in
/proc.
This commit is contained in:
Christopher Faylor
2002-05-04 03:24:35 +00:00
parent 4b3f6588fb
commit 8761c1dcf7
7 changed files with 167 additions and 65 deletions

View File

@@ -19,8 +19,8 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
#include "cygheap.h"
#include "shared_info.h"
#include "cygheap.h"
#include <assert.h>
#define _COMPILING_NEWLIB
@@ -34,7 +34,7 @@ fhandler_virtual::fhandler_virtual (DWORD devtype):
fhandler_virtual::~fhandler_virtual ()
{
if (filebuf)
delete filebuf;
cfree (filebuf);
filebuf = NULL;
}
@@ -132,18 +132,25 @@ fhandler_virtual::lseek (__off32_t offset, int whence)
int
fhandler_virtual::dup (fhandler_base * child)
{
fhandler_virtual *fhproc_child = (fhandler_virtual *) child;
fhproc_child->filebuf = new char[filesize];
fhproc_child->bufalloc = fhproc_child->filesize = filesize;
fhproc_child->position = position;
return 0;
int ret = fhandler_base::dup (child);
if (!ret)
{
fhandler_virtual *fhproc_child = (fhandler_virtual *) child;
fhproc_child->filebuf = (char *) cmalloc (HEAP_BUF, filesize);
fhproc_child->bufalloc = fhproc_child->filesize = filesize;
fhproc_child->position = position;
memcpy (fhproc_child->filebuf, filebuf, filesize);
fhproc_child->set_flags (get_flags ());
}
return ret;
}
int
fhandler_virtual::close ()
{
if (filebuf)
delete[]filebuf;
cfree (filebuf);
filebuf = NULL;
bufalloc = -1;
cygwin_shared->delqueue.process_queue ();
@@ -176,7 +183,7 @@ fhandler_virtual::read (void *ptr, size_t len)
int
fhandler_virtual::write (const void *ptr, size_t len)
{
set_errno (EROFS);
set_errno (EACCES);
return -1;
}
@@ -197,6 +204,8 @@ fhandler_virtual::open (path_conv *, int flags, mode_t mode)
set_flags (flags);
set_nohandle (true);
return 1;
}