From 8c741ed54e1be63528e79222b600f37506c6d6d2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 23 Apr 2008 13:06:58 -0700 Subject: Add pread/pwrite ioctls to mmfs. --- tests/drmtest.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests/drmtest.c') diff --git a/tests/drmtest.c b/tests/drmtest.c index cae99a0c..58f71a6a 100644 --- a/tests/drmtest.c +++ b/tests/drmtest.c @@ -26,7 +26,9 @@ */ #include +#include #include "drmtest.h" +#include "mmfs.h" /** Open the first DRM device we can find, searching up to 16 device nodes */ int drm_open_any(void) @@ -81,3 +83,34 @@ int drm_open_any_master(void) abort(); } +static void +create_mmfs_device() +{ + struct stat sb; + int ret; + + ret = stat(MMFS_DEVICE_PATH, &sb); + + if (ret == 0) + return; + + ret = mknod(MMFS_DEVICE_PATH, S_IFCHR | S_IRUSR | S_IWUSR, + makedev(MMFS_DEVICE_MAJOR, 0)); + + if (ret != 0) + errx(1, "mknod()"); +} + +int +open_mmfs_device() +{ + int fd; + + create_mmfs_device(); + + fd = open(MMFS_DEVICE_PATH, O_RDWR); + if (fd == -1) + errx(1, "open()"); + + return fd; +} -- cgit v1.2.3