mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-20 10:06:31 +00:00
kernel/src
@ -4,7 +4,10 @@ use crate::{
|
||||
base::{kobject::KObject, kset::KSet},
|
||||
},
|
||||
filesystem::{
|
||||
sysfs::{file::sysfs_emit_str, sysfs_instance, Attribute, BinAttribute, SysFSOpsSupport},
|
||||
sysfs::{
|
||||
file::sysfs_emit_str, sysfs_instance, Attribute, BinAttribute, SysFSOpsSupport,
|
||||
SYSFS_ATTR_MODE_RO,
|
||||
},
|
||||
vfs::syscall::ModeType,
|
||||
},
|
||||
libs::rwlock::RwLock,
|
||||
@ -131,11 +134,11 @@ impl Attribute for AttrForceRemove {
|
||||
}
|
||||
|
||||
fn mode(&self) -> ModeType {
|
||||
return ModeType::from_bits_truncate(0o444);
|
||||
SYSFS_ATTR_MODE_RO
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
return SysFSOpsSupport::SHOW;
|
||||
return SysFSOpsSupport::ATTR_SHOW;
|
||||
}
|
||||
|
||||
fn show(&self, _kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
|
||||
@ -224,7 +227,7 @@ impl Attribute for AttrAcpiTable {
|
||||
|
||||
impl BinAttribute for AttrAcpiTable {
|
||||
fn support_battr(&self) -> SysFSOpsSupport {
|
||||
return SysFSOpsSupport::READ;
|
||||
return SysFSOpsSupport::BATTR_READ;
|
||||
}
|
||||
fn write(
|
||||
&self,
|
||||
|
@ -12,7 +12,7 @@ use crate::{
|
||||
filesystem::{
|
||||
sysfs::{
|
||||
file::sysfs_emit_str, sysfs_instance, Attribute, AttributeGroup, SysFSOps,
|
||||
SysFSOpsSupport,
|
||||
SysFSOpsSupport, SYSFS_ATTR_MODE_RW, SYSFS_ATTR_MODE_WO,
|
||||
},
|
||||
vfs::syscall::ModeType,
|
||||
},
|
||||
@ -598,7 +598,7 @@ impl Attribute for BusAttrDriversProbe {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
return SysFSOpsSupport::STORE;
|
||||
return SysFSOpsSupport::ATTR_STORE;
|
||||
}
|
||||
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?r=&mo=5649&fi=241#241
|
||||
@ -628,7 +628,7 @@ struct BusAttrDriversAutoprobe;
|
||||
|
||||
impl Attribute for BusAttrDriversAutoprobe {
|
||||
fn mode(&self) -> ModeType {
|
||||
return ModeType::from_bits_truncate(0o644);
|
||||
SYSFS_ATTR_MODE_RW
|
||||
}
|
||||
|
||||
fn name(&self) -> &str {
|
||||
@ -636,7 +636,7 @@ impl Attribute for BusAttrDriversAutoprobe {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
return SysFSOpsSupport::STORE | SysFSOpsSupport::SHOW;
|
||||
return SysFSOpsSupport::ATTR_STORE | SysFSOpsSupport::ATTR_SHOW;
|
||||
}
|
||||
|
||||
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/bus.c?r=&mo=5649&fi=241#231
|
||||
@ -738,7 +738,7 @@ struct DriverAttrUnbind;
|
||||
|
||||
impl Attribute for DriverAttrUnbind {
|
||||
fn mode(&self) -> ModeType {
|
||||
ModeType::from_bits_truncate(0o200)
|
||||
SYSFS_ATTR_MODE_WO
|
||||
}
|
||||
|
||||
fn name(&self) -> &str {
|
||||
@ -774,7 +774,7 @@ impl Attribute for DriverAttrUnbind {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
}
|
||||
|
||||
@ -787,7 +787,7 @@ impl Attribute for DriverAttrBind {
|
||||
}
|
||||
|
||||
fn mode(&self) -> ModeType {
|
||||
ModeType::from_bits_truncate(0o200)
|
||||
SYSFS_ATTR_MODE_WO
|
||||
}
|
||||
|
||||
/*
|
||||
@ -825,7 +825,7 @@ impl Attribute for DriverAttrBind {
|
||||
return Err(SystemError::ENODEV);
|
||||
}
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,9 @@ use intertrait::cast::CastArc;
|
||||
use crate::{
|
||||
driver::base::kobject::KObject,
|
||||
filesystem::{
|
||||
sysfs::{file::sysfs_emit_str, sysfs_instance, Attribute, SysFSOpsSupport},
|
||||
sysfs::{
|
||||
file::sysfs_emit_str, sysfs_instance, Attribute, SysFSOpsSupport, SYSFS_ATTR_MODE_WO,
|
||||
},
|
||||
vfs::syscall::ModeType,
|
||||
},
|
||||
libs::wait_queue::WaitQueue,
|
||||
@ -615,7 +617,7 @@ impl Attribute for DeviceAttrStateSynced {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW
|
||||
SysFSOpsSupport::ATTR_SHOW
|
||||
}
|
||||
}
|
||||
|
||||
@ -628,11 +630,11 @@ impl Attribute for DeviceAttrCoredump {
|
||||
}
|
||||
|
||||
fn mode(&self) -> ModeType {
|
||||
ModeType::from_bits_truncate(0o200)
|
||||
SYSFS_ATTR_MODE_WO
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
|
||||
fn store(&self, kobj: Arc<dyn KObject>, buf: &[u8]) -> Result<usize, SystemError> {
|
||||
|
@ -711,7 +711,7 @@ impl DeviceManager {
|
||||
) -> Result<(), SystemError> {
|
||||
if unlikely(
|
||||
attr.mode().contains(ModeType::S_IRUGO)
|
||||
&& (!attr.support().contains(SysFSOpsSupport::SHOW)),
|
||||
&& (!attr.support().contains(SysFSOpsSupport::ATTR_SHOW)),
|
||||
) {
|
||||
kwarn!(
|
||||
"Attribute '{}': read permission without 'show'",
|
||||
@ -720,7 +720,7 @@ impl DeviceManager {
|
||||
}
|
||||
if unlikely(
|
||||
attr.mode().contains(ModeType::S_IWUGO)
|
||||
&& (!attr.support().contains(SysFSOpsSupport::STORE)),
|
||||
&& (!attr.support().contains(SysFSOpsSupport::ATTR_STORE)),
|
||||
) {
|
||||
kwarn!(
|
||||
"Attribute '{}': write permission without 'store'",
|
||||
@ -847,7 +847,7 @@ impl Attribute for DeviceAttrDev {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW
|
||||
SysFSOpsSupport::ATTR_SHOW
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ impl Attribute for AttrRotate {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW | SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_SHOW | SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/video/fbdev/core/fbcon.c#3226
|
||||
@ -297,7 +297,7 @@ impl Attribute for AttrRotateAll {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/video/fbdev/core/fbcon.c#3204
|
||||
@ -320,7 +320,7 @@ impl Attribute for AttrCursorBlink {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW | SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_SHOW | SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/video/fbdev/core/fbcon.c#3245
|
||||
|
@ -57,7 +57,7 @@ impl Attribute for AttrName {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW
|
||||
SysFSOpsSupport::ATTR_SHOW
|
||||
}
|
||||
|
||||
fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
|
||||
@ -81,7 +81,7 @@ impl Attribute for AttrBitsPerPixel {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW | SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_SHOW | SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
|
||||
fn store(&self, _kobj: Arc<dyn KObject>, _buf: &[u8]) -> Result<usize, SystemError> {
|
||||
@ -111,7 +111,7 @@ impl Attribute for AttrBlank {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
|
||||
// todo: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/video/fbdev/core/fbsysfs.c#309
|
||||
@ -134,7 +134,7 @@ impl Attribute for AttrMode {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW | SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_SHOW | SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/video/fbdev/core/fbsysfs.c#166
|
||||
@ -161,7 +161,7 @@ impl Attribute for AttrModes {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW | SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_SHOW | SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
|
||||
/// https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/video/fbdev/core/fbsysfs.c#206
|
||||
@ -188,7 +188,7 @@ impl Attribute for AttrPan {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW | SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_SHOW | SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
|
||||
fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
|
||||
@ -217,7 +217,7 @@ impl Attribute for AttrVirtualSize {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW | SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_SHOW | SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
|
||||
fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
|
||||
@ -249,7 +249,7 @@ impl Attribute for AttrStride {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW
|
||||
SysFSOpsSupport::ATTR_SHOW
|
||||
}
|
||||
|
||||
fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
|
||||
@ -273,7 +273,7 @@ impl Attribute for AttrRotate {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW | SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_SHOW | SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
|
||||
fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
|
||||
@ -303,7 +303,7 @@ impl Attribute for AttrState {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW | SysFSOpsSupport::STORE
|
||||
SysFSOpsSupport::ATTR_SHOW | SysFSOpsSupport::ATTR_STORE
|
||||
}
|
||||
|
||||
fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
|
||||
|
@ -575,7 +575,7 @@ impl Attribute for AnonAttrPhysAddr {
|
||||
}
|
||||
|
||||
fn support(&self) -> SysFSOpsSupport {
|
||||
SysFSOpsSupport::SHOW
|
||||
SysFSOpsSupport::ATTR_SHOW
|
||||
}
|
||||
|
||||
fn show(&self, _kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
|
||||
|
Reference in New Issue
Block a user