1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-26 23:42:18 +00:00
Jonathan Coates 094e0d4f33 Fix mounts being usable after a disk is ejected
This probably fails "responsible disclosure", but it's not an RCE and
frankly the whole bug is utterly hilarious so here we are...

It's possible to open a file on a disk drive and continue to read/write
to them after the disk has been removed:

    local disk = peripheral.find("drive")
    local input = fs.open(fs.combine(disk.getMountPath(), "stream"), "rb")
    local output = fs.open(fs.combine(disk.getMountPath(), "stream"), "wb")
    disk.ejectDisk()

    -- input/output can still be interacted with.

This is pretty amusing, as now it allows us to move the disk somewhere
else and repeat - we've now got a private tunnel which two computers can
use to communicate.

Fixing this is intuitively quite simple - just close any open files
belonging to this mount. However, this is where things get messy thanks
to the wonderful joy of how CC's streams are handled.

As things stand, the filesystem effectively does the following flow::
 - There is a function `open : String -> Channel' (file modes are
   irrelevant here).

 - Once a file is opened, we transform it into some <T extends
   Closeable>. This is, for instance, a BufferedReader.

 - We generate a "token" (i.e. FileSystemWrapper<T>), which we generate
   a week reference to and map it to a tuple of our Channel and T. If
   this token is ever garbage collected (someone forgot to call close()
   on a file), then we close our T and Channel.

 - This token and T are returned to the calling function, which then
   constructs a Lua object.

The problem here is that if we close the underlying Channel+T before the
Lua object calls .close(), then it won't know the underlying channel is
closed, and you get some pretty ugly errors (e.g. "Stream Closed"). So
we've moved the "is open" state into the FileSystemWrapper<T>.

The whole system is incredibly complex at this point, and I'd really
like to clean it up. Ideally we could treat the HandleGeneric as the
token instead - this way we could potentially also clean up
FileSystemWrapperMount.

BBut something to play with in the future, and not when it's 10:30pm.

---

All this wall of text, and this isn't the only bug I've found with disks
today :/.
2021-05-16 13:23:37 +02:00
2021-05-15 06:46:23 -07:00
2021-02-22 01:42:34 -08:00
2021-03-27 16:40:59 -07:00
2018-12-17 18:09:32 +00:00
2017-09-10 20:45:24 +01:00
2021-05-16 09:18:02 +02:00
2021-05-16 09:18:02 +02:00
2017-11-14 22:42:03 +00:00
2017-11-14 22:42:03 +00:00
2017-06-28 21:39:54 +01:00
2021-05-15 10:31:59 -07:00
2021-05-15 10:31:59 -07:00
2021-03-28 22:49:15 -07:00

CC:Restitched Patchwork

This is a Work In Progress Port

it runs and works-ish CC: Restitched

Current build status Download CC: Restitched  on CurseForge

This is an fork of Zundrel/cc-tweaked-fabric who's goal was to port SquidDev-CC/CC-Tweaked to fabric. I picked up maintaining the mod because the team working on Zundrel's fork, admitted they had gotten lazy so I picked it up to make it up to snuff with CC:T

Contributing

Any contribution is welcome, be that using the mod, reporting bugs or contributing code. In order to start helping develop CC:R there are a few rules

  1. Any updates that port commits from CC:T, MUST follow the format defined in patchwork.md otherwise they will not be accepted,
    • Commit Message must be the same as it is in CC:T,
    • patchwork.md must be updated in the following format

    Comments, optional but useful if you had to do something differently than in CC:T (outside of Fabric/forge differences

    ```

    commitID

    commit title

    commit desc

    ```

  2. Follow the fabirc programming guidelines as close as possible. This means you have to use loom mappings,
  3. You cannot intentionally implement bugs and security vulnerabilities
  4. Unless the commit is a "patchwork" compliant commit, (IE: taken from CC:T), the lua code is off limits,s

Bleeding Edge Builds

Bleeding edge builds can be found here at github actions to simplify things

Community

If you need help getting started with CC: Tweaked, want to show off your latest project, or just want to chat about ComputerCraft, here is the Forum and the Discord

Known Issues

Main Known issue

  • Mods that add blocks that can be used as peripherals for CC:T On forge, dont work with CC:R.
    • This is because of the differences between forge and fabric, and that mod devs, to my knowledge have not agreed upon a standard method in which to implement cross compatibility between mods,
  • Storage Peripherals throw a java "StackOverflowError" when using pushItems(),
    • Work around, you are probably using pushItems(chest, 1) or simular. please use pushItems(chest, 1, nil, 1).

Known Working mods that add Peripherals

  • Please let me know of other mods that work with this one
    • Better End
    • Better Nether
Description
Modernized/improved/actually updated version of ComputerCraft: https://tweaked.cc
Readme 32 MiB
Languages
Java 73.7%
Lua 25%
Kotlin 0.6%
TypeScript 0.2%
Python 0.2%
Other 0.1%