Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-05-04 07:24:35 +0400
committerChristopher Faylor <me@cgf.cx>2002-05-04 07:24:35 +0400
commit8761c1dcf7378b6ce9dff32ef7537b113a25a48c (patch)
treef8b6d3705cc727eefa00254eea9387fe04ca7be3 /winsup/cygwin/fhandler_process.cc
parent4b3f6588fb1d23cc1df0fea05804875e7c69a7f1 (diff)
* 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.
Diffstat (limited to 'winsup/cygwin/fhandler_process.cc')
-rw-r--r--winsup/cygwin/fhandler_process.cc42
1 files changed, 23 insertions, 19 deletions
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index b51b17628..7f68d4a2f 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -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;