cregit-Linux how code gets into the kernel

Release 4.11 drivers/usb/mon/mon_stat.c

Directory: drivers/usb/mon
/*
 * The USB Monitor, inspired by Dave Harding's USBMon.
 *
 * This is the 's' or 'stat' reader which debugs usbmon itself.
 * Note that this code blows through locks, so make sure that
 * /dbg/usbmon/0s is well protected from non-root users.
 *
 */

#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/export.h>
#include <linux/usb.h>
#include <linux/fs.h>
#include <linux/uaccess.h>

#include "usb_mon.h"


#define STAT_BUF_SIZE  80


struct snap {
	
int slen;
	
char str[STAT_BUF_SIZE];
};


static int mon_stat_open(struct inode *inode, struct file *file) { struct mon_bus *mbus; struct snap *sp; sp = kmalloc(sizeof(struct snap), GFP_KERNEL); if (sp == NULL) return -ENOMEM; mbus = inode->i_private; sp->slen = snprintf(sp->str, STAT_BUF_SIZE, "nreaders %d events %u text_lost %u\n", mbus->nreaders, mbus->cnt_events, mbus->cnt_text_lost); file->private_data = sp; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Pete Zaitcev8694.51%250.00%
Greg Kroah-Hartman44.40%125.00%
Theodore Y. Ts'o11.10%125.00%
Total91100.00%4100.00%


static ssize_t mon_stat_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) { struct snap *sp = file->private_data; return simple_read_from_buffer(buf, nbytes, ppos, sp->str, sp->slen); }

Contributors

PersonTokensPropCommitsCommitProp
Pete Zaitcev4284.00%150.00%
Akinobu Mita816.00%150.00%
Total50100.00%2100.00%


static int mon_stat_release(struct inode *inode, struct file *file) { struct snap *sp = file->private_data; file->private_data = NULL; kfree(sp); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Lei Ming2051.28%150.00%
Pete Zaitcev1948.72%150.00%
Total39100.00%2100.00%

const struct file_operations mon_fops_stat = { .owner = THIS_MODULE, .open = mon_stat_open, .llseek = no_llseek, .read = mon_stat_read, /* .write = mon_stat_write, */ /* .poll = mon_stat_poll, */ /* .unlocked_ioctl = mon_stat_ioctl, */ .release = mon_stat_release, };

Overall Contributors

PersonTokensPropCommitsCommitProp
Pete Zaitcev21082.35%218.18%
Lei Ming207.84%19.09%
Akinobu Mita114.31%19.09%
Greg Kroah-Hartman41.57%19.09%
Tejun Heo31.18%19.09%
Paul Gortmaker31.18%19.09%
Luiz Fernando N. Capitulino10.39%19.09%
Arnd Bergmann10.39%19.09%
Linus Torvalds10.39%19.09%
Theodore Y. Ts'o10.39%19.09%
Total255100.00%11100.00%
Directory: drivers/usb/mon
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.