* 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.
This commit is contained in:
		| @@ -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>. | ||||
| @@ -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> | ||||
|  | ||||
| @@ -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. | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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. | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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) | ||||
| { | ||||
|   | ||||
| @@ -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)]; | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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))); | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user