diff options
author | joe <joe@FreeBSD.org> | 2001-01-14 23:33:50 +0000 |
---|---|---|
committer | joe <joe@FreeBSD.org> | 2001-01-14 23:33:50 +0000 |
commit | f9b1d852bee499c2691030f0933be6a8130a1416 (patch) | |
tree | 21eef34f8356a7eed78164497922b60e620e7fa7 /sys/compat/linux | |
parent | 95d27233f38767ebb529d8f37869c188f7ac5722 (diff) | |
download | FreeBSD-src-f9b1d852bee499c2691030f0933be6a8130a1416.zip FreeBSD-src-f9b1d852bee499c2691030f0933be6a8130a1416.tar.gz |
Instead of hard coding the major numbers for IDE and SCSI disks
look in the device's cdevsw for the D_DISK flag.
Diffstat (limited to 'sys/compat/linux')
-rw-r--r-- | sys/compat/linux/linux_stats.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index 18d76ff..ee31b4f 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -100,6 +100,8 @@ static int newstat_copyout(struct stat *buf, void *ubuf) { struct linux_newstat tbuf; + struct cdevsw *cdevsw; + dev_t dev; tbuf.stat_dev = uminor(buf->st_dev) | (umajor(buf->st_dev) << 8); tbuf.stat_ino = buf->st_ino; @@ -114,17 +116,22 @@ newstat_copyout(struct stat *buf, void *ubuf) tbuf.stat_ctime = buf->st_ctime; tbuf.stat_blksize = buf->st_blksize; tbuf.stat_blocks = buf->st_blocks; - if (tbuf.stat_mode & S_IFCHR && - (umajor(buf->st_rdev) == 116 || - umajor(buf->st_rdev) == 13)) { - - tbuf.stat_mode &= ~S_IFCHR; - tbuf.stat_mode |= S_IFBLK; - /* XXX this may not be quite right */ - /* Map major number to 0 */ - tbuf.stat_dev = uminor(buf->st_dev) & 0xf; - tbuf.stat_rdev = buf->st_rdev & 0xff; + /* Lie about disk drives which are character devices + * in FreeBSD but block devices under Linux. + */ + if (tbuf.stat_mode & S_IFCHR && + (dev = udev2dev(buf->st_rdev, 0)) != NODEV) { + cdevsw = devsw(dev); + if (cdevsw != NULL && (cdevsw->d_flags & D_DISK)) { + tbuf.stat_mode &= ~S_IFCHR; + tbuf.stat_mode |= S_IFBLK; + + /* XXX this may not be quite right */ + /* Map major number to 0 */ + tbuf.stat_dev = uminor(buf->st_dev) & 0xf; + tbuf.stat_rdev = buf->st_rdev & 0xff; + } } return (copyout(&tbuf, ubuf, sizeof(tbuf))); |