0

Javaからのstatvfs呼び出しを使用して、/フォルダーの空き領域を取得しようとしています。

44バイトを示すcからstatvfs構造体のサイズを確認し、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 */

または、ロジックに障害がありますか?

4

1 に答える 1

1

Not a solution but a few thoughts.

  1. you should check the size of fsblkcnt_t type. I'm quite positive, that it is 4 bytes, but that's just an assumption based on your 44 bytes for the whole struct.
  2. I think, the index of the first byte of the f_blocks field is 8, not 12. f_bsize and f_frsize are 4 bytes each, the total is 8 bytes, the next value starts at the nineth position which is index 8.
  3. I'm a bit confused about your 'order' setting. It should not be '44' but either Byteorder.BIG_ENDIAN or ByteOrder.LITTLE_ENDIAN. But maybe that's just a typo in your question

Have your tried dumping the buffer content or used a debugger to peek into the buffer? Does it hold the expected values? Just to sort out, if the problem is related to filling or to reading the buffer.

于 2009-11-16T08:28:22.037 に答える