Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segment_above verification failed on rpi #120

Open
Vebryn opened this issue Mar 2, 2016 · 8 comments
Open

segment_above verification failed on rpi #120

Vebryn opened this issue Mar 2, 2016 · 8 comments

Comments

@Vebryn
Copy link

Vebryn commented Mar 2, 2016

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
Copy link
Author

Vebryn commented Mar 2, 2016

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
Copy link
Owner

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
Copy link

romanrm commented Oct 29, 2017

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
Copy link
Owner

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

@romanrm
Copy link

romanrm commented Oct 29, 2017

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

@TurboGit
Copy link
Owner

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

@romanrm
Copy link

romanrm commented Oct 29, 2017

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
Copy link
Owner

TurboGit commented Nov 2, 2017

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants