* autoload.cc (GetModuleFileNameExA): Add.
(GetModuleInformation): Add. (QueryWorkingSet): Add. * fhandler.h (fhandler_virtual::get_filebuf): New method. * fhandler_proc.cc (PROC_SELF): Define. (proc_fhandlers): Change type of self to FH_PROC. (fhandler_proc::exists): Return -3 if self. (fhandler_proc::fstat): Handle self as symlink. (fhandler_proc::fill_filebuf): Handle self. * fhandler_process.cc: Include psapi.h. (PROCESS_EXENAME): Remove. (PROCESS_MAPS): Define. (PROCESS_ROOT): Define. (PROCESS_EXE): Define. (PROCESS_CWD): Define. (process_listing): Remove "exename", add "maps, "root", "exe" and "cwd" elements. (fhandler_process::exists): Return -2 for symlinks. (fhandler_process::fstat): Handle symlinks. (fill_filebuf): Evaluate pid if pid is 0. Use exename handling for exe. Handle maps, root and cwd. (format_process_maps): New function evaluating "maps". * path.cc (symlink_info::set): New method to fill symlink_info with data matching virtual symlinks. (path_conv::check): Handle virtual symlinks. * pinfo.cc (_pinfo::commune_recv): Add PICOM_CWD and PICOM_ROOT handling. (_pinfo::commune_send): Ditto. (_pinfo::root): New function. (_pinfo::cwd): New function. * pinfo.h (enum picom): Add PICOM_CWD and PICOM_ROOT. (_pinfo::root): Declare. (_pinfo::cwd): Declare.
This commit is contained in:
@@ -380,6 +380,7 @@ extern char **__argv;
|
||||
void
|
||||
_pinfo::commune_recv ()
|
||||
{
|
||||
char pathbuf[CYG_MAX_PATH];
|
||||
DWORD nr;
|
||||
DWORD code;
|
||||
HANDLE hp;
|
||||
@@ -457,6 +458,32 @@ _pinfo::commune_recv ()
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PICOM_CWD:
|
||||
{
|
||||
unsigned int n = strlen (cygheap->cwd.get (pathbuf, 1, 1, CYG_MAX_PATH)) + 1;
|
||||
CloseHandle (__fromthem); __fromthem = NULL;
|
||||
CloseHandle (hp);
|
||||
if (!WriteFile (__tothem, &n, sizeof n, &nr, NULL))
|
||||
sigproc_printf ("WriteFile sizeof argv failed, %E");
|
||||
else if (!WriteFile (__tothem, pathbuf, n, &nr, NULL))
|
||||
sigproc_printf ("WriteFile sizeof argv failed, %E");
|
||||
break;
|
||||
}
|
||||
case PICOM_ROOT:
|
||||
{
|
||||
unsigned int n;
|
||||
if (cygheap->root.exists ())
|
||||
n = strlen (strcpy (pathbuf, cygheap->root.posix_path ())) + 1;
|
||||
else
|
||||
n = strlen (strcpy (pathbuf, "/")) + 1;
|
||||
CloseHandle (__fromthem); __fromthem = NULL;
|
||||
CloseHandle (hp);
|
||||
if (!WriteFile (__tothem, &n, sizeof n, &nr, NULL))
|
||||
sigproc_printf ("WriteFile sizeof argv failed, %E");
|
||||
else if (!WriteFile (__tothem, pathbuf, n, &nr, NULL))
|
||||
sigproc_printf ("WriteFile sizeof argv failed, %E");
|
||||
break;
|
||||
}
|
||||
case PICOM_FIFO:
|
||||
{
|
||||
char path[CYG_MAX_PATH + 1];
|
||||
@@ -588,6 +615,8 @@ _pinfo::commune_send (DWORD code, ...)
|
||||
switch (code)
|
||||
{
|
||||
case PICOM_CMDLINE:
|
||||
case PICOM_CWD:
|
||||
case PICOM_ROOT:
|
||||
if (!ReadFile (fromthem, &n, sizeof n, &nr, NULL) || nr != sizeof n)
|
||||
{
|
||||
__seterrno ();
|
||||
@@ -654,6 +683,50 @@ out:
|
||||
return res;
|
||||
}
|
||||
|
||||
char *
|
||||
_pinfo::root (size_t& n)
|
||||
{
|
||||
char *s;
|
||||
if (!this || !pid)
|
||||
return NULL;
|
||||
if (pid != myself->pid)
|
||||
{
|
||||
commune_result cr = commune_send (PICOM_ROOT);
|
||||
s = cr.s;
|
||||
n = cr.n;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cygheap->root.exists ())
|
||||
s = strdup (cygheap->root.posix_path ());
|
||||
else
|
||||
s = strdup ("/");
|
||||
n = strlen (s) + 1;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
char *
|
||||
_pinfo::cwd (size_t& n)
|
||||
{
|
||||
char *s;
|
||||
if (!this || !pid)
|
||||
return NULL;
|
||||
if (pid != myself->pid)
|
||||
{
|
||||
commune_result cr = commune_send (PICOM_CWD);
|
||||
s = cr.s;
|
||||
n = cr.n;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = (char *) malloc (CYG_MAX_PATH);
|
||||
cygheap->cwd.get (s, 1, 1, CYG_MAX_PATH);
|
||||
n = strlen (s) + 1;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
char *
|
||||
_pinfo::cmdline (size_t& n)
|
||||
{
|
||||
|
Reference in New Issue
Block a user