Possibility to use sftp version of "df" with "rclone mount"

Hey,

Is it possible for rclone to use the sftp version of "df" when running "rclone mount"? Currently it tries to access the shell version using "df -k", but sftp doesn't support that parameter, and the available space is shown incorrectly. At a quick glance, it looks like the sftp version of "df" could be sufficient enough to provide used and available size.

$ df -k /smallboi/backup/bindi/encrypted/
Filesystem              1K-blocks    Used   Available Use% Mounted on
smallboi/backup/bindi 14387542016 3227648 14384314368   1% /smallboi/backup/bindi

vs.

sftp> df /smallboi/backup/bindi/encrypted
        Size         Used        Avail       (root)    %Capacity
 14387542016      3227648  14384314368  14384314368           0%

hello and welcome to the forum,

sorry, i am confused as both commands show the same available space?

Available
14384314368

and

Avail      
14384314368

They do show the same space, that's exactly my point. However when the SSH server is configured to use sftp-internal only, the users are not allowed to execute df -k, and rclone mount shows available space incorrectly (1.0PB free).

But the information is there, just by running "df" (sftp mode) instead of "df -k" (ssh mode) and parsing it.

Edit: I worded it incorrectly, the user is allowed to execute "df", just that sftp-internal version of "df" does not support the parameter "-k", and it exits with an error:

Encrypted drive 'salattu:': Statfs failed: your remote may not support About: failed to run "df -k /smallboi/backup/bindi/encrypted": : Process exited with status 1

However as I said, the information is out there, just by running "df" without the parameter! :slight_smile:

ok, now with the added info, i understand.

If I'm not mistaken, it would be a downstream fix as rclone uses a SFTP library.

pkg/sftp: SFTP support for the go.crypto/ssh package (github.com)

So you'd have to log something for them to support it.

Is that correct @ncw ?

Probably not...

./backend/sftp/sftp.go: stdout, err := f.run(ctx, "df -k "+escapedPath)

My guess is that should become a simple df and then the parseUsage() function modified to handle the resulting new output.

Feel free to submit a PR...

Shouldn't this be used instead of just parsing the "df" command? Both the "df" command and StatVFS require implementation of the statvfs@openssh.com feature, so I think it would make sense to use the library functions instead of a parser.

There is actually a pull request for rclone which includes implementation of StatVFS for the about command (even though the main purpose of the PR is Windows support):

2 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.