| .. | .. |
|---|
| 1 | | -Chinese translated version of Documentation/filesystems/sysfs.txt |
|---|
| 1 | +Chinese translated version of Documentation/filesystems/sysfs.rst |
|---|
| 2 | 2 | |
|---|
| 3 | 3 | If you have any comment or update to the content, please contact the |
|---|
| 4 | 4 | original document maintainer directly. However, if you have a problem |
|---|
| .. | .. |
|---|
| 10 | 10 | Mike Murphy <mamurph@cs.clemson.edu> |
|---|
| 11 | 11 | Chinese maintainer: Fu Wei <tekkamanninja@gmail.com> |
|---|
| 12 | 12 | --------------------------------------------------------------------- |
|---|
| 13 | | -Documentation/filesystems/sysfs.txt 的中文翻译 |
|---|
| 13 | +Documentation/filesystems/sysfs.rst 的中文翻译 |
|---|
| 14 | 14 | |
|---|
| 15 | 15 | 如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文 |
|---|
| 16 | 16 | 交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻 |
|---|
| .. | .. |
|---|
| 40 | 40 | 数据结构及其属性,以及它们之间的关联到用户空间的方法。 |
|---|
| 41 | 41 | |
|---|
| 42 | 42 | sysfs 始终与 kobject 的底层结构紧密相关。请阅读 |
|---|
| 43 | | -Documentation/kobject.txt 文档以获得更多关于 kobject 接口的 |
|---|
| 43 | +Documentation/core-api/kobject.rst 文档以获得更多关于 kobject 接口的 |
|---|
| 44 | 44 | 信息。 |
|---|
| 45 | 45 | |
|---|
| 46 | 46 | |
|---|
| .. | .. |
|---|
| 154 | 154 | |
|---|
| 155 | 155 | 示例: |
|---|
| 156 | 156 | |
|---|
| 157 | | -#define to_dev(obj) container_of(obj, struct device, kobj) |
|---|
| 158 | 157 | #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) |
|---|
| 159 | 158 | |
|---|
| 160 | 159 | static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr, |
|---|
| 161 | 160 | char *buf) |
|---|
| 162 | 161 | { |
|---|
| 163 | 162 | struct device_attribute *dev_attr = to_dev_attr(attr); |
|---|
| 164 | | - struct device *dev = to_dev(kobj); |
|---|
| 163 | + struct device *dev = kobj_to_dev(kobj); |
|---|
| 165 | 164 | ssize_t ret = -EIO; |
|---|
| 166 | 165 | |
|---|
| 167 | 166 | if (dev_attr->show) |
|---|
| .. | .. |
|---|
| 213 | 212 | |
|---|
| 214 | 213 | - 缓冲区应总是 PAGE_SIZE 大小。对于i386,这个值为4096。 |
|---|
| 215 | 214 | |
|---|
| 216 | | -- show() 方法应该返回写入缓冲区的字节数,也就是 snprintf()的 |
|---|
| 215 | +- show() 方法应该返回写入缓冲区的字节数,也就是 scnprintf()的 |
|---|
| 217 | 216 | 返回值。 |
|---|
| 218 | 217 | |
|---|
| 219 | | -- show() 应始终使用 snprintf()。 |
|---|
| 218 | +- show() 方法在将格式化返回值返回用户空间的时候,禁止使用snprintf()。 |
|---|
| 219 | + 如果可以保证不会发生缓冲区溢出,可以使用sprintf(),否则必须使用 |
|---|
| 220 | + scnprintf()。 |
|---|
| 220 | 221 | |
|---|
| 221 | 222 | - store() 应返回缓冲区的已用字节数。如果整个缓存都已填满,只需返回 |
|---|
| 222 | 223 | count 参数。 |
|---|
| .. | .. |
|---|
| 281 | 282 | 假定驱动没有跨越多个总线类型)。 |
|---|
| 282 | 283 | |
|---|
| 283 | 284 | fs/ 包含了一个为文件系统设立的目录。现在每个想要导出属性的文件系统必须 |
|---|
| 284 | | -在 fs/ 下创建自己的层次结构(参见Documentation/filesystems/fuse.txt)。 |
|---|
| 285 | +在 fs/ 下创建自己的层次结构(参见Documentation/filesystems/fuse.rst)。 |
|---|
| 285 | 286 | |
|---|
| 286 | 287 | dev/ 包含两个子目录: char/ 和 block/。在这两个子目录中,有以 |
|---|
| 287 | 288 | <major>:<minor> 格式命名的符号链接。这些符号链接指向 sysfs 目录 |
|---|
| 288 | 289 | 中相应的设备。/sys/dev 提供一个通过一个 stat(2) 操作结果,查找 |
|---|
| 289 | 290 | 设备 sysfs 接口快捷的方法。 |
|---|
| 290 | 291 | |
|---|
| 291 | | -更多有关 driver-model 的特性信息可以在 Documentation/driver-model/ |
|---|
| 292 | +更多有关 driver-model 的特性信息可以在 Documentation/driver-api/driver-model/ |
|---|
| 292 | 293 | 中找到。 |
|---|
| 293 | 294 | |
|---|
| 294 | 295 | |
|---|