当前位置:首页>Linux>Linux字符设备驱动开发初体验

Linux字符设备驱动开发初体验

  • 2026-01-22 17:03:33
Linux字符设备驱动开发初体验

字符设备驱动

设备驱动分类

Linux系统将设备分为三类:

  • • 字符设备:按字节流顺序访问的设备,如键盘、串口、LED等
  • • 块设备:可以随机访问固定大小数据块的设备,如硬盘、U盘等
  • • 网络设备:用于网络通信的设备,如网卡

字符设备驱动特点

  • • 面向流的设备,数据按顺序传输
  • • 通常不需要缓冲
  • • 通过设备文件(/dev目录下)访问
  • • 使用主设备号和次设备号标识

驱动开发环境

内核源码安装

# 安装内核源码sudo apt-get install linux-source# 解压源码tar -jxvf /usr/src/linux-source-*.tar.bz2

开发工具安装

sudo apt-get install build-essential linux-headers-$(uname -r)

字符设备驱动开发流程

初始化驱动模块
分配设备号
注册字符设备
创建设备文件
实现file_operations
编译为内核模块
加载驱动模块
测试驱动功能
卸载驱动模块

字符设备驱动实现

驱动框架结构

创建一个名为simple_char的字符设备驱动,实现基本的读写操作。

驱动实现示例

#include<linux/module.h>#include<linux/fs.h>#include<linux/cdev.h>#include<linux/uaccess.h>#include<linux/device.h>#include<linux/slab.h>// 设备名称#define DEVICE_NAME "simple_char"// 设备类别名称#define CLASS_NAME "simple_class"// 设备结构体structsimple_char_dev {structcdevcdev;// 字符设备结构体char data[256];             // 设备数据缓冲区structsemaphoresem;// 信号量,用于同步}; // 全局变量staticdev_t dev_num;           // 设备号staticstructsimple_char_dev *simple_dev;// 设备结构体指针staticstructclass *simple_class;// 设备类别staticstructdevice *simple_device;// 设备// 文件操作函数声明staticintsimple_open(struct inode *inode, struct file *file);staticintsimple_release(struct inode *inode, struct file *file);staticssize_tsimple_read(struct file *file, char __user *buf, size_t count, loff_t *pos);staticssize_tsimple_write(struct file *file, constchar __user *buf, size_t count, loff_t *pos);staticlongsimple_ioctl(struct file *file, unsignedint cmd, unsignedlong arg);// 文件操作结构体staticstructfile_operationssimple_fops = {    .owner = THIS_MODULE,    .open = simple_open,    .release = simple_release,    .read = simple_read,    .write = simple_write,    .unlocked_ioctl = simple_ioctl,};// 模块初始化函数staticint __init simple_init(void){int ret;    printk(KERN_INFO "Simple Char Driver: Initializing\n");// 1. 分配设备号    ret = alloc_chrdev_region(&dev_num, 01, DEVICE_NAME);if (ret < 0) {        printk(KERN_ERR "Simple Char Driver: Failed to allocate device number\n");return ret;    }    printk(KERN_INFO "Simple Char Driver: Major = %d, Minor = %d\n"           MAJOR(dev_num), MINOR(dev_num));// 2. 创建设备类别    simple_class = class_create(THIS_MODULE, CLASS_NAME);if (IS_ERR(simple_class)) {        unregister_chrdev_region(dev_num, 1);        printk(KERN_ERR "Simple Char Driver: Failed to create class\n");return PTR_ERR(simple_class);    }// 3. 创建设备结构体    simple_dev = kmalloc(sizeof(struct simple_char_dev), GFP_KERNEL);if (!simple_dev) {        class_destroy(simple_class);        unregister_chrdev_region(dev_num, 1);        printk(KERN_ERR "Simple Char Driver: Failed to allocate device structure\n");return -ENOMEM;    }// 初始化数据缓冲区memset(simple_dev->data, 0sizeof(simple_dev->data));// 初始化信号量    sema_init(&simple_dev->sem, 1);// 4. 初始化cdev并添加到内核    cdev_init(&simple_dev->cdev, &simple_fops);    simple_dev->cdev.owner = THIS_MODULE;    ret = cdev_add(&simple_dev->cdev, dev_num, 1);if (ret < 0) {        kfree(simple_dev);        class_destroy(simple_class);        unregister_chrdev_region(dev_num, 1);        printk(KERN_ERR "Simple Char Driver: Failed to add cdev\n");return ret;    }// 5. 创建设备文件    simple_device = device_create(simple_class, NULL, dev_num, NULL, DEVICE_NAME);if (IS_ERR(simple_device)) {        cdev_del(&simple_dev->cdev);        kfree(simple_dev);        class_destroy(simple_class);        unregister_chrdev_region(dev_num, 1);        printk(KERN_ERR "Simple Char Driver: Failed to create device\n");return PTR_ERR(simple_device);    }    printk(KERN_INFO "Simple Char Driver: Initialized successfully\n");return0;}// 模块退出函数staticvoid __exit simple_exit(void){    printk(KERN_INFO "Simple Char Driver: Exiting\n");// 1. 销毁设备文件    device_destroy(simple_class, dev_num);// 2. 删除cdev    cdev_del(&simple_dev->cdev);// 3. 释放设备结构体    kfree(simple_dev);// 4. 销毁设备类别    class_destroy(simple_class);// 5. 释放设备号    unregister_chrdev_region(dev_num, 1);    printk(KERN_INFO "Simple Char Driver: Exited successfully\n");}// 打开设备函数staticintsimple_open(struct inode *inode, struct file *file){structsimple_char_dev *dev;// 获取设备结构体指针    dev = container_of(inode->i_cdev, struct simple_char_dev, cdev);    file->private_data = dev;    printk(KERN_INFO "Simple Char Driver: Device opened\n");return0;}// 释放设备函数staticintsimple_release(struct inode *inode, struct file *file){    printk(KERN_INFO "Simple Char Driver: Device released\n");return0;}// 读取设备函数staticssize_tsimple_read(struct file *file, char __user *buf, size_t count, loff_t *pos){structsimple_char_dev *dev = file->private_data;ssize_t ret = 0;// 等待信号量if (down_interruptible(&dev->sem)) {return -ERESTARTSYS;    }// 检查读取位置是否超出范围if (*pos >= sizeof(dev->data)) {goto out;    }// 调整读取长度if (count > sizeof(dev->data) - *pos) {        count = sizeof(dev->data) - *pos;    }// 从内核空间复制到用户空间if (copy_to_user(buf, dev->data + *pos, count)) {        ret = -EFAULT;goto out;    }// 更新读取位置    *pos += count;    ret = count;    printk(KERN_INFO "Simple Char Driver: Read %ld bytes\n", count);out:    up(&dev->sem);return ret;}// 写入设备函数staticssize_tsimple_write(struct file *file, constchar __user *buf, size_t count, loff_t *pos){structsimple_char_dev *dev = file->private_data;ssize_t ret = 0;// 等待信号量if (down_interruptible(&dev->sem)) {return -ERESTARTSYS;    }// 检查写入位置是否超出范围if (*pos >= sizeof(dev->data)) {goto out;    }// 调整写入长度if (count > sizeof(dev->data) - *pos) {        count = sizeof(dev->data) - *pos;    }// 从用户空间复制到内核空间if (copy_from_user(dev->data + *pos, buf, count)) {        ret = -EFAULT;goto out;    }// 更新写入位置    *pos += count;    ret = count;    printk(KERN_INFO "Simple Char Driver: Written %ld bytes\n", count);out:    up(&dev->sem);return ret;}// IOCTL函数staticlongsimple_ioctl(struct file *file, unsignedint cmd, unsignedlong arg){structsimple_char_dev *dev = file->private_data;int ret = 0;// 等待信号量if (down_interruptible(&dev->sem)) {return -ERESTARTSYS;    }switch (cmd) {case0x100:  // 清除缓冲区memset(dev->data, 0sizeof(dev->data));            printk(KERN_INFO "Simple Char Driver: Buffer cleared\n");break;case0x101:  // 获取缓冲区大小            ret = copy_to_user((int __user *)arg, &(sizeof(dev->data)), sizeof(int));if (ret) {                ret = -EFAULT;            }break;default:            ret = -EINVAL;break;    }    up(&dev->sem);return ret;}// 模块注册module_init(simple_init);module_exit(simple_exit);// 模块信息MODULE_LICENSE("GPL");MODULE_AUTHOR("Your Name");MODULE_DESCRIPTION("A simple character device driver");MODULE_VERSION("1.0");

Makefile编写

创建一个Makefile用于编译内核模块:

obj-m += simple_char.oKDIR := /lib/modules/$(shell uname -r)/buildPWD := $(shell pwd)default:$(MAKE) -C $(KDIR) M=$(PWD) modulesclean:$(MAKE) -C $(KDIR) M=$(PWD) clean

编译与加载驱动

编译驱动

make

编译成功后,会生成以下文件:

  • • simple_char.ko:内核模块文件
  • • simple_char.mod.c:模块依赖信息
  • • simple_char.mod.o:编译后的模块依赖对象
  • • simple_char.o:编译后的驱动对象
  • • modules.order:模块顺序文件
  • • Module.symvers:模块符号版本文件

加载驱动

# 加载内核模块sudo insmod simple_char.ko# 查看是否加载成功lsmod | grep simple_char# 查看设备号cat /proc/devices | grep simple_char

创建设备文件

# 手动创建设备文件(如果device_create没有自动创建)sudomknod /dev/simple_char c <major> <minor># 设置设备文件权限sudochmod 666 /dev/simple_char

查看驱动日志

dmesg | grep "Simple Char Driver"

用户空间测试

用户空间测试程序test_simple_char.c验证:

#include<stdio.h>#include<fcntl.h>#include<unistd.h>#include<string.h>#include<sys/ioctl.h>#define DEVICE_FILE "/dev/simple_char"intmain() {int fd;char buffer[256];int size;// 打开设备文件    fd = open(DEVICE_FILE, O_RDWR);if (fd < 0) {        perror("Failed to open device file");return1;    }printf("Device opened successfully\n");// 写入数据constchar *test_data = "Hello, Linux Character Driver!";if (write(fd, test_data, strlen(test_data)) < 0) {        perror("Failed to write to device");        close(fd);return1;    }printf("Written: %s\n", test_data);// 重置文件位置    lseek(fd, 0, SEEK_SET);// 读取数据memset(buffer, 0sizeof(buffer));if (read(fd, buffer, sizeof(buffer)) < 0) {        perror("Failed to read from device");        close(fd);return1;    }printf("Read: %s\n", buffer);// 使用IOCTL获取缓冲区大小if (ioctl(fd, 0x101, &size) < 0) {        perror("Failed to get buffer size");        close(fd);return1;    }printf("Buffer size: %d bytes\n", size);// 使用IOCTL清除缓冲区if (ioctl(fd, 0x100) < 0) {        perror("Failed to clear buffer");        close(fd);return1;    }printf("Buffer cleared\n");// 验证缓冲区已清除    lseek(fd, 0, SEEK_SET);memset(buffer, 0sizeof(buffer));if (read(fd, buffer, sizeof(buffer)) < 0) {        perror("Failed to read from device");        close(fd);return1;    }printf("Read after clear: %s\n", buffer);// 关闭设备文件    close(fd);printf("Device closed\n");return0;}

编译并运行测试程序:

gcc -o test_simple_char test_simple_char.c./test_simple_char

卸载驱动

# 卸载内核模块sudo rmmod simple_char# 查看日志确认卸载

核心概念

设备号

  • • 主设备号:标识设备驱动
  • • 次设备号:标识同一驱动下的不同设备
  • • 设备号类型:dev_t(32位,高12位主设备号,低20位次设备号)

file_operations结构体

成员函数
功能
owner
模块所有者
open
打开设备
release
关闭设备
read
从设备读取数据
write
向设备写入数据
unlocked_ioctl
设备控制命令
llseek
定位文件指针

用户空间与内核空间数据交换

数据交换机制

Linux内核提供了专门的函数用于用户空间和内核空间之间的数据交换:

  • • copy_to_user():从内核空间复制数据到用户空间
  • • copy_from_user():从用户空间复制数据到内核空间
  • • get_user():获取单个用户空间数据
  • • put_user():写入单个数据到用户空间

数据交换流程图

内核缓冲区内核驱动用户空间程序内核缓冲区内核驱动用户空间程序write(fd, user_buf, count)检查参数和权限获取信号量copy_from_user()数据复制完成释放信号量返回写入字节数read(fd, user_buf, count)检查参数和权限获取信号量读取数据copy_to_user()释放信号量返回读取字节数

同步机制

  • • 信号量:用于保护共享资源,防止并发访问冲突
  • • 互斥锁:用于确保同一时间只有一个进程访问资源
  • • 自旋锁:用于内核态下的短时间同步

总结

驱动开发关键

  1. 1. 设备号管理:分配、注册和释放设备号
  2. 2. cdev管理:初始化、添加和删除cdev结构
  3. 3. 设备文件管理:创建设备文件和类别
  4. 4. file_operations实现:实现设备的各种操作方法
  5. 5. 同步机制:保护共享资源,防止并发访问冲突
  6. 6. 数据交换:正确处理用户空间和内核空间的数据传输

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-08 14:04:26 HTTP/2.0 GET : https://f.mffb.com.cn/a/464205.html
  2. 运行时间 : 0.224135s [ 吞吐率:4.46req/s ] 内存消耗:4,477.44kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=3a27abefbebac5fd1decc17293b6e6a7
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000947s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001481s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000682s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.003502s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001402s ]
  6. SELECT * FROM `set` [ RunTime:0.002447s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001563s ]
  8. SELECT * FROM `article` WHERE `id` = 464205 LIMIT 1 [ RunTime:0.004542s ]
  9. UPDATE `article` SET `lasttime` = 1770530666 WHERE `id` = 464205 [ RunTime:0.007131s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 67 LIMIT 1 [ RunTime:0.000728s ]
  11. SELECT * FROM `article` WHERE `id` < 464205 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.006244s ]
  12. SELECT * FROM `article` WHERE `id` > 464205 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.013484s ]
  13. SELECT * FROM `article` WHERE `id` < 464205 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.041987s ]
  14. SELECT * FROM `article` WHERE `id` < 464205 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.032905s ]
  15. SELECT * FROM `article` WHERE `id` < 464205 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.020087s ]
0.227897s