当前位置: 首页 > news >正文

linux 驱动, struct file , struct node, private_data

首先是关于什么是 praviate_data :

来看看正点原子是怎么使用的。

网上找的一些资料:

总结一下:

1 私有数据 是 struct file特有的。

2private_data 可以自己随便设置。

3 一般是在 open 函数中设置好,然后在 read, write 函数中使用。

4 private_data 一般是设置的 cdev, 以及 dev_t 结构体。

然后是 struct file 与 strcut node 的联系。

网上的资料:  这个文章总结的非常好。可以看到 struct file 与 struct node 是两条线。

然后是 struct file

先来看看网上的截图:

然后是 关于char_dev 的描述。

主设备号最大是 255 就是这么来的。

然后是关于cdev 的介绍。

然后是 struct node

疑问: 那么问题来了,到底,什么是字符设备呢?是为了解决什么问题呢?又懵逼了。

关于inode 的内容。

struct inode {  struct hlist_node i_hash;  struct list_head i_list;  struct list_head i_sb_list;  struct list_head i_dentry;  unsigned long  i_ino;  atomic_t  i_count;  unsigned int  i_nlink;  uid_t   i_uid;//inode拥有者id  gid_t   i_gid;//inode所属群组id  dev_t   i_rdev;//若是设备文件,表示记录设备的设备号  u64   i_version;  loff_t   i_size;//inode所代表大少  
#ifdef __NEED_I_SIZE_ORDERED  seqcount_t  i_size_seqcount;  
#endif  struct timespec  i_atime;//inode最近一次的存取时间  struct timespec  i_mtime;//inode最近一次修改时间  struct timespec  i_ctime;//inode的生成时间  unsigned int  i_blkbits;  blkcnt_t  i_blocks;  unsigned short          i_bytes;  umode_t   i_mode;  spinlock_t  i_lock;   struct mutex  i_mutex;  struct rw_semaphore i_alloc_sem;  const struct inode_operations *i_op;  const struct file_operations *i_fop;   struct super_block *i_sb;  struct file_lock *i_flock;  struct address_space *i_mapping;  struct address_space i_data;  
#ifdef CONFIG_QUOTA  struct dquot  *i_dquot[MAXQUOTAS];  
#endif  struct list_head i_devices;  union {  struct pipe_inode_info *i_pipe;  struct block_device *i_bdev;  struct cdev  *i_cdev;//若是字符设备,对应的为cdev结构  }; 
}; struct inode{...}

然后是是 文件系统对于 cdev 的访问, 这个我不是很理解,先复制过来。

http://www.lryc.cn/news/470292.html

相关文章:

  • ubuntu 硬盘扩容
  • cm211-1刷机教程镜像包
  • Android 15自定义设置导航栏与状态栏,EdgeToEdge适配
  • 设计模式概览
  • 力扣每日一题打卡 684. 冗余连接
  • 什么是微服务中的反应性扩展?
  • 【MyBatis】MyBatis-config标签详解
  • 使用AVPlayer进行音频播放开发基础设计
  • API网关的作用--为什么微服务需要一个API网关?
  • [0154].第5节:IDEA中创建Java Web工程
  • React03 组件 Props
  • 多线程——线程安全的集合类
  • 自动化数据库管理:如何通过存储过程动态创建 MySQL 对象
  • 480p 720p 1080p 2k 4k 8k 12k分辨率视频分别占用多大带宽?
  • unity中GameObject介绍
  • 洛谷——P8468 [Aya Round 1 C] 文文的构造游戏(01构造问题)
  • 双击热备和负载均衡的区别
  • 如何使用 cPanel 部署 WordPress临时网站
  • Android 自定义 Dialog 实现列表 单选,多选,搜索
  • 下载地址合辑(持续更新)
  • Android Kotlin 高阶函数详解及其在协程中的应用
  • CSS基础—网页布局(重点!)
  • 【Fargo】17:vs工程转qt构建:QT6 不支持32bit转向qt5.15.2
  • ​智能电表蓝牙芯片方案
  • miRNA分析流程学习(一)/TCGAmiRNA数据下载
  • 西南大学软件专硕考研难度分析!
  • 计算机前沿技术-人工智能算法-大语言模型-最新研究进展-2024-10-21
  • 安全芯片 OPTIGA TRUST M 使用介绍与示例(基于STM32裸机)
  • 【AI换装整合及教程】CatVTON:时尚与科技的完美融合
  • 接口测试(七)jmeter——参数化(RandomString函数)