mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 20:05:07 +00:00
Kernel: Use KString instead of String in InodeWatcher::Event's path
This commit is contained in:
parent
d5189b6677
commit
3c1ca61e74
2 changed files with 10 additions and 7 deletions
|
@ -37,10 +37,9 @@ ErrorOr<size_t> InodeWatcher::read(OpenFileDescription&, u64, UserOrKernelBuffer
|
||||||
|
|
||||||
auto event = m_queue.dequeue();
|
auto event = m_queue.dequeue();
|
||||||
|
|
||||||
size_t name_length = event.path.length() + 1;
|
|
||||||
size_t bytes_to_write = sizeof(InodeWatcherEvent);
|
size_t bytes_to_write = sizeof(InodeWatcherEvent);
|
||||||
if (!event.path.is_null())
|
if (event.path)
|
||||||
bytes_to_write += name_length;
|
bytes_to_write += event.path->length() + 1;
|
||||||
|
|
||||||
if (buffer_size < bytes_to_write)
|
if (buffer_size < bytes_to_write)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
@ -53,10 +52,11 @@ ErrorOr<size_t> InodeWatcher::read(OpenFileDescription&, u64, UserOrKernelBuffer
|
||||||
memcpy(bytes.offset(offset), &event.type, sizeof(InodeWatcherEvent::type));
|
memcpy(bytes.offset(offset), &event.type, sizeof(InodeWatcherEvent::type));
|
||||||
offset += sizeof(InodeWatcherEvent::type);
|
offset += sizeof(InodeWatcherEvent::type);
|
||||||
|
|
||||||
if (!event.path.is_null()) {
|
if (event.path) {
|
||||||
|
size_t name_length = event.path->length() + 1;
|
||||||
memcpy(bytes.offset(offset), &name_length, sizeof(InodeWatcherEvent::name_length));
|
memcpy(bytes.offset(offset), &name_length, sizeof(InodeWatcherEvent::name_length));
|
||||||
offset += sizeof(InodeWatcherEvent::name_length);
|
offset += sizeof(InodeWatcherEvent::name_length);
|
||||||
memcpy(bytes.offset(offset), event.path.characters(), name_length);
|
memcpy(bytes.offset(offset), event.path->characters(), name_length);
|
||||||
} else {
|
} else {
|
||||||
memset(bytes.offset(offset), 0, sizeof(InodeWatcherEvent::name_length));
|
memset(bytes.offset(offset), 0, sizeof(InodeWatcherEvent::name_length));
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,10 @@ void InodeWatcher::notify_inode_event(Badge<Inode>, InodeIdentifier inode_id, In
|
||||||
if (!(watcher.event_mask & static_cast<unsigned>(event_type)))
|
if (!(watcher.event_mask & static_cast<unsigned>(event_type)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_queue.enqueue({ watcher.wd, event_type, name });
|
OwnPtr<KString> path;
|
||||||
|
if (!name.is_null())
|
||||||
|
path = KString::try_create(name).release_value_but_fixme_should_propagate_errors();
|
||||||
|
m_queue.enqueue({ watcher.wd, event_type, move(path) });
|
||||||
evaluate_block_conditions();
|
evaluate_block_conditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ private:
|
||||||
struct Event {
|
struct Event {
|
||||||
int wd { 0 };
|
int wd { 0 };
|
||||||
InodeWatcherEvent::Type type { InodeWatcherEvent::Type::Invalid };
|
InodeWatcherEvent::Type type { InodeWatcherEvent::Type::Invalid };
|
||||||
String path;
|
OwnPtr<KString> path;
|
||||||
};
|
};
|
||||||
CircularQueue<Event, 32> m_queue;
|
CircularQueue<Event, 32> m_queue;
|
||||||
Checked<int> m_wd_counter { 1 };
|
Checked<int> m_wd_counter { 1 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue