summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-03-28 08:58:11 +0000
committerphk <phk@FreeBSD.org>2003-03-28 08:58:11 +0000
commitb01c30ec028f2ef80f7d4d4122e603604c5651e4 (patch)
treefcdd4cfbb69963682bb37c1eaa11c10ab7d638b6
parent5d5d5f775ce468bcb7dd450a586fdd2a7f51d71f (diff)
downloadFreeBSD-src-b01c30ec028f2ef80f7d4d4122e603604c5651e4.zip
FreeBSD-src-b01c30ec028f2ef80f7d4d4122e603604c5651e4.tar.gz
Fix an XXX: and implement LINUX_BLKGETSIZE correctly.
-rw-r--r--sys/compat/linux/linux_ioctl.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index b71cf6f..e63012f 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -33,6 +33,7 @@
#include <sys/sysproto.h>
#include <sys/cdio.h>
#include <sys/dvdio.h>
+#include <sys/disk.h>
#include <sys/consio.h>
#include <sys/ctype.h>
#include <sys/disklabel.h>
@@ -111,20 +112,27 @@ linux_ioctl_disk(struct thread *td, struct linux_ioctl_args *args)
{
struct file *fp;
int error;
- struct disklabel dl;
+ u_int sectorsize;
+ off_t mediasize;
if ((error = fget(td, args->fd, &fp)) != 0)
return (error);
switch (args->cmd & 0xffff) {
case LINUX_BLKGETSIZE:
- /* XXX: wrong, should use DIOCGMEDIASIZE/DIOCGSECTORSIZE */
- error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, td->td_ucred,
- td);
+ error = fo_ioctl(fp, DIOCGSECTORSIZE,
+ (caddr_t)&sectorsize, td->td_ucred, td);
+ if (!error)
+ error = fo_ioctl(fp, DIOCGMEDIASIZE,
+ (caddr_t)&mediasize, td->td_ucred, td);
fdrop(fp, td);
if (error)
return (error);
- return (copyout(&(dl.d_secperunit), (void *)args->arg,
- sizeof(dl.d_secperunit)));
+ sectorsize = mediasize / sectorsize;
+ /*
+ * XXX: How do we know we return the right size of integer ?
+ */
+ return (copyout(&sectorsize, (void *)args->arg,
+ sizeof(sectorsize)));
}
fdrop(fp, td);
return (ENOIOCTL);
OpenPOWER on IntegriCloud