This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
tinynja98's profile picture

More directories = more disk space?

Started by tinynja98, 01 February 2015 - 10:58 PM
tinynja98 #1
Posted 01 February 2015 - 11:58 PM
Hello there,

I was messing around with the free space i had left on my disk and i realized that whenever i created a new DIRECTORY or when i delete an existing empty DIRECTORY, the size returned by fs.getFreeSpace() is 512 bytes bigger than without the new directory/empty file or removed directory/empty file. Can anyone explain this (is the disk size really increased by 512 or its an error/glitch) :huh:/>? Does this mean i could "glitch" my disk size to 1gb and not have to worry about disk space B)/>?

Proof:
Spoiler

P.S. Should i have posted this in the "bugs" section? If so, feel free to move this thread.

Thanks for your answers!
Dog #2
Posted 02 February 2015 - 03:16 AM
I believe that (or something very similar) was already reported in the bugs section.
Lyqyd #3
Posted 02 February 2015 - 03:54 AM
Moved to Bugs.
Xtansia #4
Posted 02 February 2015 - 09:45 AM
I tweeted Dan about this, he says it's fixed for the next version fixed for the next version
InDieTasten #5
Posted 02 February 2015 - 12:05 PM
maybe somone should create a custom section for the bios to prevent this for all past versions. Because I can already see how people will make a loop increasing the freeSpace and writing to it to the point, where the harddrive is full. I've heard of tekkit classic servers dealing with this issue to an extend, where 8TB RAID systems have been fludded with 100KB files in computers, so that theres no space left for the actual server.log file to be written.
I could imagine this can become a problem to all servers having computercraft installed to this moment, again.
Xtansia #6
Posted 02 February 2015 - 12:34 PM
maybe somone should create a custom section for the bios to prevent this for all past versions. Because I can already see how people will make a loop increasing the freeSpace and writing to it to the point, where the harddrive is full. I've heard of tekkit classic servers dealing with this issue to an extend, where 8TB RAID systems have been fludded with 100KB files in computers, so that theres no space left for the actual server.log file to be written.
I could imagine this can become a problem to all servers having computercraft installed to this moment, again.

You wouldn't be able to because of all the filesystem handling being done in Java
Edited on 02 February 2015 - 11:36 AM
InDieTasten #7
Posted 02 February 2015 - 12:37 PM
maybe somone should create a custom section for the bios to prevent this for all past versions. Because I can already see how people will make a loop increasing the freeSpace and writing to it to the point, where the harddrive is full. I've heard of tekkit classic servers dealing with this issue to an extend, where 8TB RAID systems have been fludded with 100KB files in computers, so that theres no space left for the actual server.log file to be written.
I could imagine this can become a problem to all servers having computercraft installed to this moment, again.

You wouldn't be able to because of all the filesystem handling being done in Java
It's a little complicated, but it's possible as you can override fs.open and fs.makeDir

oh, and copy, move and that stuff too ofcourse
InDieTasten #8
Posted 02 February 2015 - 01:09 PM
I am currently not able to test this, but does the freespace reset after the mod gets reloaded (ie. server restart)?
I would guess so, so only current directorys need to be taken into account, when writing a fix. (Since you can't save the difference between getFreeSpace and the realFreeSpace in case of any reboots/shutdowns of the computers without a file, which would make this stuff even harder to fix within lua in a secure manner
Bomb Bloke #9
Posted 02 February 2015 - 01:31 PM
In the past, I've found that sometimes getFreeSpace starts returning 0 no matter how much data is really on the system (typically after attempting to write a load of data to an open file, enough to actually fill the "drive"). This typically requires a restart of the entire game in order to correct it - just rebooting the affected computer isn't enough, let alone simply emptying out its drive via eg Windows Explorer.
dan200 #10
Posted 02 February 2015 - 09:20 PM
Fixed in 1.66pr4