Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - [QNX7] getfsstat on beaglebone: (1 Item)
   
[QNX7] getfsstat on beaglebone  
Hi!

I've not found any information about my problem at knowledge base. Hope this forum is alive and team can help me. 

I've got Beaglebone with QNX7. Trying to get list of mounted filesystem I faces with strange behaviour of getfsstat 
function. 
Running very simple test program 
#include "nbutil.h"
#include "stdio.h"
#include "stdlib.h"

int main(int argc, char** argv) {
    int nentries = getfsstat(NULL, 0, MNT_NOWAIT);
    fprintf(stderr, "netr1=%d\n", nentries);
    size_t bufsize = nentries * sizeof(struct statfs);
    void* buf = malloc(bufsize);
    nentries = getfsstat(buf, bufsize, MNT_NOWAIT);
    fprintf(stderr, "netr2=%d\n", nentries);
    bufsize = nentries * sizeof(struct statfs);
    buf = malloc(bufsize);
    nentries = getfsstat(buf, bufsize, MNT_NOWAIT);
    fprintf(stderr, "netr3=%d\n", nentries);

    return 0;
}
results in following  output 
netr1=4
netr2=2
netr3=4

I expect all three line should contain equal numbers since no filesystems were changed between functions call. 

My initial though was about compilation issue and size of the buffer is not enough to keep all necessary structures. 
Increasing the buffer 10 times changes output slightly. 
bufsize = nentries * sizeof(struct statfs) * 10;
netr1=4
netr2=2
netr3=2

So yes, required buffer size calculation is not correct and I don't know why. The second issue is bound to a number 
returned by function when no buffer is provided. It differs from that with correct buffer. And again I 've no idea why. 


What am I doing wrong? The same code works correctly on OSX.

Thank you in advance.

Vasya