This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fdisk -l is mute


Corinna Vinschen <corinna-cygwin <at> cygwin.com> writes:

> 
> On Dec 11 18:38, Christian Franke wrote:
> > Corinna Vinschen wrote:
> > >On Dec 10 22:37, Christian Franke wrote:
> > >>Fergus Daly wrote:
> > >>>If util-linux is installed then
> > >>>$ /usr/sbin/fdisk
> > >>>returns a list of options as expected; but choosing one of them
> > >>>$ /usr/sbin/fdisk -l
> > >>>is mute.
> > >>>In the past this has returned filesystem summaries as expected.
> > >>>Windows 7, all up to date.
> > >>>Anybody else?
> > >>Could reproduce this.
> > >>
> > >>The option -l still works if a device is specified:
> > >>
> > >># fdisk -l /dev/sdX
> > >>...
> > >>Disk /dev/sda: 1.8 TiB, ...
> > >>
> > >>Is this probably because the format of /proc/partitions has changed due to
> > >>the new (& useful!) win-mounts column?
> > >The win-mount column is empty for disk entries, only filled for
> > >partitions.  In theory that shouldn't bother fdisk which only looks
> > >for disk entries.  Or, does it?
> > >
> > >
> > 
> > It doesn't.
> > 
> > A quick look in the source shows that the function sysfs_devname_to_devno()
> > now only checks the path /sys/block/sdX/dev if the device name does not
> > start with /dev/. I presume upstream has removed a fallback to /dev/sdX
> > because this is no longer required on Linux.
> 
> Hey, I'm off the hook on that one, cool! :)

As Cygwin does not provide /sys/block/sdX/dev, should fdisk be patched for
Cygwin to enumerate and prefix the device names from /proc/partitions with
/dev/ so that --list without arguments works as expected? 

If I could configure the ! package, I could test if a patch like the
following would work: 

--- origsrc/util-linux-2.25.2/lib/sysfs.c	2014-10-24 03:21:20.311387900 -0600
+++ src/util-linux-2.25.2/lib/sysfs.c	2014-12-16 22:16:58.076483200 -0700
@@ -60,6 +60,22 @@ dev_t sysfs_devname_to_devno(const char
 		else
 			name += 5;	/* unaccesible, or not node in /dev */
 	}
+#ifdef __CYGWIN__
+	else {
+		/*
+		 * Create path to /dev/<name>
+		 */
+		int len = snprintf(buf, sizeof(buf),
+				 "/dev/%s", name);
+		struct stat st;
+
+		if (len < 0 || (size_t) len + 1 > sizeof(buf))
+			return 0;
+
+		if (stat(buf, &st) == 0)
+			dev = st.st_rdev;
+	}
+#endif
 
 	if (!dev && parent && strncmp("dm-", name, 3)) {
 		/*




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]