hubicfuse icon indicating copy to clipboard operation
hubicfuse copied to clipboard

segment_above verification failed on rpi

Open Vebryn opened this issue 8 years ago • 8 comments

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 avatar Mar 02 '16 22:03 Vebryn

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

Vebryn avatar Mar 02 '16 22:03 Vebryn

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?

TurboGit avatar Oct 28 '17 22:10 TurboGit

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.

romanrm avatar Oct 29 '17 08:10 romanrm

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

TurboGit avatar Oct 29 '17 10:10 TurboGit

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

romanrm avatar Oct 29 '17 10:10 romanrm

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

TurboGit avatar Oct 29 '17 11:10 TurboGit

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.

romanrm avatar Oct 29 '17 11:10 romanrm

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?

TurboGit avatar Nov 02 '17 15:11 TurboGit