* 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

@ -21,23 +21,27 @@ details. */
#include "pinfo.h"
#include "path.h"
#include "shared_info.h"
#include "dtable.h"
#include "cygheap.h"
#include <assert.h>
#define _COMPILING_NEWLIB
#include <dirent.h>
static const int PROCESS_PPID = 0;
static const int PROCESS_EXENAME = 1;
static const int PROCESS_WINPID = 2;
static const int PROCESS_WINEXENAME = 3;
static const int PROCESS_STATUS = 4;
static const int PROCESS_UID = 5;
static const int PROCESS_GID = 6;
static const int PROCESS_PGID = 7;
static const int PROCESS_SID = 8;
static const int PROCESS_CTTY = 9;
static const int PROCESS_PPID = 2;
static const int PROCESS_EXENAME = 3;
static const int PROCESS_WINPID = 4;
static const int PROCESS_WINEXENAME = 5;
static const int PROCESS_STATUS = 6;
static const int PROCESS_UID = 7;
static const int PROCESS_GID = 8;
static const int PROCESS_PGID = 9;
static const int PROCESS_SID = 10;
static const int PROCESS_CTTY = 11;
static const char *process_listing[] = {
".",
"..",
"ppid",
"exename",
"winpid",
@ -133,13 +137,13 @@ fhandler_process::open (path_conv *pc, int flags, mode_t mode)
if (*path == 0)
{
if ((mode & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
{
set_errno (EEXIST);
res = 0;
goto out;
}
else if (mode & O_WRONLY)
else if (flags & O_WRONLY)
{
set_errno (EISDIR);
res = 0;
@ -161,7 +165,7 @@ fhandler_process::open (path_conv *pc, int flags, mode_t mode)
}
if (process_file_no == -1)
{
if ((mode & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
if (flags & O_CREAT)
{
set_errno (EROFS);
res = 0;
@ -174,7 +178,7 @@ fhandler_process::open (path_conv *pc, int flags, mode_t mode)
goto out;
}
}
if (mode & O_WRONLY)
if (flags & O_WRONLY)
{
set_errno (EROFS);
res = 0;
@ -203,7 +207,7 @@ found:
case PROCESS_CTTY:
case PROCESS_PPID:
{
filebuf = new char[bufalloc = 40];
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc = 40);
int num;
switch (process_file_no)
{
@ -230,7 +234,7 @@ found:
}
case PROCESS_EXENAME:
{
filebuf = new char[bufalloc = MAX_PATH];
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc = MAX_PATH);
if (p->process_state & (PID_ZOMBIE | PID_EXITED))
strcpy (filebuf, "<defunct>");
else
@ -249,7 +253,7 @@ found:
}
case PROCESS_WINPID:
{
filebuf = new char[bufalloc = 40];
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc = 40);
__small_sprintf (filebuf, "%d\n", p->dwProcessId);
filesize = strlen (filebuf);
break;
@ -257,7 +261,7 @@ found:
case PROCESS_WINEXENAME:
{
int len = strlen (p->progname);
filebuf = new char[len + 2];
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc = (len + 2));
strcpy (filebuf, p->progname);
filebuf[len] = '\n';
filesize = len + 1;
@ -265,7 +269,7 @@ found:
}
case PROCESS_STATUS:
{
filebuf = new char[bufalloc = 3];
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc = 3);
filebuf[0] = ' ';
filebuf[1] = '\n';
filebuf[2] = 0;