Procházet zdrojové kódy

Kernel: Add comment block about File, taking some from Device.

Andreas Kling před 6 roky
rodič
revize
8454d3e184
2 změnil soubory, kde provedl 27 přidání a 24 odebrání
  1. 0 24
      Kernel/Devices/Device.h
  2. 27 0
      Kernel/File.h

+ 0 - 24
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 <Kernel/File.h>
 #include <Kernel/UnixTypes.h>
 

+ 27 - 0
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<File> {
 public:
     virtual ~File();