mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:27:46 +00:00
Kernel: Add comment block about File, taking some from Device.
This commit is contained in:
parent
e24f18dd83
commit
8454d3e184
2 changed files with 27 additions and 24 deletions
|
@ -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 <Kernel/File.h>
|
||||
#include <Kernel/UnixTypes.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<File> {
|
||||
public:
|
||||
virtual ~File();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue