private Space getSpaceStatVFSOpenSSH(SFTPEngine sftp, final Path directory) throws BackgroundException { try { final Request request = sftp.newExtendedRequest("statvfs@openssh.com").putString(directory.getAbsolute()); final Response response = sftp.request(request).retrieve(); switch(response.getType()) { case EXTENDED_REPLY: long blockSize = response.readUInt64(); /* file system block size */ long filesystemBlockSize = response.readUInt64(); /* fundamental fs block size */ long totalBlocks = response.readUInt64(); /* number of blocks (unit f_frsize) */ long filesystemFreeBlocks = response.readUInt64(); /* free blocks in file system */ long blocksAvailable = response.readUInt64(); /* free blocks for non-root */ long fileInodes = response.readUInt64(); /* total file inodes */ long fileInodesFree = response.readUInt64(); /* free file inodes */ long fileInodesAvailable = response.readUInt64(); /* free file inodes for to non-root */ byte[] filesystemID = new byte[8]; /* file system id */ response.readRawBytes(filesystemID); long flags = response.readUInt64(); /* bit mask of f_flag values */ long maximumFilenameLength = response.readUInt64(); /* maximum filename length */ long total = totalBlocks * filesystemBlockSize; long available = blocksAvailable * filesystemBlockSize; long used = total - available; return new Space(used, available); default: throw new IOException(String.format("Unexpected response type %s", response.getType())); } } catch(IOException e) { throw new SFTPExceptionMappingService().map("Failure to read attributes of {0}", e, directory); } }
switch(response.getType()) { case EXTENDED_REPLY: long bytesOnDevice = response.readUInt64(); long unusedBytesOnDevice = response.readUInt64(); long bytesAvailableToUser = response.readUInt64(); long unusedBytesAvailableToUser = response.readUInt64(); int bytesPerAllocationUnit = response.readUInt32AsInt();