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-02 08:13:48 +0400
committerChristopher Faylor <me@cgf.cx>2002-05-02 08:13:48 +0400
commit291be3076b91e2165b6c9aecf89d7e767afa89d7 (patch)
tree0da562f5dfc2f8f7e63bb335aff79ddd60429aca /winsup/cygwin
parente1377e380f8dc4ee26802a3b15ce94ebf629c64c (diff)
* path.h (pathconv_arg): Add PC_POSIX.
(path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog96
-rw-r--r--winsup/cygwin/Makefile.in21
-rw-r--r--winsup/cygwin/cygheap.h1
-rw-r--r--winsup/cygwin/dtable.cc13
-rw-r--r--winsup/cygwin/fhandler.cc3
-rw-r--r--winsup/cygwin/fhandler.h89
-rw-r--r--winsup/cygwin/path.cc56
-rw-r--r--winsup/cygwin/path.h12
-rw-r--r--winsup/cygwin/pinfo.h2
-rw-r--r--winsup/cygwin/syscalls.cc8
-rw-r--r--winsup/cygwin/winsup.h3
11 files changed, 240 insertions, 64 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 7c80413a5..d5fea8fab 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,45 @@
+2002-05-02 Christopher Faylor <cgf@redhat.com>
+
+ * path.h (pathconv_arg): Add PC_POSIX.
+ (path_conv): Add normalized_path field.
+ * path.cc (path_conv::~path_conv): New destructor.
+ (path_conv::check): Set normalized_path, where appropriate.
+ * dtable.cc (build_fhandler_from_name): Use normalized path from
+ path_conv.
+ * syscalls.cc (chroot): Ditto.
+
+ * cygheap.h: Remove path_prefix_p declaration.
+
+2002-02-26 Christopher January <chris@atomice.net>
+ Christopher Faylor <cgf@redhat.com> (minor fixups)
+
+ * Makefile.in: Add fhandler_proc.o, fhandler_registry.o,
+ fhandler_process.o and fhandler_virtual.o.
+ * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC,
+ FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix
+ path.
+ * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS.
+ Add class declarations for fhandler_virtual, fhandler_proc,
+ fhandler_registry and fhandler_virtual. Update fhandler_union
+ accordingly.
+ * fhandler_proc.cc: New file. Add implementation for fhandler_proc.
+ * fhandler_virtual.cc: New file. Add implementation for
+ fhandler_virtual.
+ * fhandler_process.cc: New file. Add implementation for
+ fhandler_process.
+ * fhandler_registry.cc: New file. Add implementation for
+ fhandler_registry.
+ * path.cc: Add isproc and isvirtual_dev macros.
+ * path.cc (path_conv::check): Add check for virtual devices.
+ * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to
+ empty Win32 paths.
+ * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic
+ isvirtual_dev macro. Force setting of posix path for virtual
+ fhandlers.
+ * path.h: Add externally visible path_prefix_p and
+ normalized_posix_path prototypes.
+
+
Wed May 1 16:06:02 2002 Jason Tishler <jason@tishler.net>
* include/cygwin/types.h: Include <sys/sysmacros.h>.
@@ -14,7 +56,7 @@ Wed Apr 17 11:27:04 2002 Jason Tishler <jason@tishler.net>
2002-04-12 Egor Duda <deo@logos-m.ru>
- * fhandler.h (class fhandler_socket): New member to store socket type.
+ * fhandler.h (class fhandler_socket): New member to store socket type.
(fhandler_socket::get_socket_type): Access it.
(fhandler_socket::set_socket_type): Ditto.
* net.cc (cygwin_socket): Store socket type.
@@ -55,7 +97,7 @@ Wed Apr 17 11:27:04 2002 Jason Tishler <jason@tishler.net>
2002-03-19 Boris Schaeling <boriss@web.de>
- * poll.cc (poll): Add support for invalid descriptors.
+ * poll.cc (poll): Add support for invalid descriptors.
2002-03-15 Robert Collins <rbtcollins@hotmail.com>
@@ -76,7 +118,7 @@ Wed Apr 17 11:27:04 2002 Jason Tishler <jason@tishler.net>
2002-03-15 Corinna Vinschen <corinna@vinschen.de>
- * glob.c (stat32_to_STAT): New function.
+ * glob.c (stat32_to_STAT): New function.
(g_lstat): Call user space functions always with 32 bit struct stat
as a workaround.
(g_stat): Ditto.
@@ -144,10 +186,10 @@ Wed Apr 17 11:27:04 2002 Jason Tishler <jason@tishler.net>
2002-03-05 Robert Collins <rbtcollins@hotmail.com>
- * cygserver_transport_pipes.cc (transport_layer_pipes::transport_layer_pipes):
+ * cygserver_transport_pipes.cc (transport_layer_pipes::transport_layer_pipes):
Always init - until static members work correctly.
* shm.cc (shmget): Initialize the security descriptor - thanks Corinna!
- * include/sys/ipc.h: Make the ipc control constants partitioned off from the sem
+ * include/sys/ipc.h: Make the ipc control constants partitioned off from the sem
control constants.
2002-03-04 Christian Lestrade <christian.lestrade@free.fr>
@@ -211,7 +253,7 @@ Wed Apr 17 11:27:04 2002 Jason Tishler <jason@tishler.net>
2002-01-17 Robert Collins <rbtcollins@hotmail.com>
- * cygserver.cc (check_and_dup_handle): Consolidate the two variants for
+ * cygserver.cc (check_and_dup_handle): Consolidate the two variants for
simplicity.
Add Some basic debug output.
(client_request_attach_tty::serve): Use the new debug_printf for clarity.
@@ -249,7 +291,7 @@ Mon Oct 8 7:41:00 2001 Robert Collins <rbtcollins@hotmail.com>
* shm.cc: Globally rename client_request_shm_get to client_request_shm.
(client_request_shm::client_request_shm): New constructor for attach requests.
(shmat): Use it.
- * include/cygwin/cygserver_process.h (class process_request): Rename to
+ * include/cygwin/cygserver_process.h (class process_request): Rename to
process_cleanup.
(class cleanup_routine): New class.
(class process): New members and methods to allow calling back when the process
@@ -294,7 +336,7 @@ Tue Oct 2 23:24:00 2001 Robert Collins <rbtcollins@hotmail.com>
(queue_process_param::~queue_process_param): Ditto.
(queue_process_param::start): Ditto.
(queue_process_param::stop): Ditto.
- * threaded_queue.h (class queue_process_param): Add support for
+ * threaded_queue.h (class queue_process_param): Add support for
interruptible request loops.
* cygwin/include/cygwin/cygserver_process.h (class process_cache): Add
destructor.
@@ -312,7 +354,7 @@ Tue Oct 2 23:00:00 2001 Robert Collins <rbtcollins@hotmail.com>
Tue Oct 2 16:06:00 2001 Robert Collins <rbtcollins@hotmail.com>
- * Makefile.in: Remove cygserver_shm.o from cygwin1.dll.
+ * Makefile.in: Remove cygserver_shm.o from cygwin1.dll.
Rename cygserver_shm_outside.o to cygserver_shm.o.
* cygserver.cc (server_request::process): Use the new client_request
constructor.
@@ -322,7 +364,7 @@ Tue Oct 2 16:06:00 2001 Robert Collins <rbtcollins@hotmail.com>
client_request constructor.
(client_request_shutdown::client_request_shutdown): Ditto.
(client_request::client_request): Ditto.
- * cygserver_shm.cc (client_request_shm_get::serve): Remove the
+ * cygserver_shm.cc (client_request_shm_get::serve): Remove the
#ifdef'd stub for in-cygwin builds.
(client_request_shm_get::client_request_shm_get): Use the new
client_request constructor, and remove the in-cygwin variants.
@@ -330,7 +372,7 @@ Tue Oct 2 16:06:00 2001 Robert Collins <rbtcollins@hotmail.com>
serve method - it's only used in cygserver.
* shm.cc (client_request_shm_get::client_request_shm_get): New function.
* include/cygwin/cygserver.h (request_header): New constructor.
- (class client_request): Use it.
+ (class client_request): Use it.
New constructor accepting the header size.
#ifndef test the server method - it's only used within cygserver.
(client_request_get_version): #ifdef test the server method.
@@ -345,7 +387,7 @@ Tue Oct 2 9:57:00 2001 Robert Collins <rbtcollins@hotmail.com>
(class server_process_param): Inherit from queue_process_param.
(class server_request_queue): Inherit from threaded_queue.
(request_loop): Adjust for new types.
- (server_request_queue::process_requests): Remove guts to
+ (server_request_queue::process_requests): Remove guts to
threaded_queue::process_requests.
(server_request::server_request): Adjust for new types.
(worker_function): Delete.
@@ -360,10 +402,10 @@ Mon Oct 1 12:38:00 2001 Robert Collins <rbtcollins@hotmail.com>
* cygserver.cc (client_request::serve): New function.
* cygserver_process.cc: Inlude <pthread.h> for pthread_once.
(process_cache::process_cache): Initialise a crtiical section for write access.
- (process_cache::process): Use the critical section. Also add missing entries to
+ (process_cache::process): Use the critical section. Also add missing entries to
the cache.
(do_process_init): New function to initalise class process static variables.
- (process::process): Ensure that the process access critical section is
+ (process::process): Ensure that the process access critical section is
initialised.
(process::handle): Close the handle of old process's when they have terminated
and we are returning the handle for a process with the same pid.
@@ -372,13 +414,13 @@ Mon Oct 1 12:38:00 2001 Robert Collins <rbtcollins@hotmail.com>
(client_request_shm_get::serve): New parameter for process cache support.
Use the process cache, not OpenProcess to get a handle to the originating process.
Fix a handle leak with token_handle.
- * cygserver_shm.h (class client_request_shm_get): Update ::serve for process
+ * cygserver_shm.h (class client_request_shm_get): Update ::serve for process
cache support.
* cygserver_transport_pipes.cc: Redefine debug_printf to be conditional on DEBUG.
- * include/cygwin/cygserver.h: Do not implement client_request::serve in the
+ * include/cygwin/cygserver.h: Do not implement client_request::serve in the
header.
- * include/cygwin/cygserver_process.h (class process_cache): Add a write access
- critical section to prevent races when requests from a multithreaded
+ * include/cygwin/cygserver_process.h (class process_cache): Add a write access
+ critical section to prevent races when requests from a multithreaded
application arrive.
Sun Sep 30 23:41:00 2001 Robert Collins <rbtcollins@hotmail.com>
@@ -398,7 +440,7 @@ Sun Sep 30 23:41:00 2001 Robert Collins <rbtcollins@hotmail.com>
(server_request_queue::process_requests): Initiator for threaded request loops.
(client_request_shutdown::serve): Add beginning of process cache support.
(server_request::server_request): Ditto.
- (server_request::process): Use debug_printf. Add beginning of process cache
+ (server_request::process): Use debug_printf. Add beginning of process cache
support.
(server_request_queue::cleanup): Kill off any request loop threads.
(server_request_queue::add): Add beginning of process cache support.
@@ -407,7 +449,7 @@ Sun Sep 30 23:41:00 2001 Robert Collins <rbtcollins@hotmail.com>
Add process cache support.
Spawn a separate thread for the transport request loop, thus allowing concurrent
support for multiple transports.
- * cygserver_client.cc (client_request_get_version::serve): Add process cache
+ * cygserver_client.cc (client_request_get_version::serve): Add process cache
support.
(client_request_attach_tty::serve): Add process cache support.
(client_request_shutdown::serve): Add process cache support.
@@ -444,7 +486,7 @@ Sat Sep 29 20:40:00 2001 Robert Collins <rbtcollins@hotmail.com>
(transport_layer_base::read): Ditto.
(transport_layer_base::write): Ditto.
(transport_layer_base::connect): Ditto.
- * cygserver_transport_pipes.cc: Include new header
+ * cygserver_transport_pipes.cc: Include new header
"cygwin/cygserver_transport_pipes.h".
* cygserver_transport_sockets.cc: New file.
* dcrt0.cc: No need to include <sys/socket.h> now.
@@ -846,7 +888,7 @@ Tue Sep 25 16:22:00 2001 Robert Collins <rbtcollins@hotmail.com>
2002-01-21 DJ Delorie <dj@redhat.com>
* Makefile.in (libpthread.a): Pass the assembler also.
- (libm.a): Ditto.
+ (libm.a): Ditto.
(libc.a): Ditto.
* speclib: Specify the assembler to dlltool.
@@ -911,9 +953,9 @@ Tue Sep 25 16:22:00 2001 Robert Collins <rbtcollins@hotmail.com>
2002-01-19 Mark Bradshaw <bradshaw@staff.crosswalk.com>
- * cygwin.din: Add recvmsg and sendmsg.
- * net.cc: Add cygwin_recvmsg and cygwin_sendmsg.
- * /usr/include/sys/socket.h: Add recvmsg and sendmsg.
+ * cygwin.din: Add recvmsg and sendmsg.
+ * net.cc: Add cygwin_recvmsg and cygwin_sendmsg.
+ * /usr/include/sys/socket.h: Add recvmsg and sendmsg.
2002-01-19 Corinna Vinschen <corinna@vinschen.de>
@@ -965,7 +1007,7 @@ Tue Sep 25 16:22:00 2001 Robert Collins <rbtcollins@hotmail.com>
file parameter.
2002-01-09 Christopher Faylor <cgf@redhat.com>
- Robert Collins <rbtcollins@hotmail.com>
+ Robert Collins <rbtcollins@hotmail.com>
* exceptions.cc (early_stuff_init): Rename from misnamed
set_console_handler.
@@ -1042,7 +1084,7 @@ Tue Sep 25 16:22:00 2001 Robert Collins <rbtcollins@hotmail.com>
2002-01-01 Christopher Faylor <cgf@redhat.com>
- * speclib: Remove temp files automatically.
+ * speclib: Remove temp files automatically.
2002-01-01 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (fhandler_socket::sun_path): New private member.
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index b8b2fae00..14d9fbe71 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -123,16 +123,17 @@ DLL_OFILES:=assert.o autoload.o cygheap.o cygserver_client.o cygserver_transport
delqueue.o dir.o dlfcn.o dll_init.o dtable.o environ.o errno.o exceptions.o \
exec.o external.o fcntl.o fhandler.o fhandler_clipboard.o fhandler_console.o \
fhandler_disk_file.o fhandler_dsp.o fhandler_floppy.o fhandler_mem.o \
- fhandler_random.o fhandler_raw.o fhandler_serial.o fhandler_socket.o \
- fhandler_tape.o fhandler_termios.o fhandler_tty.o fhandler_windows.o \
- fhandler_zero.o fnmatch.o fork.o glob.o grp.o heap.o init.o ioctl.o ipc.o \
- localtime.o malloc.o miscfuncs.o mmap.o net.o ntea.o passwd.o path.o \
- pinfo.o pipe.o poll.o pthread.o regcomp.o regerror.o regexec.o \
- regfree.o registry.o resource.o scandir.o sched.o sec_acl.o \
- sec_helper.o security.o select.o shared.o shm.o shortcut.o signal.o \
- sigproc.o smallprint.o spawn.o strace.o strsep.o sync.o syscalls.o \
- sysconf.o syslog.o termios.o thread.o times.o tty.o uinfo.o uname.o \
- v8_regexp.o v8_regerror.o v8_regsub.o wait.o wincap.o window.o \
+ fhandler_proc.o fhandler_process.o fhandler_random.o fhandler_raw.o \
+ fhandler_registry.o fhandler_serial.o fhandler_socket.o \
+ fhandler_tape.o fhandler_termios.o fhandler_tty.o fhandler_virtual.o \
+ fhandler_windows.o fhandler_zero.o fnmatch.o fork.o glob.o grp.o \
+ heap.o init.o ioctl.o ipc.o localtime.o malloc.o miscfuncs.o mmap.o \
+ net.o ntea.o passwd.o path.o pinfo.o pipe.o poll.o pthread.o regcomp.o \
+ regerror.o regexec.o regfree.o registry.o resource.o scandir.o sched.o \
+ sec_acl.o sec_helper.o security.o select.o shared.o shm.o shortcut.o \
+ signal.o sigproc.o smallprint.o spawn.o strace.o strsep.o sync.o \
+ syscalls.o sysconf.o syslog.o termios.o thread.o times.o tty.o uinfo.o \
+ uname.o v8_regexp.o v8_regerror.o v8_regsub.o wait.o wincap.o window.o \
$(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MALLOC_OFILES) $(MT_SAFE_OBJECTS)
GMON_OFILES:=gmon.o mcount.o profil.o
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index ec7624bea..154fd24bf 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -48,7 +48,6 @@ struct cygheap_root_mount_info
/* CGF: FIXME This doesn't belong here */
-int path_prefix_p (const char *path1, const char *path2, int len1) __attribute__ ((regparm (3)));
class cygheap_root
{
/* Root directory information.
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index f70e41599..93d5602fd 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -280,14 +280,14 @@ fhandler_base *
dtable::build_fhandler_from_name (int fd, const char *name, HANDLE handle,
path_conv& pc, unsigned opt, suffix_info *si)
{
- pc.check (name, opt | PC_NULLEMPTY | PC_FULL, si);
+ pc.check (name, opt | PC_NULLEMPTY | PC_FULL | PC_POSIX, si);
if (pc.error)
{
set_errno (pc.error);
return NULL;
}
- return build_fhandler (fd, pc.get_devn (), name, pc, pc.get_unitn ());
+ return build_fhandler (fd, pc.get_devn (), pc.normalized_path, pc, pc.get_unitn ());
}
#define cnew(name) new ((void *) ccalloc (HEAP_FHANDLER, 1, sizeof (name))) name
@@ -363,6 +363,15 @@ dtable::build_fhandler (int fd, DWORD dev, const char *unix_name,
case FH_OSS_DSP:
fh = cnew (fhandler_dev_dsp) ();
break;
+ case FH_PROC:
+ fh = cnew (fhandler_proc) ();
+ break;
+ case FH_REGISTRY:
+ fh = cnew (fhandler_registry) ();
+ break;
+ case FH_PROCESS:
+ fh = cnew (fhandler_process) ();
+ break;
default:
system_printf ("internal error -- unknown device - %p", dev);
fh = NULL;
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index abddc6000..dd7aeb2e7 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -148,7 +148,8 @@ fhandler_base::get_readahead_into_buffer (char *buf, size_t buflen)
/* Record the file name.
Filenames are used mostly for debugging messages, and it's hoped that
in cases where the name is really required, the filename wouldn't ever
- be too long (e.g. devices or some such). */
+ be too long (e.g. devices or some such).
+ The unix_path_name is also used by virtual fhandlers. */
void
fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit)
{
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index cc54024be..aa0b6ccee 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -70,8 +70,11 @@ enum
FH_CLIPBOARD = 0x00000017, /* is a clipboard device */
FH_OSS_DSP = 0x00000018, /* is a dsp audio device */
FH_CYGDRIVE= 0x00000019, /* /cygdrive/x */
+ FH_PROC = 0x0000001a, /* /proc */
+ FH_REGISTRY =0x0000001b, /* /proc/registry */
+ FH_PROCESS = 0x0000001c, /* /proc/<n> */
- FH_NDEV = 0x0000001a, /* Maximum number of devices */
+ FH_NDEV = 0x0000001d, /* Maximum number of devices */
FH_DEVMASK = 0x00000fff, /* devices live here */
FH_BAD = 0xffffffff
};
@@ -100,6 +103,8 @@ enum
extern const char *windows_device_names[];
extern struct __cygwin_perfile *perfile_table;
#define __fmode (*(user_data->fmode_ptr))
+extern const char proc[];
+extern const int proc_len;
class select_record;
class path_conv;
@@ -280,7 +285,7 @@ class fhandler_base
/* fixup fd possibly non-inherited handles after fork */
void fork_fixup (HANDLE parent, HANDLE &h, const char *name);
- virtual int open (path_conv * real_path, int flags, mode_t mode = 0);
+ virtual int open (path_conv *real_path, int flags, mode_t mode = 0);
virtual int close ();
virtual int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
virtual int ioctl (unsigned int cmd, void *);
@@ -512,16 +517,16 @@ class fhandler_dev_tape: public fhandler_dev_raw
public:
fhandler_dev_tape (int unit);
- int open (path_conv *, int flags, mode_t mode = 0);
- int close (void);
+ virtual int open (path_conv *, int flags, mode_t mode = 0);
+ virtual int close (void);
- __off64_t lseek (__off64_t offset, int whence);
+ virtual __off64_t lseek (__off64_t offset, int whence);
- int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
+ virtual int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
- int dup (fhandler_base *child);
+ virtual int dup (fhandler_base *child);
- int ioctl (unsigned int cmd, void *buf);
+ virtual int ioctl (unsigned int cmd, void *buf);
private:
int tape_write_marks (int marktype, DWORD len);
@@ -1034,6 +1039,71 @@ class fhandler_dev_dsp : public fhandler_base
void fixup_after_exec (HANDLE);
};
+class fhandler_virtual : public fhandler_base
+{
+ protected:
+ char *filebuf;
+ int bufalloc, filesize;
+ __off32_t position;
+ public:
+
+ fhandler_virtual (DWORD devtype);
+ virtual ~fhandler_virtual();
+
+ virtual int exists(const char *path);
+ DIR *opendir (path_conv& pc);
+ __off64_t telldir (DIR *);
+ void seekdir (DIR *, __off32_t);
+ void rewinddir (DIR *);
+ int closedir (DIR *);
+ int write (const void *ptr, size_t len);
+ int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
+ __off64_t lseek (__off32_t, int);
+ int dup (fhandler_base * child);
+ int open (path_conv *, int flags, mode_t mode = 0);
+ int close (void);
+ int __stdcall fstat (struct stat *buf, path_conv *pc) __attribute__ ((regparm (3)));
+};
+
+class fhandler_proc: public fhandler_virtual
+{
+ public:
+ fhandler_proc ();
+ fhandler_proc (DWORD devtype);
+ int exists(const char *path);
+ struct dirent *readdir (DIR *);
+ static DWORD get_proc_fhandler(const char *path);
+
+ int open (path_conv *real_path, int flags, mode_t mode = 0);
+ int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
+};
+
+class fhandler_registry: public fhandler_proc
+{
+ public:
+ fhandler_registry ();
+ int exists(const char *path);
+ struct dirent *readdir (DIR *);
+ __off64_t telldir (DIR *);
+ void seekdir (DIR *, __off32_t);
+ void rewinddir (DIR *);
+ int closedir (DIR *);
+
+ int open (path_conv *real_path, int flags, mode_t mode = 0);
+ int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
+ HKEY open_key(const char *name, REGSAM access = KEY_READ, bool isValue = false);
+};
+
+class fhandler_process: public fhandler_proc
+{
+ public:
+ fhandler_process ();
+ int exists(const char *path);
+ struct dirent *readdir (DIR *);
+ int open (path_conv *real_path, int flags, mode_t mode = 0);
+ int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
+};
+
typedef union
{
char base[sizeof(fhandler_base)];
@@ -1049,7 +1119,10 @@ typedef union
char dev_zero[sizeof(fhandler_dev_zero)];
char disk_file[sizeof(fhandler_disk_file)];
char pipe[sizeof(fhandler_pipe)];
+ char proc[sizeof(fhandler_proc)];
+ char process[sizeof(fhandler_process)];
char pty_master[sizeof(fhandler_pty_master)];
+ char registry[sizeof(fhandler_registry)];
char serial[sizeof(fhandler_serial)];
char socket[sizeof(fhandler_socket)];
char termios[sizeof(fhandler_termios)];
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index e95f6caf1..0b5ef06e9 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -118,6 +118,12 @@ int pcheck_case = PCHECK_RELAXED; /* Determines the case check behaviour. */
(isdirsep(path[mount_table->cygdrive_len + 1]) || \
!path[mount_table->cygdrive_len + 1]))
+#define isproc(path) \
+ (path_prefix_p (proc, (path), proc_len))
+
+#define isvirtual_dev(devn) \
+ (devn == FH_CYGDRIVE || devn == FH_PROC || devn == FH_REGISTRY || devn == FH_PROCESS)
+
/* Return non-zero if PATH1 is a prefix of PATH2.
Both are assumed to be of the same path style and / vs \ usage.
Neither may be "".
@@ -173,7 +179,7 @@ pathmatch (const char *path1, const char *path2)
#define isslash(c) ((c) == '/')
-int
+static int
normalize_posix_path (const char *src, char *dst)
{
const char *src_start = src;
@@ -362,6 +368,12 @@ path_conv::update_fs_info (const char* win32_path)
}
}
+path_conv::~path_conv ()
+{
+ if (normalized_path)
+ cfree (normalized_path);
+}
+
/* Convert an arbitrary path SRC to a pure Win32 path, suitable for
passing to Win32 API routines.
@@ -413,6 +425,7 @@ path_conv::check (const char *src, unsigned opt,
sym_opt = 0;
drive_type = 0;
is_remote_drive = 0;
+ normalized_path = NULL;
if (!(opt & PC_NULLEMPTY))
error = 0;
@@ -494,6 +507,28 @@ path_conv::check (const char *src, unsigned opt,
}
goto out;
}
+ else if (isvirtual_dev (devn))
+ {
+ fhandler_virtual *fh =
+ (fhandler_virtual *) cygheap->fdtab.build_fhandler (-1, devn, path_copy, NULL, unit);
+ int file_type = fh->exists (path_copy);
+ switch (file_type)
+ {
+ case 0:
+ error = ENOENT;
+ break;
+ case 1:
+ case 2:
+ fileattr = FILE_ATTRIBUTE_DIRECTORY;
+ break;
+ case -1:
+ fileattr = 0;
+ }
+ delete fh;
+ if (!error)
+ strcpy (path, path_copy);
+ goto out;
+ }
/* devn should not be a device. If it is, then stop parsing now. */
else if (devn != FH_BAD)
{
@@ -683,6 +718,8 @@ path_conv::check (const char *src, unsigned opt,
add_ext_from_sym (sym);
out:
+ if (opt & PC_POSIX)
+ normalized_path = cstrdup (path_copy);
/* Deal with Windows stupidity which considers filename\. to be valid
even when "filename" is not a directory. */
if (!need_directory || error)
@@ -1409,6 +1446,14 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
else if (mount_table->cygdrive_len > 1)
return ENOENT;
}
+ if (isproc (pathbuf))
+ {
+ devn = fhandler_proc::get_proc_fhandler (pathbuf);
+ dst[0] = '\0';
+ if (devn == FH_BAD)
+ return ENOENT;
+ goto out;
+ }
int chrooted_path_len;
chrooted_path_len = 0;
@@ -1476,7 +1521,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
*flags = mi->flags;
}
- if (devn != FH_CYGDRIVE)
+ if (!isvirtual_dev (devn))
win32_device_name (src_path, dst, devn, unit);
out:
@@ -3237,7 +3282,8 @@ chdir (const char *in_dir)
path.get_win32 ()[3] = '\0';
}
int res;
- if (path.get_devn () != FH_CYGDRIVE)
+ int devn = path.get_devn();
+ if (!isvirtual_dev (devn))
res = SetCurrentDirectory (native_dir) ? 0 : -1;
else
{
@@ -3257,8 +3303,8 @@ chdir (const char *in_dir)
we'll see if Cygwin mailing list users whine about the current behavior. */
if (res == -1)
__seterrno ();
- else if (!path.has_symlinks () && strpbrk (dir, ":\\") == NULL
- && pcheck_case == PCHECK_RELAXED)
+ else if ((!path.has_symlinks () && strpbrk (dir, ":\\") == NULL
+ && pcheck_case == PCHECK_RELAXED) || isvirtual_dev (devn))
cygheap->cwd.set (native_dir, dir);
else
cygheap->cwd.set (native_dir, NULL);
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index ea3a6545a..1daaa11d8 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -23,7 +23,8 @@ enum pathconv_arg
PC_SYM_CONTENTS = 0x0008,
PC_FULL = 0x0010,
PC_NULLEMPTY = 0x0020,
- PC_CHECK_EA = 0x0040
+ PC_CHECK_EA = 0x0040,
+ PC_POSIX = 0x0080
};
enum case_checking
@@ -75,6 +76,7 @@ class path_conv
int unit;
DWORD fileattr;
BOOL case_clash;
+ char *normalized_path;
int isdisk () const { return path_flags & PATH_ISDISK;}
int isremote () const {return is_remote_drive;}
@@ -126,9 +128,11 @@ class path_conv
path_conv (): path_flags (0), known_suffix (NULL), error (0), devn (0), unit (0), fileattr (INVALID_FILE_ATTRIBUTES) {path[0] = '\0';}
+ ~path_conv ();
inline char *get_win32 () { return path; }
- operator char *() {return path; }
- operator DWORD &() {return fileattr; }
+ operator char *() {return path;}
+ operator const char *() {return path;}
+ operator DWORD &() {return fileattr;}
operator int &() {return (int) fileattr; }
BOOL is_device () {return devn != FH_BAD && devn != FH_DISK;}
DWORD get_devn () {return devn == FH_BAD ? (DWORD) FH_DISK : devn;}
@@ -178,3 +182,5 @@ has_exec_chars (const char *buf, int len)
int pathmatch (const char *path1, const char *path2) __attribute__ ((regparm (2)));
int pathnmatch (const char *path1, const char *path2, int len) __attribute__ ((regparm (2)));
+
+int path_prefix_p (const char *path1, const char *path2, int len1) __attribute__ ((regparm (3)));
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index dc16966b9..cad2c4a5b 100644
--- a/winsup/cygwin/pinfo.h
+++ b/winsup/cygwin/pinfo.h
@@ -39,7 +39,7 @@ public:
we only use this handle from the parent. */
HANDLE hProcess;
-#define PINFO_REDIR_SIZE ((DWORD) &(((_pinfo *)NULL)->hProcess) + sizeof (DWORD))
+#define PINFO_REDIR_SIZE ((char *) &myself.procinfo->hProcess - (char *) myself.procinfo)
/* Handle associated with initial Windows pid which started it all. */
HANDLE pid_handle;
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 1613d7b8d..b549f9530 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -39,8 +39,6 @@ details. */
#include "shared_info.h"
#include "cygheap.h"
-extern int normalize_posix_path (const char *, char *);
-
SYSTEM_INFO system_info;
/* Close all files and process any queued deletions.
@@ -2207,7 +2205,7 @@ extern "C" int
chroot (const char *newroot)
{
sigframe thisframe (mainthread);
- path_conv path (newroot, PC_SYM_FOLLOW | PC_FULL);
+ path_conv path (newroot, PC_SYM_FOLLOW | PC_FULL | PC_POSIX);
int ret;
if (path.error)
@@ -2224,9 +2222,7 @@ chroot (const char *newroot)
}
else
{
- char buf[MAX_PATH];
- normalize_posix_path (newroot, buf);
- cygheap->root.set (buf, path);
+ cygheap->root.set (path.normalized_path, path);
ret = 0;
}
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index ea9251aaf..1c039a7f1 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -269,6 +269,9 @@ extern SYSTEM_INFO system_info;
#define STD_RBITS (S_IRUSR | S_IRGRP | S_IROTH)
#define STD_WBITS (S_IWUSR)
#define STD_XBITS (S_IXUSR | S_IXGRP | S_IXOTH)
+#define NO_W ~(S_IWUSR | S_IWGRP | S_IWOTH)
+#define NO_R ~(S_IRUSR | S_IRGRP | S_IROTH)
+#define NO_X ~(S_IXUSR | S_IXGRP | S_IXOTH)
/* The title on program start. */
extern char *old_title;