aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Franke <franke@computer.org>2020-11-28 22:09:23 +0100
committerCorinna Vinschen <corinna@vinschen.de>2020-11-30 11:53:00 +0100
commit3434d35a64736f0b77a12f61784c2caa33ac44cf (patch)
treeb6e41e6493ca222733713d6ab805783e2ce32226
parent7fa8405d3fc166e48f8b401cbd83ce65e694b5a7 (diff)
downloadnewlib-3434d35a64736f0b77a12f61784c2caa33ac44cf.zip
newlib-3434d35a64736f0b77a12f61784c2caa33ac44cf.tar.gz
newlib-3434d35a64736f0b77a12f61784c2caa33ac44cf.tar.bz2
Cygwin: Fix access to block devices below /proc/sys.
Use fhandler_dev_floppy instead of fhandler_procsys for such devices. The read()/write() functions from fhandler_procsys do not ensure sector aligned transfers and lseek() fails always. Signed-off-by: Christian Franke <franke@computer.org>
-rw-r--r--winsup/cygwin/path.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 4f5f03a..7e6243d 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -863,19 +863,28 @@ path_conv::check (const char *src, unsigned opt,
dev.parse (FH_FS);
goto is_fs_via_procsys;
case virt_blk:
- /* Block special device. If the trailing slash has been
- requested, the target is the root directory of the
- filesystem on this block device. So we convert this
- to a real file and attach the backslash. */
- if (component == 0 && need_directory)
+ /* Block special device. Convert to a /dev/sd* like
+ block device unless the trailing slash has been
+ requested. In this case, the target is the root
+ directory of the filesystem on this block device.
+ So we convert this to a real file and attach the
+ backslash. */
+ if (component == 0)
{
- dev.parse (FH_FS);
- strcat (full_path, "\\");
- fileattr = FILE_ATTRIBUTE_DIRECTORY
- | FILE_ATTRIBUTE_DEVICE;
+ fileattr = FILE_ATTRIBUTE_DEVICE;
+ if (!need_directory)
+ /* Use a /dev/sd* device number > /dev/sddx.
+ FIXME: Define a new major DEV_ice number. */
+ dev.parse (DEV_SD_HIGHPART_END, 9999);
+ else
+ {
+ dev.parse (FH_FS);
+ strcat (full_path, "\\");
+ fileattr |= FILE_ATTRIBUTE_DIRECTORY;
+ }
goto out;
}
- fallthrough;
+ break;
case virt_chr:
if (component == 0)
fileattr = FILE_ATTRIBUTE_DEVICE;