From 8454d3e184499feec4b7c623191087b110fd9728 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 2 Jun 2019 09:23:37 +0200 Subject: [PATCH] Kernel: Add comment block about File, taking some from Device. --- Kernel/Devices/Device.h | 24 ------------------------ Kernel/File.h | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Kernel/Devices/Device.h b/Kernel/Devices/Device.h index 93817896e8..7c19a9fea9 100644 --- a/Kernel/Devices/Device.h +++ b/Kernel/Devices/Device.h @@ -9,30 +9,6 @@ // There are two main subclasses: // - BlockDevice (random access) // - CharacterDevice (sequential) -// -// The most important functions in Device are: -// -// class_name() -// - Used in the /proc filesystem to identify the type of Device. -// -// read() and write() -// - Implement reading and writing. -// - Return the number of bytes read/written, OR a negative error code. -// -// can_read() and can_write() -// -// - Used to implement blocking I/O, and the select() and poll() syscalls. -// - Return true if read() or write() would succeed, respectively. -// - Note that can_read() should return true in EOF conditions, -// and a subsequent call to read() should return 0. -// -// ioctl() -// -// - Optional. If unimplemented, ioctl() on the device will fail with -ENOTTY. -// - Can be overridden in subclasses to implement arbitrary functionality. -// - Subclasses should take care to validate incoming addresses before dereferencing. -// - #include #include diff --git a/Kernel/File.h b/Kernel/File.h index 7398c2a180..c0ad044482 100644 --- a/Kernel/File.h +++ b/Kernel/File.h @@ -12,6 +12,33 @@ class FileDescriptor; class Process; class Region; +// File is the base class for anything that can be referenced by a FileDescriptor. +// +// The most important functions in File are: +// +// read() and write() +// - Implement reading and writing. +// - Return the number of bytes read/written, OR a negative error code. +// +// can_read() and can_write() +// +// - Used to implement blocking I/O, and the select() and poll() syscalls. +// - Return true if read() or write() would succeed, respectively. +// - Note that can_read() should return true in EOF conditions, +// and a subsequent call to read() should return 0. +// +// ioctl() +// +// - Optional. If unimplemented, ioctl() on this File will fail with -ENOTTY. +// - Can be overridden in subclasses to implement arbitrary functionality. +// - Subclasses should take care to validate incoming addresses before dereferencing. +// +// mmap() +// +// - Optional. If unimplemented, mmap() on this File will fail with -ENODEV. +// - Called by mmap() when userspace wants to memory-map this File somewhere. +// - Should create a Region in the Process and return it if successful. + class File : public Retainable { public: virtual ~File();