我的属性太不讲究了,我该怎么办? [英] My attributes are way too racy, what should I do?

查看:71
本文介绍了我的属性太不讲究了,我该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在linux设备驱动程序中,在probe中创建sysfs属性太不明智了-具体来说, struct device_driver 为此包含 const struct attribute_group **groups 目的.

In a linux device driver, creating sysfs attributes in probe is way too racy--specifically, it experiences a race condition with userspace. The recommended workaround is to add your attributes to various default attribute groups so they can be automatically created before probe. For a device driver, struct device_driver contains const struct attribute_group **groups for this purpose.

但是, struct attribute_group 在Linux 3.11中只有一个二进制属性字段 .对于较旧的内核(特别是3.4),设备驱动程序应如何在探查之前创建sysfs二进制属性?

However, struct attribute_group only got a field for binary attributes in Linux 3.11. With older kernels (specifically, 3.4), how should a device driver create sysfs binary attributes before probe?

推荐答案

引用(强调我的意思) Greg Kroah-Hartman 从他的对合并请求的评论( 通过合并了a href ="https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7a62711aacda8887d94c40daa199b37abb1d54e1" rel ="noreferrer"> href ="https://en.wikipedia.org/wiki/Linus_Torvalds" rel ="noreferrer"> Linus 作为3.11开发周期的一部分):

Quoting (emphasis mine) Greg Kroah-Hartman from his comment to a merge request (that was merged by Linus as a part of 3.11 development cycle):

这是一些用于3.11-rc2的驱动程序核心补丁.他们不是真的 错误修正,但一堆新的帮助程序宏可以使驱动程序正确运行 创建属性组,驱动程序和子系统需要修复这些属性组 错误创建sysfs文件(二进制和 正常)在告知用户空间该设备存在之后.

Here are some driver core patches for 3.11-rc2. They aren't really bugfixes, but a bunch of new helper macros for drivers to properly create attribute groups, which drivers and subsystems need to fix up a ton of race issues with incorrectly creating sysfs files (binary and normal) after userspace has been told that the device is present.

这也是创建二进制文件作为属性组的能力,以解决这种竞争状况,这在此之前是不可能的,所以这是我的驱动程序损坏了.

Also here is the ability to create binary files as attribute groups, to solve that race condition, which was impossible to do before this, so that's my fault the drivers were broken.

因此,看起来似乎真的没有办法在旧内核上解决此问题.

So it looks like there really is no way to solve this problem on old kernels.

这篇关于我的属性太不讲究了,我该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆