* Makefile.in (DLL_OFILES): Add fhandler_procsys.o.
* devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
This commit is contained in:
@ -53,28 +53,28 @@ static _off64_t format_process_mounts (void *, char *&);
|
||||
|
||||
static const virt_tab_t process_tab[] =
|
||||
{
|
||||
{ ".", FH_PROCESS, virt_directory, NULL },
|
||||
{ "..", FH_PROCESS, virt_directory, NULL },
|
||||
{ "ppid", FH_PROCESS, virt_file, format_process_ppid },
|
||||
{ "winpid", FH_PROCESS, virt_file, format_process_winpid },
|
||||
{ "winexename", FH_PROCESS, virt_file, format_process_winexename },
|
||||
{ "status", FH_PROCESS, virt_file, format_process_status },
|
||||
{ "uid", FH_PROCESS, virt_file, format_process_uid },
|
||||
{ "gid", FH_PROCESS, virt_file, format_process_gid },
|
||||
{ "pgid", FH_PROCESS, virt_file, format_process_pgid },
|
||||
{ "sid", FH_PROCESS, virt_file, format_process_sid },
|
||||
{ "ctty", FH_PROCESS, virt_file, format_process_ctty },
|
||||
{ "stat", FH_PROCESS, virt_file, format_process_stat },
|
||||
{ "statm", FH_PROCESS, virt_file, format_process_statm },
|
||||
{ "cmdline", FH_PROCESS, virt_file, format_process_cmdline },
|
||||
{ "maps", FH_PROCESS, virt_file, format_process_maps },
|
||||
{ "fd", FH_PROCESSFD, virt_directory, format_process_fd },
|
||||
{ "exename", FH_PROCESS, virt_file, format_process_exename },
|
||||
{ "root", FH_PROCESS, virt_symlink, format_process_root },
|
||||
{ "exe", FH_PROCESS, virt_symlink, format_process_exename },
|
||||
{ "cwd", FH_PROCESS, virt_symlink, format_process_cwd },
|
||||
{ "mounts", FH_PROCESS, virt_file, format_process_mounts },
|
||||
{ NULL, 0, virt_none, NULL }
|
||||
{ _VN ("."), FH_PROCESS, virt_directory, NULL },
|
||||
{ _VN (".."), FH_PROCESS, virt_directory, NULL },
|
||||
{ _VN ("cmdline"), FH_PROCESS, virt_file, format_process_cmdline },
|
||||
{ _VN ("ctty"), FH_PROCESS, virt_file, format_process_ctty },
|
||||
{ _VN ("cwd"), FH_PROCESS, virt_symlink, format_process_cwd },
|
||||
{ _VN ("exe"), FH_PROCESS, virt_symlink, format_process_exename },
|
||||
{ _VN ("exename"), FH_PROCESS, virt_file, format_process_exename },
|
||||
{ _VN ("fd"), FH_PROCESSFD, virt_directory, format_process_fd },
|
||||
{ _VN ("gid"), FH_PROCESS, virt_file, format_process_gid },
|
||||
{ _VN ("maps"), FH_PROCESS, virt_file, format_process_maps },
|
||||
{ _VN ("mounts"), FH_PROCESS, virt_file, format_process_mounts },
|
||||
{ _VN ("pgid"), FH_PROCESS, virt_file, format_process_pgid },
|
||||
{ _VN ("ppid"), FH_PROCESS, virt_file, format_process_ppid },
|
||||
{ _VN ("root"), FH_PROCESS, virt_symlink, format_process_root },
|
||||
{ _VN ("sid"), FH_PROCESS, virt_file, format_process_sid },
|
||||
{ _VN ("stat"), FH_PROCESS, virt_file, format_process_stat },
|
||||
{ _VN ("statm"), FH_PROCESS, virt_file, format_process_statm },
|
||||
{ _VN ("status"), FH_PROCESS, virt_file, format_process_status },
|
||||
{ _VN ("uid"), FH_PROCESS, virt_file, format_process_uid },
|
||||
{ _VN ("winexename"), FH_PROCESS, virt_file, format_process_winexename },
|
||||
{ _VN ("winpid"), FH_PROCESS, virt_file, format_process_winpid },
|
||||
{ NULL, 0, 0, virt_none, NULL }
|
||||
};
|
||||
|
||||
static const int PROCESS_LINK_COUNT =
|
||||
@ -90,7 +90,7 @@ static bool get_mem_values (DWORD dwProcessId, unsigned long *vmsize,
|
||||
* -1 if path is a file, -2 if path is a symlink, -3 if path is a pipe,
|
||||
* -4 if path is a socket.
|
||||
*/
|
||||
int
|
||||
virtual_ftype_t
|
||||
fhandler_process::exists ()
|
||||
{
|
||||
const char *path = get_name ();
|
||||
@ -99,21 +99,20 @@ fhandler_process::exists ()
|
||||
while (*path != 0 && !isdirsep (*path))
|
||||
path++;
|
||||
if (*path == 0)
|
||||
return 2;
|
||||
return virt_rootdir;
|
||||
|
||||
for (int i = 0; process_tab[i].name; i++)
|
||||
virt_tab_t *entry = virt_tab_search (path + 1, true, process_tab,
|
||||
PROCESS_LINK_COUNT);
|
||||
if (entry)
|
||||
{
|
||||
if (!strcmp (path + 1, process_tab[i].name))
|
||||
if (!path[entry->name_len + 1])
|
||||
{
|
||||
fileid = i;
|
||||
return process_tab[i].type;
|
||||
fileid = entry - process_tab;
|
||||
return entry->type;
|
||||
}
|
||||
if (process_tab[i].type == virt_directory
|
||||
&& !strncmp (path + 1, process_tab[i].name,
|
||||
strlen (process_tab[i].name))
|
||||
&& path[1 + strlen (process_tab[i].name)] == '/')
|
||||
if (entry->type == virt_directory)
|
||||
{
|
||||
fileid = i;
|
||||
fileid = entry - process_tab;
|
||||
if (fill_filebuf ())
|
||||
return virt_symlink;
|
||||
/* Check for nameless device entries. */
|
||||
@ -232,8 +231,6 @@ out:
|
||||
int
|
||||
fhandler_process::open (int flags, mode_t mode)
|
||||
{
|
||||
int process_file_no = -1;
|
||||
|
||||
int res = fhandler_virtual::open (flags, mode);
|
||||
if (!res)
|
||||
goto out;
|
||||
@ -267,29 +264,15 @@ fhandler_process::open (int flags, mode_t mode)
|
||||
}
|
||||
}
|
||||
|
||||
process_file_no = -1;
|
||||
for (int i = 0; process_tab[i].name; i++)
|
||||
virt_tab_t *entry;
|
||||
entry = virt_tab_search (path + 1, true, process_tab, PROCESS_LINK_COUNT);
|
||||
if (!entry)
|
||||
{
|
||||
if (path_prefix_p (process_tab[i].name, path + 1,
|
||||
strlen (process_tab[i].name), false))
|
||||
process_file_no = i;
|
||||
set_errno ((flags & O_CREAT) ? EROFS : ENOENT);
|
||||
res = 0;
|
||||
goto out;
|
||||
}
|
||||
if (process_file_no == -1)
|
||||
{
|
||||
if (flags & O_CREAT)
|
||||
{
|
||||
set_errno (EROFS);
|
||||
res = 0;
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
set_errno (ENOENT);
|
||||
res = 0;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
if (process_tab[process_file_no].fhandler == FH_PROCESSFD)
|
||||
if (entry->fhandler == FH_PROCESSFD)
|
||||
{
|
||||
flags |= O_DIROPEN;
|
||||
goto success;
|
||||
@ -301,7 +284,7 @@ fhandler_process::open (int flags, mode_t mode)
|
||||
goto out;
|
||||
}
|
||||
|
||||
fileid = process_file_no;
|
||||
fileid = entry - process_tab;
|
||||
if (!fill_filebuf ())
|
||||
{
|
||||
res = 0;
|
||||
|
Reference in New Issue
Block a user