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
This commit is contained in:
Martin Blapp 2003-04-29 12:36:03 +00:00
parent fd08d16bc2
commit 616aa29a0e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=114214

View file

@ -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,