* 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> | Wed May  1 16:06:02 2002  Jason Tishler <jason@tishler.net> | ||||||
|  |  | ||||||
| 	* include/cygwin/types.h: Include <sys/sysmacros.h>. | 	* include/cygwin/types.h: Include <sys/sysmacros.h>. | ||||||
|   | |||||||
| @@ -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 \ | 	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 \ | 	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_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_proc.o fhandler_process.o fhandler_random.o fhandler_raw.o \ | ||||||
| 	fhandler_tape.o fhandler_termios.o fhandler_tty.o fhandler_windows.o \ | 	fhandler_registry.o fhandler_serial.o fhandler_socket.o \ | ||||||
| 	fhandler_zero.o fnmatch.o fork.o glob.o grp.o heap.o init.o ioctl.o ipc.o \ | 	fhandler_tape.o fhandler_termios.o fhandler_tty.o fhandler_virtual.o \ | ||||||
| 	localtime.o malloc.o miscfuncs.o mmap.o net.o ntea.o passwd.o path.o \ | 	fhandler_windows.o fhandler_zero.o fnmatch.o fork.o glob.o grp.o \ | ||||||
| 	pinfo.o pipe.o poll.o pthread.o regcomp.o regerror.o regexec.o \ | 	heap.o init.o ioctl.o ipc.o localtime.o malloc.o miscfuncs.o mmap.o \ | ||||||
| 	regfree.o registry.o resource.o scandir.o sched.o sec_acl.o \ | 	net.o ntea.o passwd.o path.o pinfo.o pipe.o poll.o pthread.o regcomp.o \ | ||||||
| 	sec_helper.o security.o select.o shared.o shm.o shortcut.o signal.o \ | 	regerror.o regexec.o regfree.o registry.o resource.o scandir.o sched.o \ | ||||||
| 	sigproc.o smallprint.o spawn.o strace.o strsep.o sync.o syscalls.o \ | 	sec_acl.o sec_helper.o security.o select.o shared.o shm.o shortcut.o \ | ||||||
| 	sysconf.o syslog.o termios.o thread.o times.o tty.o uinfo.o uname.o \ | 	signal.o sigproc.o smallprint.o spawn.o strace.o strsep.o sync.o \ | ||||||
| 	v8_regexp.o v8_regerror.o v8_regsub.o wait.o wincap.o window.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) | 	$(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MALLOC_OFILES) $(MT_SAFE_OBJECTS) | ||||||
|  |  | ||||||
| GMON_OFILES:=gmon.o mcount.o profil.o | GMON_OFILES:=gmon.o mcount.o profil.o | ||||||
|   | |||||||
| @@ -48,7 +48,6 @@ struct cygheap_root_mount_info | |||||||
|  |  | ||||||
| /* CGF: FIXME This doesn't belong here */ | /* 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 | class cygheap_root | ||||||
| { | { | ||||||
|   /* Root directory information. |   /* Root directory information. | ||||||
|   | |||||||
| @@ -280,14 +280,14 @@ fhandler_base * | |||||||
| dtable::build_fhandler_from_name (int fd, const char *name, HANDLE handle, | dtable::build_fhandler_from_name (int fd, const char *name, HANDLE handle, | ||||||
| 				  path_conv& pc, unsigned opt, suffix_info *si) | 				  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) |   if (pc.error) | ||||||
|     { |     { | ||||||
|       set_errno (pc.error); |       set_errno (pc.error); | ||||||
|       return NULL; |       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 | #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: |       case FH_OSS_DSP: | ||||||
| 	fh = cnew (fhandler_dev_dsp) (); | 	fh = cnew (fhandler_dev_dsp) (); | ||||||
| 	break; | 	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: |       default: | ||||||
| 	system_printf ("internal error -- unknown device - %p", dev); | 	system_printf ("internal error -- unknown device - %p", dev); | ||||||
| 	fh = NULL; | 	fh = NULL; | ||||||
|   | |||||||
| @@ -148,7 +148,8 @@ fhandler_base::get_readahead_into_buffer (char *buf, size_t buflen) | |||||||
| /* Record the file name. | /* Record the file name. | ||||||
|    Filenames are used mostly for debugging messages, and it's hoped that |    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 |    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 | void | ||||||
| fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit) | 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_CLIPBOARD = 0x00000017,	/* is a clipboard device */ | ||||||
|   FH_OSS_DSP = 0x00000018,	/* is a dsp audio device */ |   FH_OSS_DSP = 0x00000018,	/* is a dsp audio device */ | ||||||
|   FH_CYGDRIVE= 0x00000019,	/* /cygdrive/x */ |   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_DEVMASK = 0x00000fff,	/* devices live here */ | ||||||
|   FH_BAD     = 0xffffffff |   FH_BAD     = 0xffffffff | ||||||
| }; | }; | ||||||
| @@ -100,6 +103,8 @@ enum | |||||||
| extern const char *windows_device_names[]; | extern const char *windows_device_names[]; | ||||||
| extern struct __cygwin_perfile *perfile_table; | extern struct __cygwin_perfile *perfile_table; | ||||||
| #define __fmode (*(user_data->fmode_ptr)) | #define __fmode (*(user_data->fmode_ptr)) | ||||||
|  | extern const char proc[]; | ||||||
|  | extern const int proc_len; | ||||||
|  |  | ||||||
| class select_record; | class select_record; | ||||||
| class path_conv; | class path_conv; | ||||||
| @@ -280,7 +285,7 @@ class fhandler_base | |||||||
|   /* fixup fd possibly non-inherited handles after fork */ |   /* fixup fd possibly non-inherited handles after fork */ | ||||||
|   void fork_fixup (HANDLE parent, HANDLE &h, const char *name); |   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 close (); | ||||||
|   virtual int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); |   virtual int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); | ||||||
|   virtual int ioctl (unsigned int cmd, void *); |   virtual int ioctl (unsigned int cmd, void *); | ||||||
| @@ -512,16 +517,16 @@ class fhandler_dev_tape: public fhandler_dev_raw | |||||||
|  public: |  public: | ||||||
|   fhandler_dev_tape (int unit); |   fhandler_dev_tape (int unit); | ||||||
|  |  | ||||||
|   int open (path_conv *, int flags, mode_t mode = 0); |   virtual int open (path_conv *, int flags, mode_t mode = 0); | ||||||
|   int close (void); |   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: |  private: | ||||||
|   int tape_write_marks (int marktype, DWORD len); |   int tape_write_marks (int marktype, DWORD len); | ||||||
| @@ -1034,6 +1039,71 @@ class fhandler_dev_dsp : public fhandler_base | |||||||
|   void fixup_after_exec (HANDLE); |   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 | typedef union | ||||||
| { | { | ||||||
|   char base[sizeof(fhandler_base)]; |   char base[sizeof(fhandler_base)]; | ||||||
| @@ -1049,7 +1119,10 @@ typedef union | |||||||
|   char dev_zero[sizeof(fhandler_dev_zero)]; |   char dev_zero[sizeof(fhandler_dev_zero)]; | ||||||
|   char disk_file[sizeof(fhandler_disk_file)]; |   char disk_file[sizeof(fhandler_disk_file)]; | ||||||
|   char pipe[sizeof(fhandler_pipe)]; |   char pipe[sizeof(fhandler_pipe)]; | ||||||
|  |   char proc[sizeof(fhandler_proc)]; | ||||||
|  |   char process[sizeof(fhandler_process)]; | ||||||
|   char pty_master[sizeof(fhandler_pty_master)]; |   char pty_master[sizeof(fhandler_pty_master)]; | ||||||
|  |   char registry[sizeof(fhandler_registry)]; | ||||||
|   char serial[sizeof(fhandler_serial)]; |   char serial[sizeof(fhandler_serial)]; | ||||||
|   char socket[sizeof(fhandler_socket)]; |   char socket[sizeof(fhandler_socket)]; | ||||||
|   char termios[sizeof(fhandler_termios)]; |   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]) || \ |    (isdirsep(path[mount_table->cygdrive_len + 1]) || \ | ||||||
|     !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. | /* Return non-zero if PATH1 is a prefix of PATH2. | ||||||
|    Both are assumed to be of the same path style and / vs \ usage. |    Both are assumed to be of the same path style and / vs \ usage. | ||||||
|    Neither may be "". |    Neither may be "". | ||||||
| @@ -173,7 +179,7 @@ pathmatch (const char *path1, const char *path2) | |||||||
|  |  | ||||||
| #define isslash(c) ((c) == '/') | #define isslash(c) ((c) == '/') | ||||||
|  |  | ||||||
| int | static int | ||||||
| normalize_posix_path (const char *src, char *dst) | normalize_posix_path (const char *src, char *dst) | ||||||
| { | { | ||||||
|   const char *src_start = src; |   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 | /* Convert an arbitrary path SRC to a pure Win32 path, suitable for | ||||||
|    passing to Win32 API routines. |    passing to Win32 API routines. | ||||||
|  |  | ||||||
| @@ -413,6 +425,7 @@ path_conv::check (const char *src, unsigned opt, | |||||||
|   sym_opt = 0; |   sym_opt = 0; | ||||||
|   drive_type = 0; |   drive_type = 0; | ||||||
|   is_remote_drive = 0; |   is_remote_drive = 0; | ||||||
|  |   normalized_path = NULL; | ||||||
|  |  | ||||||
|   if (!(opt & PC_NULLEMPTY)) |   if (!(opt & PC_NULLEMPTY)) | ||||||
|     error = 0; |     error = 0; | ||||||
| @@ -494,6 +507,28 @@ path_conv::check (const char *src, unsigned opt, | |||||||
| 		} | 		} | ||||||
| 	      goto out; | 	      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. */ | 	  /* devn should not be a device.  If it is, then stop parsing now. */ | ||||||
| 	  else if (devn != FH_BAD) | 	  else if (devn != FH_BAD) | ||||||
| 	    { | 	    { | ||||||
| @@ -683,6 +718,8 @@ path_conv::check (const char *src, unsigned opt, | |||||||
|     add_ext_from_sym (sym); |     add_ext_from_sym (sym); | ||||||
|  |  | ||||||
| out: | out: | ||||||
|  |   if (opt & PC_POSIX) | ||||||
|  |     normalized_path = cstrdup (path_copy); | ||||||
|   /* Deal with Windows stupidity which considers filename\. to be valid |   /* Deal with Windows stupidity which considers filename\. to be valid | ||||||
|      even when "filename" is not a directory. */ |      even when "filename" is not a directory. */ | ||||||
|   if (!need_directory || error) |   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) |       else if (mount_table->cygdrive_len > 1) | ||||||
| 	return ENOENT; | 	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; |   int chrooted_path_len; | ||||||
|   chrooted_path_len = 0; |   chrooted_path_len = 0; | ||||||
| @@ -1476,7 +1521,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, | |||||||
|       *flags = mi->flags; |       *flags = mi->flags; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   if (devn != FH_CYGDRIVE) |   if (!isvirtual_dev (devn)) | ||||||
|     win32_device_name (src_path, dst, devn, unit); |     win32_device_name (src_path, dst, devn, unit); | ||||||
|  |  | ||||||
|  out: |  out: | ||||||
| @@ -3237,7 +3282,8 @@ chdir (const char *in_dir) | |||||||
|       path.get_win32 ()[3] = '\0'; |       path.get_win32 ()[3] = '\0'; | ||||||
|     } |     } | ||||||
|   int res; |   int res; | ||||||
|   if (path.get_devn () != FH_CYGDRIVE) |   int devn = path.get_devn(); | ||||||
|  |   if (!isvirtual_dev (devn)) | ||||||
|     res = SetCurrentDirectory (native_dir) ? 0 : -1; |     res = SetCurrentDirectory (native_dir) ? 0 : -1; | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
| @@ -3257,8 +3303,8 @@ chdir (const char *in_dir) | |||||||
|      we'll see if Cygwin mailing list users whine about the current behavior. */ |      we'll see if Cygwin mailing list users whine about the current behavior. */ | ||||||
|   if (res == -1) |   if (res == -1) | ||||||
|     __seterrno (); |     __seterrno (); | ||||||
|   else if (!path.has_symlinks () && strpbrk (dir, ":\\") == NULL |   else if ((!path.has_symlinks () && strpbrk (dir, ":\\") == NULL | ||||||
| 	   && pcheck_case == PCHECK_RELAXED) |             && pcheck_case == PCHECK_RELAXED) || isvirtual_dev (devn)) | ||||||
|     cygheap->cwd.set (native_dir, dir); |     cygheap->cwd.set (native_dir, dir); | ||||||
|   else |   else | ||||||
|     cygheap->cwd.set (native_dir, NULL); |     cygheap->cwd.set (native_dir, NULL); | ||||||
|   | |||||||
| @@ -23,7 +23,8 @@ enum pathconv_arg | |||||||
|   PC_SYM_CONTENTS	= 0x0008, |   PC_SYM_CONTENTS	= 0x0008, | ||||||
|   PC_FULL		= 0x0010, |   PC_FULL		= 0x0010, | ||||||
|   PC_NULLEMPTY		= 0x0020, |   PC_NULLEMPTY		= 0x0020, | ||||||
|   PC_CHECK_EA		= 0x0040 |   PC_CHECK_EA		= 0x0040, | ||||||
|  |   PC_POSIX		= 0x0080 | ||||||
| }; | }; | ||||||
|  |  | ||||||
| enum case_checking | enum case_checking | ||||||
| @@ -75,6 +76,7 @@ class path_conv | |||||||
|   int unit; |   int unit; | ||||||
|   DWORD fileattr; |   DWORD fileattr; | ||||||
|   BOOL case_clash; |   BOOL case_clash; | ||||||
|  |   char *normalized_path; | ||||||
|  |  | ||||||
|   int isdisk () const { return path_flags & PATH_ISDISK;} |   int isdisk () const { return path_flags & PATH_ISDISK;} | ||||||
|   int isremote () const {return is_remote_drive;} |   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 (): 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; } |   inline char *get_win32 () { return path; } | ||||||
|   operator char *() {return path; } |   operator char *() {return path;} | ||||||
|   operator DWORD &() {return fileattr; } |   operator const char *() {return path;} | ||||||
|  |   operator DWORD &() {return fileattr;} | ||||||
|   operator int &() {return (int) fileattr; } |   operator int &() {return (int) fileattr; } | ||||||
|   BOOL is_device () {return devn != FH_BAD && devn != FH_DISK;} |   BOOL is_device () {return devn != FH_BAD && devn != FH_DISK;} | ||||||
|   DWORD get_devn () {return devn == FH_BAD ? (DWORD) FH_DISK : devn;} |   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 pathmatch (const char *path1, const char *path2) __attribute__ ((regparm (2))); | ||||||
| int pathnmatch (const char *path1, const char *path2, int len) __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. */ |      we only use this handle from the parent. */ | ||||||
|   HANDLE hProcess; |   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 associated with initial Windows pid which started it all. */ | ||||||
|   HANDLE pid_handle; |   HANDLE pid_handle; | ||||||
|   | |||||||
| @@ -39,8 +39,6 @@ details. */ | |||||||
| #include "shared_info.h" | #include "shared_info.h" | ||||||
| #include "cygheap.h" | #include "cygheap.h" | ||||||
|  |  | ||||||
| extern int normalize_posix_path (const char *, char *); |  | ||||||
|  |  | ||||||
| SYSTEM_INFO system_info; | SYSTEM_INFO system_info; | ||||||
|  |  | ||||||
| /* Close all files and process any queued deletions. | /* Close all files and process any queued deletions. | ||||||
| @@ -2207,7 +2205,7 @@ extern "C" int | |||||||
| chroot (const char *newroot) | chroot (const char *newroot) | ||||||
| { | { | ||||||
|   sigframe thisframe (mainthread); |   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; |   int ret; | ||||||
|   if (path.error) |   if (path.error) | ||||||
| @@ -2224,9 +2222,7 @@ chroot (const char *newroot) | |||||||
|     } |     } | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
|       char buf[MAX_PATH]; |       cygheap->root.set (path.normalized_path, path); | ||||||
|       normalize_posix_path (newroot, buf); |  | ||||||
|       cygheap->root.set (buf, path); |  | ||||||
|       ret = 0; |       ret = 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -269,6 +269,9 @@ extern SYSTEM_INFO system_info; | |||||||
| #define STD_RBITS (S_IRUSR | S_IRGRP | S_IROTH) | #define STD_RBITS (S_IRUSR | S_IRGRP | S_IROTH) | ||||||
| #define STD_WBITS (S_IWUSR) | #define STD_WBITS (S_IWUSR) | ||||||
| #define STD_XBITS (S_IXUSR | S_IXGRP | S_IXOTH) | #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. */ | /* The title on program start. */ | ||||||
| extern char *old_title; | extern char *old_title; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user