diff options
author | mbr <mbr@FreeBSD.org> | 2003-04-29 12:36:03 +0000 |
---|---|---|
committer | mbr <mbr@FreeBSD.org> | 2003-04-29 12:36:03 +0000 |
commit | 284d69d7b0ddbfa7a18a9d36e5cf00df3cf66773 (patch) | |
tree | c4e9c347275ced551421d01c7e97db99e6f7bdbe /sys/compat | |
parent | 28e298a192c457d0efdcd4a84587c2dd30f2278f (diff) | |
download | FreeBSD-src-284d69d7b0ddbfa7a18a9d36e5cf00df3cf66773.zip FreeBSD-src-284d69d7b0ddbfa7a18a9d36e5cf00df3cf66773.tar.gz |
Do the same thing for stat64_copyout() as we already
do for newstat_copyout().
Lie about disk drives which are character devices
in FreeBSD but block devices under Linux.
PR: 37227
Submitted by: Vladimir B. Grebenschikov <vova@sw.ru>
Reviewed by: phk
MFC after: 2 weeks
Diffstat (limited to 'sys/compat')
-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 eab5ad5..969dcb6 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, |