reactos/boot
Hermès Bélusca-Maïto 5d361b602d
[FREELDR] fs.c: Fix handling of file handles, (de)referencing, and direct-device access (#7414)
- The original code was just incrementing the reference counts (RefCounts)
  of the device objects or the device/file handles, without decrementing
  them when closing the handles. This is now fixed.

  Notice the following:

  * When opening a file on a device (disk), the device's (and its
    handle's) RefCount is incremented, and the file handle's RefCount
    is incremented as well.

  * When closing a file, the file handle's RefCount is decremented
    (and the file closed if the RefCount reaches zero), and the file's
    parent device handle is also closed, recursively.
    This has the effect of decrementing the parent device handle's
    RefCount, and the device's own RefCount is decremented as well.

  IMPORTANT NOTE: The usefulness of handle-level RefCount is still
  under question, and might be (consistently) removed in the future.

- Fix opening a device (disk) in direct access, when this device is
  already opened. Indeed, we previously allowed direct access only if
  the device was opened as such for the very first time (its RefCount
  = 0 originally); no filesystem mounting was attempted as well.
  Then for any later open-operations on this device (while keeping an
  already-opened handle to it), filesystem access was assumed.

  Thus, this problem would show up in two ways:

  * Either the device is first opened for direct access, this succeeded
    and no filesystem was mounted. Then, for any other open-operations,
    the filesystem was NOT mounted, and opening files on it would fail.
    Direct accesses would succeed but would create an unnecessary second
    file handle.

  * Or, the device is first opened for file-access: a filesystem was
    mounted and file opening would succeed. Any other file opening
    operation would succeed as well (if the file exists). But, a direct
    access open-operation would fail, because now any open-operations on
    the device would be assumed to be a file opening.

  This is now correctly fixed. If direct-open is requested, just do it.
  If this is a file opening, we open the device, then try to mount a
  filesystem on it (if not already done), then we try to open the file.

  If file opening fails, derereference the device.

- Pass the file path to the filesystem-specific Open() functions without
  truncating the leading path separator, if any. This has to be handled
  by the filesystem routines themselves.
2024-10-16 22:20:52 +02:00
..
armllb [REACTOS] Add missing line breaks at end of file 2024-10-06 10:47:11 +03:00
bcd
bgfx
bootdata [BOOTDATA] Fix LiveCD autorun (#7282) 2024-08-30 10:16:31 +03:00
environ [REACTOS] Add missing line breaks at end of file 2024-10-06 10:47:11 +03:00
freeldr [FREELDR] fs.c: Fix handling of file handles, (de)referencing, and direct-device access (#7414) 2024-10-16 22:20:52 +02:00
rtl
boot_images.cmake Revert "[BOOT] Don't create CSIDL_ADMINTOOLS folder in initial (#6551)" (#7017) 2024-06-14 11:08:14 +09:00
CMakeLists.txt