mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 15:05:07 +00:00
Kernel+FileManager: Disallow watch_file() in unsupported file systems
Currently only Ext2FS and TmpFS supports InodeWatchers. We now fail with ENOTSUPP if watch_file() is called on e.g ProcFS. This fixes an issue with FileManager chewing up all the CPU when /proc was opened. Watchers don't keep the watched Inode open, and when they close, the watcher FD will EOF. Since nothing else kept /proc open in FileManager, the watchers created for it would EOF immediately, causing a refresh over and over. Fixes #879.
This commit is contained in:
parent
7fea25943d
commit
5292f6e78f
6 changed files with 21 additions and 9 deletions
|
@ -341,21 +341,23 @@ void GDirectoryModel::open(const StringView& a_path)
|
|||
if (!dirp)
|
||||
return;
|
||||
closedir(dirp);
|
||||
if (m_notifier)
|
||||
if (m_notifier) {
|
||||
close(m_notifier->fd());
|
||||
m_notifier = nullptr;
|
||||
}
|
||||
m_path = path;
|
||||
int watch_fd = watch_file(path.characters(), path.length());
|
||||
if (watch_fd < 0) {
|
||||
perror("watch_file");
|
||||
ASSERT_NOT_REACHED();
|
||||
} else {
|
||||
m_notifier = CNotifier::construct(watch_fd, CNotifier::Event::Read);
|
||||
m_notifier->on_ready_to_read = [this] {
|
||||
update();
|
||||
char buffer[32];
|
||||
int rc = read(m_notifier->fd(), buffer, sizeof(buffer));
|
||||
ASSERT(rc >= 0);
|
||||
};
|
||||
}
|
||||
m_notifier = CNotifier::construct(watch_fd, CNotifier::Event::Read);
|
||||
m_notifier->on_ready_to_read = [this] {
|
||||
update();
|
||||
char buffer[32];
|
||||
int rc = read(m_notifier->fd(), buffer, sizeof(buffer));
|
||||
ASSERT(rc >= 0);
|
||||
};
|
||||
if (on_path_change)
|
||||
on_path_change();
|
||||
update();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue