usb udev
[root@localhost ~] # udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[105.208635] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
KERNEL[105.208721] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg1 (scsi_generic)
KERNEL[105.208764] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
KERNEL[105.208836] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
KERNEL[105.209093] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb4 (block)
UDEV [105.211112] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
UDEV [105.212047] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg1 (scsi_generic)
KERNEL[105.213199] remove /devices/virtual/bdi/8:16 (bdi)
KERNEL[105.213516] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
KERNEL[105.213585] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0 (scsi)
UDEV [105.213641] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
UDEV [105.213998] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
UDEV [105.214105] remove /devices/virtual/bdi/8:16 (bdi)
UDEV [105.214980] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb4 (block)
UDEV [105.216450] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
UDEV [105.217848] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0 (scsi)
KERNEL[105.221213] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0 (scsi)
KERNEL[105.221232] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/scsi_host/host4 (scsi_host)
KERNEL[105.221240] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4 (scsi)
KERNEL[105.221284] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0 (usb)
KERNEL[105.221557] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1 (usb)
UDEV [105.221673] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0 (scsi)
UDEV [105.221769] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/scsi_host/host4 (scsi_host)
UDEV [105.221885] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4 (scsi)
UDEV [105.222110] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0 (usb)
UDEV [105.222325] remove /devices/pci0000:00/0000:00:14.0/usb2/2-1 (usb)
KERNEL[128.272086] add /devices/pci0000:00/0000:00:14.0/usb2/2-1 (usb)
KERNEL[128.283096] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0 (usb)
KERNEL[128.283566] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4 (scsi)
KERNEL[128.283617] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/scsi_host/host4 (scsi_host)
UDEV [128.292000] add /devices/pci0000:00/0000:00:14.0/usb2/2-1 (usb)
UDEV [128.294367] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0 (usb)
UDEV [128.296326] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4 (scsi)
UDEV [128.298073] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/scsi_host/host4 (scsi_host)
KERNEL[129.311851] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0 (scsi)
KERNEL[129.311874] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0 (scsi)
KERNEL[129.311880] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
KERNEL[129.311886] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
KERNEL[129.311894] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg1 (scsi_generic)
KERNEL[129.311913] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
KERNEL[129.312405] add /devices/virtual/bdi/8:16 (bdi)
UDEV [129.312474] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0 (scsi)
UDEV [129.312773] add /devices/virtual/bdi/8:16 (bdi)
UDEV [129.312910] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0 (scsi)
UDEV [129.313439] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
UDEV [129.313483] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
UDEV [129.313685] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
UDEV [129.313707] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg1 (scsi_generic)
KERNEL[129.314981] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
KERNEL[129.314993] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb4 (block)
UDEV [129.346675] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
UDEV [129.374249] add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb4 (block)
[10月24 23:38] sdb: sdb4
[10月24 23:39] usb 2-1: USB disconnect, device number 2
[ +23.032664] usb 2-1: new SuperSpeed USB device number 3 using xhci_hcd
[ +0.023654] usb 2-1: New USB device found, idVendor=0951, idProduct=1666
[ +0.000005] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ +0.000003] usb 2-1: Product: DataTraveler 3.0
[ +0.000003] usb 2-1: Manufacturer: Kingston
[ +0.000002] usb 2-1: SerialNumber: 0026186645E5F0C078808600
[ +0.011328] usb-storage 2-1:1.0: USB Mass Storage device detected
[ +0.000359] scsi host4: usb-storage 2-1:1.0
[ +1.027962] scsi 4:0:0:0: Direct-Access Kingston DataTraveler 3.0 PQ: 0 ANSI: 6
[ +0.000176] sd 4:0:0:0: Attached scsi generic sg1 type 0
[ +0.000207] sd 4:0:0:0: [sdb] 30218842 512-byte logical blocks: (15.5 GB/14.4 GiB)
[ +0.000144] sd 4:0:0:0: [sdb] Write Protect is off
[ +0.000000] sd 4:0:0:0: [sdb] Mode Sense: 4f 00 00 00
[ +0.000142] sd 4:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ +0.002550] sdb: sdb4
[ +0.000741] sd 4:0:0:0: [sdb] Attached SCSI removable disk
/* usbreset -- send a USB port reset to a USB device */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>
int main(int argc, char **argv)
{
const char *filename;
int fd;
int rc;
if (argc != 2) {
fprintf(stderr, "Usage: usbreset device-filename\n");
return 1;
}
filename = argv[1];
fd = open(filename, O_WRONLY);
if (fd < 0) {
perror("Error opening output file");
return 1;
}
printf("Resetting USB device %s\n", filename);
rc = ioctl(fd, USBDEVFS_RESET, 0);
if (rc < 0) {
perror("Error in ioctl");
return 1;
}
printf("Reset successful\n");
close(fd);
return 0;
}
https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line
usb udev的更多相关文章
- debian下使用dynamic printk分析usb网卡驱动
在<debian下使用dynamic printk分析usb转串口驱动执行流程>中使用了usb转串口,当前例子使用usb网卡分析驱动(dm9601芯片). 仍然需要使能dynamic pr ...
- debian下使用dynamic printk分析usb转串口驱动执行流程
看了一篇文章<debug by printing>,文中提到了多种通过printk来调试驱动的方法,其中最有用的就是"Dynamic debugging". “Dyna ...
- 使用 udev 进行动态内核设备管理(转自suse文档)
第 12 章使用 udev 进行动态内核设备管理¶ 目录 12.1. /dev 目录 12.2. 内核 uevents 和 udev 12.3. 驱动程序.内核模块和设备 12.4. 引导和启动设备设 ...
- [转]linux的du和df命令
转自:http://blog.csdn.net/kmesg/article/details/6570800 今天也有同学问我Linux下查看目录大小的命令,现在也将前阵子学习到du/df两个命令总结一 ...
- 使用apt-mirror建立本地debian仓库源
先介绍一下环境: 主机:Win7 虚拟机:VirtualBox + Debian7 由于软件源的体积比较大,所以我又给虚拟机添加了一块50GB的虚拟硬盘(给虚拟机添加虚拟硬盘的方法参见:http:// ...
- linux的du和df命令
今天也有同学问我Linux下查看目录大小的命令,现在也将前阵子学习到du/df两个命令总结一下吧.前阵子测试工作中有遇到过由于磁盘空间满导致程序无法执行到情况,所以使用了df和du两个命令. du查看 ...
- linux中du与df的区别和联系
1,两者区别 du,disk usage,是通过搜索文件来计算每个文件的大小然后累加,du能看到的文件只是一些当前存在 的,没有被删除的.他计算的大小就是当前他认为存在的所有文件大小的累加和. df, ...
- linux下无线鼠标驱动执行流程
操作系统: debian 7.4(linux 3.2.54) 硬件: 一个无线鼠标.一个有线鼠标.usb集线器. 从淘宝上花了15块钱买了个无线鼠标,很好奇它的驱动程序是如何执行的. 首先将usb集线 ...
- Linux中的du和df命令
现在也将前阵子学习到du/df两个命令总结一下吧.前阵子测试工作中有遇到过由于磁盘空间满导致程序无法执行到情况,所以使用了df和du两个命令. du查看目录大小,df查看磁盘使用情况.我常使用的命令( ...
随机推荐
- 算法学习 - ST表 - 稀疏表 - 解决RMQ问题
2017-08-26 21:44:45 writer:pprp RMQ问题就是区间最大最小值查询问题: 这个SparseTable算法构造一个表,F[i][j] 表示 区间[i, i + 2 ^ j ...
- P4开源Tutorials教程样例实战及对P4v1.1规范的初分析
Github链接:Github-P4Lang-Tutorials-p4v1.1 前言 本文主要对Barefoot开源教程中的p4v1.1实例simple_router的实战步骤进行记录与阐述,希望能帮 ...
- checkbox及css实现点击下拉菜单
面试遇到的问题.用checkbox中的:checked伪类选择器实现. 通过label标签来触发checkbox的unchecked 和checked两种状态:用css普通同胞选择器 ~.另外补充一点 ...
- Struts2框架学习第二章——Struts2下的HelloWorld
本章要点 — Struts 2的下载和安装 — 纯手工创建一个Web应用 — 纯手工创建一个Struts 2应用 — 实现Struts 2的Action — 配置Struts 2的Action — ...
- awardRotate.js
(function($) { var supportedCSS,styles=document.getElementsByTagName("head")[0].style,toCh ...
- Memcached get 命令
Memcached get 命令获取存储在 key(键) 中的 value(数据值) ,如果 key 不存在,则返回空. 语法: get 命令的基本语法格式如下: get key 多个 key 使用空 ...
- input实现文件上传
input实现文件上传 input + ajax 实现文件上传,包括文件大小及类型的判断 一.html <input type="file" id="file&qu ...
- C++名字查找和重载
重载函数的定义:在同一作用域内的几个函数名字相同但形参列表不同,称为重载函数.这里有一个重要的前提就是:同一个作用域: 而如果重载函数是定义在不同的作用域,那么一旦编译器在当前作用域找到所需的名字,编 ...
- SSM整合报错org.springframework.beans.factory.UnsatisfiedDependencyException
我解决的办法是把.m2仓库所有文件删除,重新maven project就可以了. 但是在做这一步之前,报错如下: ①org.springframework.beans.factory.Unsatisf ...
- mongodb禁止外网访问以及添加账号
未曾料到被黑客勒索比特币的戏码竟然降临到我的身上,几个月的技术积累付之一炬.怪只怪自己学艺不精,心存侥幸和无知,不过经此一役,方知网络安全防护的重要性. 一直未给自己的mongodb数据库设置账号密码 ...