Can statfs() read a remote network drive mounted using FTP?
Yes.
You must use statfs() correctly. Please see the following example:
#include <stat.h>
#include <stdio.h>
int myStatFs() {
struct statfs sfs;
int ret = statfs("host:", &sfs);
printf("[+] f_fbsize: %ld\n",sfs.f_bsize);
printf("[+] f_files: %ld\n",sfs.f_files);
printf("[+] f_bfree: %ld\n",sfs.f_bfree);
return ret;
}
And this is what it looks like when the above example runs:
-> myStatFs()
[+] f_fbsize: 16
[+] f_files: 25067444
[+] f_bfree: 2952740
value = -1 = 0xffffffff
->
You must make sure that you mount your network drive correctly. This is what my hostShow() returns:
-> hostShow
hostname inet address aliases
-------- ------------ -------
localhost 127.0.0.1
xlnx_zynq7k 192.168.1.10
host 192.168.1.11
value = 0 = 0x0
->
The machine at 192.168.1.11 is running an FTP server.
This is what the statfs struct looks like:
struct statfs {
long f_type; /* type of info, zero for now */
long f_bsize; /* fundamental file system block size */
long f_blocks; /* total blocks in file system */
long f_bfree; /* free block in fs */
long f_bavail; /* free blocks avail to non-superuser */
long f_files; /* total file nodes in file system */
long f_ffree; /* free file nodes in fs */
fsid_t f_fsid; /* file system id */
long f_spare[7]; /* spare for later */
};
Here is the vxWorks 5.5 statfs documentation (and it's basically the same for vxWorks 6.9):
http://www.vxdev.com/docs/vx55man/vxworks/ref/dirLib.html#statfs