TurboGit / hubicfuse

Support for mounting HubiC drive in GNU/Linux
MIT License
327 stars 55 forks source link

segment_above verification failed on rpi #120

Open Vebryn opened 8 years ago

Vebryn commented 8 years ago

Hi,

Similar to #64, size calculation is wrong on a Raspberry Pi B+. FiveGb size is 1073741824.

Debug source code :

  // check consistency
  const unsigned long FiveGb = (unsigned  long)5 * (unsigned long)(1 << 30);

  if (segment_above > FiveGb)
  {
    printf ("A segment cannot be larger than 5Gb %lu\n",FiveGb);
    return 1;
  }

Result :

# hubicfuse /mnt/hubic -o noauto_cache,sync_read,allow_other
A segment cannot be larger than 5Gb 1073741824

Why don't you set 5368709120 value to FiveGb ?

Best regards.

Vebryn commented 8 years ago

I think that all other calculations return a wrong value. I'm limited to 2Mb filesize. I get an operation not permitted error.

cp: error writing ‘./grafana_2.1_armv6l.tgz’: Operation not permitted
cp: failed to extend ‘./grafana_2.1_armv6l.tgz’: Operation not permitted
TurboGit commented 7 years ago

I'm not sure to see the issue.

const unsigned long FiveGb = (unsigned long)5 * (unsigned long)(1 << 30);

Is really 5Gb. On the RasP what the size for an unsigned long?

romanrm commented 7 years ago

Using the following program on a Raspberry Pi

#include <stdio.h>
int main()
{
    printf("sizeof(char) = %d\n", sizeof(char));
    printf("sizeof(short) = %d\n", sizeof(short));
    printf("sizeof(int) = %d\n", sizeof(int));
    printf("sizeof(long) = %d\n", sizeof(long));
    printf("sizeof(unsigned long) = %d\n", sizeof(unsigned long));
    printf("sizeof(long long) = %d\n", sizeof(long long));
    printf("sizeof(float) = %d\n", sizeof(float));
    printf("sizeof(double) = %d\n", sizeof(double));
    printf("sizeof(long double) = %d\n", sizeof(long double));
    return 0;
}

I get the output:

sizeof(char) = 1
sizeof(short) = 2
sizeof(int) = 4
sizeof(long) = 4
sizeof(unsigned long) = 4
sizeof(long long) = 8
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double) = 8

So it appears the size is 32-bit, limited to 4294967296, and it can't hold the value of 5 billion. It will wrap around (5368709120-4294967296) and produce the value 1073741824 that the user is seeing.

TurboGit commented 7 years ago

So that's a 32bit Raspberry Pi, and files above 4Gb cannot be supported.

romanrm commented 7 years ago

Is it not possible to switch to the "unsigned long long" type?

TurboGit commented 7 years ago

Is that supported on Raspberry Pi? And this is probably not supported on all 64bit machines. Not easy.

romanrm commented 7 years ago

Unsigned long long has the same 8 byte size both on 32-bit and on 64-bit machines. The updated test program:

#include <stdio.h>
int main()
{
    printf("sizeof(char) = %d\n", sizeof(char));
    printf("sizeof(short) = %d\n", sizeof(short));
    printf("sizeof(int) = %d\n", sizeof(int));
    printf("sizeof(long) = %d\n", sizeof(long));
    printf("sizeof(unsigned long) = %d\n", sizeof(unsigned long));
    printf("sizeof(long long) = %d\n", sizeof(long long));
    printf("sizeof(unsigned long long) = %d\n", sizeof(unsigned long long));
    printf("sizeof(float) = %d\n", sizeof(float));
    printf("sizeof(double) = %d\n", sizeof(double));
    printf("sizeof(long double) = %d\n", sizeof(long double));
    return 0;
}

Result on Raspberry Pi:

sizeof(char) = 1
sizeof(short) = 2
sizeof(int) = 4
sizeof(long) = 4
sizeof(unsigned long) = 4
sizeof(long long) = 8
sizeof(unsigned long long) = 8
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double) = 8

Result on AMD FX-8350 (amd64):

sizeof(char) = 1
sizeof(short) = 2
sizeof(int) = 4
sizeof(long) = 8
sizeof(unsigned long) = 8
sizeof(long long) = 8
sizeof(unsigned long long) = 8
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double) = 16

As you can see the size of unsigned long differs, but unsigned long long stays the same across both platforms.

TurboGit commented 7 years ago

Note that current version of hubicfuse should already handle this properly. On 32bit system the segment is max 2Gb. Look at new code, it seems you have an old version. Can you double check with current sources?