Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Apr 2002 19:08:19 +0400
From:      "Vladimir B.Grebenschikov" <vova@sw.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        vsilyaev@mindspring.com
Subject:   kern/37227: VMWare do not work with raw disks due to invalid device hadling by linuxlator
Message-ID:  <E16yDWF-0000cK-00@vbook.express.ru>

next in thread | raw e-mail | index | archive | help

>Number:         37227
>Category:       kern
>Synopsis:       VMWare do not work with raw disks due to invalid device hadling by linuxlator
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 18 08:10:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Vladimir B. Grebenschikov
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
SWsoft
>Environment:
System: FreeBSD vbook.express.ru 5.0-CURRENT FreeBSD 5.0-CURRENT #16: Tue Apr 9 12:13:44 MSD 2002 vova@vbook.express.ru:/usr/local/src/sys/i386/compile/VBOOK i386

-CURRENT kernel about  Tue Apr 9 12:13:44 MSD 
/usr/ports/emulators/vmware2 port

>Description:
When vmware tries to work with disk in "raw" mode it does some strange
magics actions to determine type of disk and in case of character device
(nowdays in FreeBSD) it failed to determine disk type validly.

>How-To-Repeat:
install /usr/ports/emulators/vmware2 port and try to use "raw" disk in
vmware, it will detect partitions right, but filed to start VirtualMachine

>Fix:

I found exactly same hack (BSD characted devices substituted to block device
for linux binaries) in newstat_copyout() and assume that this hack will help
in stat64_copyout() for vmware2 - it really helps.


Index: linux_stats.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_stats.c,v
retrieving revision 1.40
diff -u -r1.40 linux_stats.c
--- linux_stats.c	2002/01/14 00:13:42	1.40
+++ linux_stats.c	2002/04/18 15:00:43
@@ -362,6 +362,8 @@
 stat64_copyout(struct stat *buf, void *ubuf)
 {
 	struct l_stat64 lbuf;
+        struct cdevsw *cdevsw;
+        dev_t dev;
 
 	bzero(&lbuf, sizeof(lbuf));
 	lbuf.st_dev = uminor(buf->st_dev) | (umajor(buf->st_dev) << 8);
@@ -377,6 +379,25 @@
 	lbuf.st_ctime = buf->st_ctime;
 	lbuf.st_blksize = buf->st_blksize;
 	lbuf.st_blocks = buf->st_blocks;
+
+
+        /* Lie about disk drives which are character devices
+         * in FreeBSD but block devices under Linux.
+         */
+        if (S_ISCHR(lbuf.st_mode) &&
+            (dev = udev2dev(buf->st_rdev, 0)) != NODEV) {
+                cdevsw = devsw(dev);
+                if (cdevsw != NULL && (cdevsw->d_flags & D_DISK)) {
+                        lbuf.st_mode &= ~S_IFMT;
+                        lbuf.st_mode |= S_IFBLK;
+
+                        /* XXX this may not be quite right */
+                        /* Map major number to 0 */
+                        lbuf.st_dev = uminor(buf->st_dev) & 0xf;
+                        lbuf.st_rdev = buf->st_rdev & 0xff;
+                }
+        }
+
 
 	/*
 	 * The __st_ino field makes all the difference. In the Linux kernel



>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E16yDWF-0000cK-00>