ValveSoftware / steam-for-linux

Issue tracking for the Steam for Linux beta client
4.21k stars 174 forks source link

Disk space check before "Discovering existing files" #3226

Open kaydenl opened 10 years ago

kaydenl commented 10 years ago

I installed Steam on a new computer, and copied over my SteamApps folder from another machine so I wouldn't have to re-download ~150GB of games.

Normally, clicking "Install" then causes Steam to "Discover existing files..." and skip downloading the game (or only download a small amount of updates). This is great.

However, it doesn't work when you're low on disk space. Steam first checks that there's enough hard drive space for a full install. If there isn't, it refuses to continue, so it never reaches the "Discover existing files" step...when it would realize it actually needs 0 MB of space.

Thanks for your time!

Sephiroth1983 commented 9 years ago

Indeed, this issue is annoying.

AsgerHB commented 6 years ago

The issue that has been referenced is closed, reason cited is that it's a duplicate of this issue.("Circular reference: See Reference, Circular") This issue is preventing me from discovering files on external drive, robbing me of an hour's playtime with my little brother before I have to catch the bus.

kgagnon commented 6 years ago

After 4 years do we know if this will be fixed?

tchebb commented 6 years ago

Since this issue is still not fixed, I have created a workaround which uses LD_PRELOAD to override the function that Steam uses to find the free space and make it think that the disk has 0% usage. Save the following as fakefree.c and follow the instructions in the header:

/*
 * Intercept calls to statvfs64(), which is used by Steam to determine
 * free disk space, and indicate that all space is available. This is
 * needed to work around the fact that Steam checks available disk space
 * before it checks for existing files.
 *
 * Please ONLY use this preload when you need it to install a game, then
 * relaunch Steam without it so that disk space detection works again.
 *
 * To compile:
 *   gcc -shared -fPIC -m32 -o fakefree.so fakefree.c -ldl
 *
 * To use (after ensuring Steam is not running):
 *   LD_PRELOAD=<path-to-fakefree.so> steam
 *
 * This code is Public Domain.
 */
#define _GNU_SOURCE
#include <stdlib.h>
#include <dlfcn.h>
#include <sys/statvfs.h>

int statvfs64(const char *path, struct statvfs64 *buf)
{
    static int (*real)(const char *, struct statvfs64 *) = NULL;
    if (real == NULL)
        real = dlsym(RTLD_NEXT, "statvfs64");

    int ret = real(path, buf);
    buf->f_bfree = buf->f_blocks;
    buf->f_bavail = buf->f_blocks;
    return ret;
}
Adel-Magebinary commented 6 years ago

fakefree.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.

tchebb commented 6 years ago

@Adel-Magebinary You'll see that even if it's working properly, as Steam launches both 32-bit and 64-bit executables when it runs. fakefree.so needs to be 32-bit, as the main Steam executable (the one that needs to be tricked) is 32-bit. If it's not working for you, make sure you have a compiler that can cross-compile to 32-bit, and make sure that you pass it -m32 when you build the library.

You can verify that your library is 32-bit by running file fakefree.so. The output should be something like

fakefree.so: ELF 32-bit LSB pie executable Intel 80386 ...
burjui commented 6 years ago

I wonder what can I do on Windows to work around this bug. I installed Windows specifically for Rainbow Six: Siege, which is now 70 GB in size, and my SSD is only 256 GB. Since I have a Russian version of the game, which I didn't ask for (I live in Kaliningrad and play on EU servers anyway), but was forced to use by Steam, for every "new operation" update I have to add English sound files and fix some ini files. After Operation Grim Sky landed, I did this again. This time voices stayed Russian, despite everything I did to change it to English.

I tried reinstalling the game with existing files, but Steam tells me that I can't do that, because I only have 300 MB of free space. But I have all the files, why should I need any free space to do that? So now I have to delete some other useful stuff to just reinstall the game. Thanks Valve for keeping me occupied.

Pretty please fix the damn bug already

ijurisic commented 6 years ago

I try fakefree.c fix:

LD_PRELOAD=fakefree.so steam ERROR: ld.so: object 'fakefree.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. ERROR: ld.so: object 'fakefree.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. Running Steam on debian 9 64-bit STEAM_RUNTIME is enabled automatically Pins up-to-date! [2018-09-10 19:30:05] Startup - updater built Aug 29 2018 20:06:41 [2018-09-10 19:30:05] Verifying installation... [2018-09-10 19:30:05] Verification complete html_chrome.cpp (394) : Assertion Failed: CefCrashReportingEnabled()

[2018-09-10 19:30:16] Shutdown

I check fakefree.so with:

file fakefree.so fakefree.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=f50e19eb6dc0c58bf7e63d67b770b13266f1b18d, not stripped

ldd fakefree.so linux-gate.so.1 (0xf7f94000) libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf7f69000) libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7db2000) /lib/ld-linux.so.2 (0xf7f96000)

All looks normal but can't assertion of code. Any idea how to fix?

tchebb commented 6 years ago

LD_PRELOAD needs to contain the full (absolute) path to fakefree.so, otherwise the loader won't be able to find it.

ijurisic commented 6 years ago

Thanks, but now have error:

LD_PRELOAD=/home/ijurisic/Downloads/fakefree.so steam ERROR: ld.so: object '/home/ijurisic/Downloads/fakefree.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored. ERROR: ld.so: object '/home/ijurisic/Downloads/fakefree.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored. Running Steam on debian 9 64-bit STEAM_RUNTIME is enabled automatically Pins up-to-date! [2018-09-10 22:23:43] Startup - updater built Aug 29 2018 20:06:41 [2018-09-10 22:23:43] Verifying installation... [2018-09-10 22:23:43] Verification complete html_chrome.cpp (394) : Assertion Failed: CefCrashReportingEnabled()

ok I re-compile without -m32 I got result:

LD_PRELOAD=/home/ijurisic/Downloads/fakefree.so steam ERROR: ld.so: object '/home/ijurisic/Downloads/fakefree.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored. ERROR: ld.so: object '/home/ijurisic/Downloads/fakefree.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored. Running Steam on debian 9 64-bit STEAM_RUNTIME is enabled automatically Pins up-to-date! [2018-09-10 22:38:08] Startup - updater built Aug 29 2018 20:06:41 [2018-09-10 22:38:08] Verifying installation... [2018-09-10 22:38:08] Verification complete html_chrome.cpp (394) : Assertion Failed: CefCrashReportingEnabled()

tchebb commented 6 years ago

@ijurisic You definitely want to compile with -m32. The "wrong ELF class: ELFCLASS32" error is expected and can be safely ignored. Is Steam starting after printing those log messages? If so, you should be fine; try installing a game. If not, please verify that it starts properly without LD_PRELOAD. If it still crashes, try rebooting or logging out—when I was developing the workaround, I somehow got Steam into a state where it wouldn't start at all, and rebooting fixed it.

ryao commented 6 years ago

@tchebb I don't like how you handled this in your wrapper. I am not in a position to test, but I think something like this would work better:

/*
 * Intercept calls to statvfs64(), which is used by Steam to determine
 * free disk space, and indicate that all space is available. This is
 * needed to work around the fact that Steam checks available disk space
 * before it checks for existing files.
 *
 * Please ONLY use this preload when you need it to install a game, then
 * relaunch Steam without it so that disk space detection works again.
 *
 * To compile:
 *   gcc -shared -fPIC -m32 -o fakefree.so fakefree.c -ldl
 *
 * To use (after ensuring Steam is not running):
 *   LD_PRELOAD=<path-to-fakefree.so> steam
 *
 * This code is Public Domain.
 */
#define _GNU_SOURCE
#include <stdlib.h>
#include <limits.h>
#include <dlfcn.h>
#include <sys/statvfs.h>

void limitField(fsfilcnt64_t *field, fsfilcnt64_t size)
{
        if (*field * size > (((fsfilcnt64_t)INT_MAX) << 9)) {
                *field = (((fsfilcnt64_t)INT_MAX) << 9) / size;
        }
}

int statvfs64(const char *path, struct statvfs64 *buf)
{
        static int (*real)(const char *, struct statvfs64 *) = NULL;
        if (real == NULL)
                real = dlsym(RTLD_NEXT, "statvfs64");

        int ret = real(path, buf);

        limitField(&buf->f_bfree, buf->f_frsize);
        limitField(&buf->f_bavail, buf->f_frsize);

        return ret;
}

It might need a limitField(&buf->f_blocks, buf->f_frsize); line too. The idea being to limit the fields to a 2TB volume size, which is the largest that we can represent with a 32-bit signed integer and a sector size of 512-bytes. The data in #4982 suggests that Steam is trying to emulate that internally.

Francesco149 commented 5 years ago

@ryao you need to clear errno and ret to 0 because the stat call can return errno 75 and steam will bail out. other than that, INT_MAX << 9 seems to be a good value and it's working for me so far

rayza commented 5 years ago

This bug is still a thing and quite annoying! Please do the disk space check after you checked for existing files! Ideally even after finding out how much additional space needs to be allocated.

Managor commented 4 years ago

This should get fixed I recorded a demonstrative video before noticing that there already exists a report for this: https://www.youtube.com/watch?v=6ZxCIAs5VwI

MasterCATZ commented 3 years ago

so what is the current permanent fix for doing this ?

over 20tb free and steam still thinks it has no space to install on Linux I have no been able to install any new games for a year now

can someone just hard code a toggle switch into steam to allow installer to ignore reported space ?

someone closed the other 0 byte issue https://github.com/ValveSoftware/steam-for-linux/issues/5742

burjui commented 3 years ago

Come on, nobody's gonna fix this, the issue is more than 6 years old. This is how capitalism works: if money are flowing, nobody cares about the customer.

MasterCATZ commented 3 years ago

they would make more $ if I could install more .. especially during all this covid oh well I will just keep sniping all the cheap key codes when they pop up and add to collection

all steam seems to pay attention to is free space under home folder

burjui commented 3 years ago

The vast majority of people don't have the problem, so why spend time solving it? That's the logic they use, so don't get your hopes too high.

MasterCATZ commented 1 year ago

how ever I can no longer install anything again because the fake 2tb was all used up what other idea's are their ? I thought this would fake 2tb free space remaining but it fakes a 2tb volume size that steam then virtually fills up