diff options
| author | Martin Blapp <mbr@FreeBSD.org> | 2003-04-29 12:36:03 +0000 |
|---|---|---|
| committer | Martin Blapp <mbr@FreeBSD.org> | 2003-04-29 12:36:03 +0000 |
| commit | 616aa29a0e1d9ec92515222425e9b16d551f2eb8 (patch) | |
| tree | c4e9c347275ced551421d01c7e97db99e6f7bdbe /sys | |
| parent | fd08d16bc21e24b78e4f78759978c0633a3508d0 (diff) | |
Notes
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/compat/linux/linux_stats.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index eab5ad517b427..969dcb6000515 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -380,6 +380,8 @@ static int 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); @@ -396,6 +398,23 @@ stat64_copyout(struct stat *buf, void *ubuf) 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 * it is conditionally compiled based on STAT64_HAS_BROKEN_ST_INO, |
