Merge "ueventd: fix subsystem list logic issues"
This commit is contained in:
commit
edf03e23bb
3 changed files with 16 additions and 17 deletions
|
|
@ -386,26 +386,24 @@ void DeviceHandler::HandleDeviceEvent(const Uevent& uevent) {
|
||||||
if (StartsWith(uevent.path, "/devices")) {
|
if (StartsWith(uevent.path, "/devices")) {
|
||||||
links = GetBlockDeviceSymlinks(uevent);
|
links = GetBlockDeviceSymlinks(uevent);
|
||||||
}
|
}
|
||||||
} else if (StartsWith(uevent.subsystem, "usb")) {
|
|
||||||
if (uevent.subsystem == "usb") {
|
|
||||||
if (!uevent.device_name.empty()) {
|
|
||||||
devpath = "/dev/" + uevent.device_name;
|
|
||||||
} else {
|
|
||||||
// This imitates the file system that would be created
|
|
||||||
// if we were using devfs instead.
|
|
||||||
// Minors are broken up into groups of 128, starting at "001"
|
|
||||||
int bus_id = uevent.minor / 128 + 1;
|
|
||||||
int device_id = uevent.minor % 128 + 1;
|
|
||||||
devpath = StringPrintf("/dev/bus/usb/%03d/%03d", bus_id, device_id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// ignore other USB events
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (const auto subsystem =
|
} else if (const auto subsystem =
|
||||||
std::find(subsystems_.cbegin(), subsystems_.cend(), uevent.subsystem);
|
std::find(subsystems_.cbegin(), subsystems_.cend(), uevent.subsystem);
|
||||||
subsystem != subsystems_.cend()) {
|
subsystem != subsystems_.cend()) {
|
||||||
devpath = subsystem->ParseDevPath(uevent);
|
devpath = subsystem->ParseDevPath(uevent);
|
||||||
|
} else if (uevent.subsystem == "usb") {
|
||||||
|
if (!uevent.device_name.empty()) {
|
||||||
|
devpath = "/dev/" + uevent.device_name;
|
||||||
|
} else {
|
||||||
|
// This imitates the file system that would be created
|
||||||
|
// if we were using devfs instead.
|
||||||
|
// Minors are broken up into groups of 128, starting at "001"
|
||||||
|
int bus_id = uevent.minor / 128 + 1;
|
||||||
|
int device_id = uevent.minor % 128 + 1;
|
||||||
|
devpath = StringPrintf("/dev/bus/usb/%03d/%03d", bus_id, device_id);
|
||||||
|
}
|
||||||
|
} else if (StartsWith(uevent.subsystem, "usb")) {
|
||||||
|
// ignore other USB events
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
devpath = "/dev/" + Basename(uevent.path);
|
devpath = "/dev/" + Basename(uevent.path);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ class Subsystem {
|
||||||
friend class SubsystemParser;
|
friend class SubsystemParser;
|
||||||
|
|
||||||
Subsystem() {}
|
Subsystem() {}
|
||||||
|
Subsystem(std::string name) : name_(std::move(name)) {}
|
||||||
|
|
||||||
// Returns the full path for a uevent of a device that is a member of this subsystem,
|
// Returns the full path for a uevent of a device that is a member of this subsystem,
|
||||||
// according to the rules parsed from ueventd.rc
|
// according to the rules parsed from ueventd.rc
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ Result<Success> SubsystemParser::ParseSection(std::vector<std::string>&& args,
|
||||||
return Error() << "ignoring duplicate subsystem entry";
|
return Error() << "ignoring duplicate subsystem entry";
|
||||||
}
|
}
|
||||||
|
|
||||||
subsystem_.name_ = args[1];
|
subsystem_ = Subsystem(std::move(args[1]));
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue