diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-07-23 23:38:57 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-11-24 15:21:05 -0500 |
commit | 12982f31a233250c7a62b17fb4bd13594cb78777 (patch) | |
tree | 31048c4492b13b832d40812599cb08a50c394bce /litmus/ftdev.c | |
parent | 49e5b0c0d7c09bef5b9bfecaaac3f0ea2cf24e43 (diff) |
ftdev: let bufffer-specific code handle writes from userspace
This allows us to splice in information into logs from events
that were recorded in userspace.
Diffstat (limited to 'litmus/ftdev.c')
-rw-r--r-- | litmus/ftdev.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/litmus/ftdev.c b/litmus/ftdev.c index 216dc0b4cb94..06fcf4cf77dc 100644 --- a/litmus/ftdev.c +++ b/litmus/ftdev.c | |||
@@ -114,6 +114,7 @@ static int ftdev_open(struct inode *in, struct file *filp) | |||
114 | goto out; | 114 | goto out; |
115 | 115 | ||
116 | ftdm = ftdev->minor + buf_idx; | 116 | ftdm = ftdev->minor + buf_idx; |
117 | ftdm->ftdev = ftdev; | ||
117 | filp->private_data = ftdm; | 118 | filp->private_data = ftdm; |
118 | 119 | ||
119 | if (mutex_lock_interruptible(&ftdm->lock)) { | 120 | if (mutex_lock_interruptible(&ftdm->lock)) { |
@@ -284,11 +285,25 @@ out: | |||
284 | return err; | 285 | return err; |
285 | } | 286 | } |
286 | 287 | ||
288 | static ssize_t ftdev_write(struct file *filp, const char __user *from, | ||
289 | size_t len, loff_t *f_pos) | ||
290 | { | ||
291 | struct ftdev_minor* ftdm = filp->private_data; | ||
292 | ssize_t err = -EINVAL; | ||
293 | struct ftdev* ftdev = ftdm->ftdev; | ||
294 | |||
295 | /* dispatch write to buffer-specific code, if available */ | ||
296 | if (ftdev->write) | ||
297 | err = ftdev->write(ftdm->buf, len, from); | ||
298 | |||
299 | return err; | ||
300 | } | ||
287 | 301 | ||
288 | struct file_operations ftdev_fops = { | 302 | struct file_operations ftdev_fops = { |
289 | .owner = THIS_MODULE, | 303 | .owner = THIS_MODULE, |
290 | .open = ftdev_open, | 304 | .open = ftdev_open, |
291 | .release = ftdev_release, | 305 | .release = ftdev_release, |
306 | .write = ftdev_write, | ||
292 | .read = ftdev_read, | 307 | .read = ftdev_read, |
293 | .unlocked_ioctl = ftdev_ioctl, | 308 | .unlocked_ioctl = ftdev_ioctl, |
294 | }; | 309 | }; |
@@ -308,6 +323,7 @@ int ftdev_init( struct ftdev* ftdev, struct module* owner, | |||
308 | ftdev->alloc = NULL; | 323 | ftdev->alloc = NULL; |
309 | ftdev->free = NULL; | 324 | ftdev->free = NULL; |
310 | ftdev->can_open = NULL; | 325 | ftdev->can_open = NULL; |
326 | ftdev->write = NULL; | ||
311 | 327 | ||
312 | ftdev->minor = kcalloc(ftdev->minor_cnt, sizeof(*ftdev->minor), | 328 | ftdev->minor = kcalloc(ftdev->minor_cnt, sizeof(*ftdev->minor), |
313 | GFP_KERNEL); | 329 | GFP_KERNEL); |