* devices.h (_minor): Coerce argument to proper type before manipulating.
(_major): Ditto. (device::is_fs_special): New function. * fhandler_disk_file.cc (fhandler_base::fstat_helper): Set the size to 0 for devices rather than reporting the size of the symlink. (fhandler_disk_file::readdir): Use is_fs_special to determine if .lnk should be stripped. * path.cc: Rename symlink_info::is_symlink to symlink_info::issymlink throughout. (symlink_info::isdevice): New field. (path_conv::check): Use 'isdevice' to determine if just-parsed entity is a device rather than relying on non-zero major/minor. (symlink_info::parse_device): Set isdevice to true if we've discovered a device. (symlink_info::check): Clear isdevice field prior to processing. Use isdevice to control debugging output. (symlink_info::set): Set isdevice to false. * path.h (path_conv::is_fs_special): New function. * devices.cc: Regenerate.
This commit is contained in:
		| @@ -1,3 +1,26 @@ | ||||
| 2005-12-01  Christopher Faylor  <cgf@timesys.com> | ||||
|  | ||||
| 	* devices.h (_minor): Coerce argument to proper type before | ||||
| 	manipulating. | ||||
| 	(_major): Ditto. | ||||
| 	(device::is_fs_special): New function. | ||||
| 	* fhandler_disk_file.cc (fhandler_base::fstat_helper): Set the size to | ||||
| 	0 for devices rather than reporting the size of the symlink. | ||||
| 	(fhandler_disk_file::readdir): Use is_fs_special to determine if .lnk | ||||
| 	should be stripped. | ||||
| 	* path.cc: Rename symlink_info::is_symlink to symlink_info::issymlink | ||||
| 	throughout. | ||||
| 	(symlink_info::isdevice): New field. | ||||
| 	(path_conv::check): Use 'isdevice' to determine if just-parsed entity | ||||
| 	is a device rather than relying on non-zero major/minor. | ||||
| 	(symlink_info::parse_device): Set isdevice to true if we've discovered | ||||
| 	a device. | ||||
| 	(symlink_info::check): Clear isdevice field prior to processing.  Use | ||||
| 	isdevice to control debugging output. | ||||
| 	(symlink_info::set): Set isdevice to false. | ||||
| 	* path.h (path_conv::is_fs_special): New function. | ||||
| 	* devices.cc: Regenerate. | ||||
|  | ||||
| 2005-11-30  Christopher Faylor  <cgf@timesys.com> | ||||
|  | ||||
| 	* times.cc (hires_ms::prime): Remove debugging stuff. | ||||
| @@ -46,19 +69,19 @@ | ||||
| 	(mmap_record::autogrow): Call global autogrow function. | ||||
| 	(list::anonymous): New method.  Use throughout were appropriate. | ||||
| 	(mmap_record::compatible_flags): Drop now useless ifdef. | ||||
| 	(mmap_record::alloc_page_map): Accomodate private anonymous maps. | ||||
| 	(mmap_record::map_pages): Accomodate MAP_NORESERVE mappings. | ||||
| 	(mmap_record::unmap_pages): Accomodate private anonymous maps. | ||||
| 	(mmap_record::alloc_page_map): Accommodate private anonymous maps. | ||||
| 	(mmap_record::map_pages): Accommodate MAP_NORESERVE mappings. | ||||
| 	(mmap_record::unmap_pages): Accommodate private anonymous maps. | ||||
| 	(mmap64): Simplify argument check.  Don't remove the MAP_PRIVATE flag | ||||
| 	for anonymous mappings on 9x anymore since that's now handled | ||||
| 	gracefully. | ||||
| 	(mprotect): Accomodate MAP_NORESERVE mappings.  Fix case when | ||||
| 	(mprotect): Accommodate MAP_NORESERVE mappings.  Fix case when | ||||
| 	non-mmap areas are just MEM_RESERVEd. | ||||
| 	(fhandler_dev_zero::mmap): Implement anonymous mapping here. | ||||
| 	(fhandler_dev_zero::munmap): Ditto. | ||||
| 	(fhandler_dev_zero::msyn): Ditto. | ||||
| 	(fhandler_dev_zero::fixup_mmap_after_fork): Ditto. | ||||
| 	(fixup_mmaps_after_fork): Accomodate private anonymous maps.  Enhance | ||||
| 	(fixup_mmaps_after_fork): Accommodate private anonymous maps.  Enhance | ||||
| 	debug output in case VirtualProtect fails. | ||||
| 	* include/sys/mman.h: Really define MAP_NORESERVE now. | ||||
|  | ||||
|   | ||||
| @@ -14,8 +14,8 @@ typedef mode_t _mode_t; | ||||
| typedef __dev32_t _dev_t; | ||||
|  | ||||
| #define FHDEV(maj, min) ((((unsigned) (maj)) << (sizeof (_major_t) * 8)) | (unsigned) (min)) | ||||
| #define _minor(dev) ((dev) & ((1 << (sizeof (_minor_t) * 8)) - 1)) | ||||
| #define _major(dev) ((dev) >> (sizeof (_major_t) * 8)) | ||||
| #define _minor(dev) (((_minor_t) dev) & ((1 << (sizeof (_minor_t) * 8)) - 1)) | ||||
| #define _major(dev) (((_major_t) dev) >> (sizeof (_major_t) * 8)) | ||||
|  | ||||
| enum fh_devices | ||||
| { | ||||
| @@ -149,6 +149,7 @@ struct device | ||||
|   inline operator int () const {return devn;} | ||||
|   inline void setfs (bool x) {dev_on_fs = x;} | ||||
|   inline bool isfs () const {return dev_on_fs || devn == FH_FS;} | ||||
|   inline bool is_fs_special () const {return dev_on_fs && devn != FH_FS;} | ||||
| }; | ||||
|  | ||||
| extern const device *console_dev; | ||||
|   | ||||
| @@ -394,6 +394,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, | ||||
| 	{ | ||||
| 	  buf->st_dev = dev (); | ||||
| 	  buf->st_mode = dev ().mode; | ||||
| 	  buf->st_size = 0; | ||||
| 	} | ||||
|     } | ||||
|   else | ||||
| @@ -413,6 +414,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, | ||||
| 	{ | ||||
| 	  buf->st_dev = dev (); | ||||
| 	  buf->st_mode = dev ().mode; | ||||
| 	  buf->st_size = 0; | ||||
| 	} | ||||
|       else | ||||
| 	{ | ||||
| @@ -1458,7 +1460,7 @@ fhandler_disk_file::readdir (DIR *dir, dirent *de) | ||||
| 	  strcpy (fbuf, dir->__d_dirname); | ||||
| 	  strcpy (fbuf + strlen (fbuf) - 1, c); | ||||
| 	  path_conv fpath (fbuf, PC_SYM_NOFOLLOW); | ||||
| 	  if (fpath.issymlink () || fpath.isspecial ()) | ||||
| 	  if (fpath.issymlink () || fpath.is_fs_special ()) | ||||
| 	    c[len - 4] = '\0'; | ||||
| 	} | ||||
|     } | ||||
|   | ||||
| @@ -88,10 +88,11 @@ struct symlink_info | ||||
|   int extn; | ||||
|   unsigned pflags; | ||||
|   DWORD fileattr; | ||||
|   int is_symlink; | ||||
|   int issymlink; | ||||
|   bool ext_tacked_on; | ||||
|   int error; | ||||
|   bool case_clash; | ||||
|   bool isdevice; | ||||
|   _major_t major; | ||||
|   _minor_t minor; | ||||
|   _mode_t mode; | ||||
| @@ -749,7 +750,7 @@ path_conv::check (const char *src, unsigned opt, | ||||
|  | ||||
| is_virtual_symlink: | ||||
|  | ||||
| 	  if (sym.minor || sym.major) | ||||
| 	  if (sym.isdevice) | ||||
| 	    { | ||||
| 	      dev.parse (sym.major, sym.minor); | ||||
| 	      dev.setfs (1); | ||||
| @@ -797,7 +798,7 @@ is_virtual_symlink: | ||||
| 	      /* If symlink.check found an existing non-symlink file, then | ||||
| 		 it sets the appropriate flag.  It also sets any suffix found | ||||
| 		 into `ext_here'. */ | ||||
| 	      if (!sym.is_symlink && sym.fileattr != INVALID_FILE_ATTRIBUTES) | ||||
| 	      if (!sym.issymlink && sym.fileattr != INVALID_FILE_ATTRIBUTES) | ||||
| 		{ | ||||
| 		  error = sym.error; | ||||
| 		  if (component == 0) | ||||
| @@ -3152,36 +3153,28 @@ symlink_info::parse_device (const char *contents) | ||||
|  | ||||
|   mymajor = strtol (contents += 2, &endptr, 16); | ||||
|   if (endptr == contents) | ||||
|     return false; | ||||
|     return isdevice = false; | ||||
|  | ||||
|   contents = endptr; | ||||
|   myminor = strtol (++contents, &endptr, 16); | ||||
|   if (endptr == contents) | ||||
|     return false; | ||||
|     return isdevice = false; | ||||
|  | ||||
|   contents = endptr; | ||||
|   mymode = strtol (++contents, &endptr, 16); | ||||
|   if (endptr == contents) | ||||
|     return false; | ||||
|     return isdevice = false; | ||||
|  | ||||
|   switch (mymode & S_IFMT) | ||||
|   if ((mymode & S_IFMT) == S_IFIFO) | ||||
|     { | ||||
|     case S_IFIFO: | ||||
|       mymajor = _major (FH_FIFO); | ||||
|       myminor = _minor (FH_FIFO); | ||||
|       break; | ||||
|     case S_IFBLK: | ||||
|     case S_IFCHR: | ||||
|       if (mymajor || myminor) | ||||
| 	break; | ||||
|     default: | ||||
|       return false; | ||||
|     } | ||||
|  | ||||
|   major = mymajor; | ||||
|   minor = myminor; | ||||
|   mode = mymode; | ||||
|   return true; | ||||
|   return isdevice = true; | ||||
| } | ||||
|  | ||||
| /* Check if PATH is a symlink.  PATH must be a valid Win32 path name. | ||||
| @@ -3209,11 +3202,13 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt) | ||||
|   suffix_scan suffix; | ||||
|   contents[0] = '\0'; | ||||
|  | ||||
|   is_symlink = true; | ||||
|   issymlink = true; | ||||
|   isdevice = false; | ||||
|   ext_here = suffix.has (path, suffixes); | ||||
|   extn = ext_here - path; | ||||
|   major = 0; | ||||
|   minor = 0; | ||||
|   mode = 0; | ||||
|  | ||||
|   pflags &= ~(PATH_SYMLINK | PATH_LNK); | ||||
|   unsigned pflags_or = pflags & PATH_NO_ACCESS_CHECK; | ||||
| @@ -3323,8 +3318,8 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt) | ||||
|       break; | ||||
|  | ||||
|     file_not_symlink: | ||||
|       is_symlink = false; | ||||
|       syscall_printf ("%s", (major || minor) ? "is a device" : "not a symlink"); | ||||
|       issymlink = false; | ||||
|       syscall_printf ("%s", isdevice ? "is a device" : "not a symlink"); | ||||
|       res = 0; | ||||
|       break; | ||||
|     } | ||||
| @@ -3343,7 +3338,8 @@ symlink_info::set (char *path) | ||||
|   pflags = PATH_SYMLINK; | ||||
|   fileattr = FILE_ATTRIBUTE_NORMAL; | ||||
|   error = 0; | ||||
|   is_symlink = true; | ||||
|   issymlink = true; | ||||
|   isdevice = false; | ||||
|   ext_tacked_on = case_clash = false; | ||||
|   ext_here = NULL; | ||||
|   extn = major = minor = mode = 0; | ||||
|   | ||||
| @@ -153,7 +153,7 @@ class path_conv | ||||
|   int isspecial () const {return dev.devn && dev.devn != FH_FS;} | ||||
|   int is_auto_device () const {return isdevice () && !is_fs_special ();} | ||||
|   int is_fs_device () const {return isdevice () && is_fs_special ();} | ||||
|   int is_fs_special () const {return isspecial () && dev.isfs ();} | ||||
|   int is_fs_special () const {return dev.is_fs_special ();} | ||||
|   int is_lnk_special () const {return is_fs_device () || isfifo () || is_lnk_symlink ();} | ||||
|   int issocket () const {return dev.devn == FH_UNIX;} | ||||
|   int iscygexec () const {return path_flags & PATH_CYGWIN_EXEC;} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user