Tag: jna bytebuffer

JNA ByteBuffer statvfs

我试图使用java中的statvfs调用获取/文件夹上的可用空间, 我从c中检查了statvfs struct的大小,它显示了44个字节,我已经使用java.nio.ByteBuffer.allocateDirect 44字节分配了一个字节缓冲区,并且它的顺序设置为44个字节。 当我调用statvfs我得到一个返回值为0,所以我假设调用成功,但我似乎无法从使用buffer.getInt获取ByteBuffer的信息返回512 f_bsize这是正确但但之后我无法读取。 buffer.getInt(12)应该给我f_blocks,但我得到0。 unsigned long f_bsize; /* File system block size */ unsigned long f_frsize; /* Fundamental file system block size */ fsblkcnt_t f_blocks; /* Blocks on FS in units of f_frsize */ 或者我的逻辑有错吗?