aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_ioctl.c
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2003-03-28 08:58:11 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2003-03-28 08:58:11 +0000
commit10c665ef8ff0d53ac6461db6568980daf16b27c7 (patch)
treefcdd4cfbb69963682bb37c1eaa11c10ab7d638b6 /sys/compat/linux/linux_ioctl.c
parentd1636fcf4efdad30ab04a1c077df812dd62b4875 (diff)
downloadsrc-10c665ef8ff0d53ac6461db6568980daf16b27c7.tar.gz
src-10c665ef8ff0d53ac6461db6568980daf16b27c7.zip
Fix an XXX: and implement LINUX_BLKGETSIZE correctly.
Notes
Notes: svn path=/head/; revision=112740
Diffstat (limited to 'sys/compat/linux/linux_ioctl.c')
-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 b71cf6fab021..e63012f5a8ad 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);