static int hammer_vfs_statvfs(struct mount *mp, struct statvfs *sbp, struct ucred *cred) { struct hammer_mount *hmp = (void *)mp->mnt_data; hammer_volume_t volume; hammer_volume_ondisk_t ondisk; int error; int64_t bfree; int64_t breserved; lwkt_gettoken(&hmp->fs_token); volume = hammer_get_root_volume(hmp, &error); if (error) { lwkt_reltoken(&hmp->fs_token); return(error); } ondisk = volume->ondisk; /* * Basic stats */ _hammer_checkspace(hmp, HAMMER_CHKSPC_WRITE, &breserved); mp->mnt_vstat.f_files = ondisk->vol0_stat_inodes; bfree = ondisk->vol0_stat_freebigblocks * HAMMER_LARGEBLOCK_SIZE; hammer_rel_volume(volume, 0); mp->mnt_vstat.f_bfree = (bfree - breserved) / HAMMER_BUFSIZE; mp->mnt_vstat.f_bavail = mp->mnt_vstat.f_bfree; if (mp->mnt_vstat.f_files < 0) mp->mnt_vstat.f_files = 0; *sbp = mp->mnt_vstat; lwkt_reltoken(&hmp->fs_token); return(0); }
/* * Get information */ static int hammer_ioc_get_info(hammer_transaction_t trans, struct hammer_ioc_info *info) { hammer_volume_ondisk_t ondisk = trans->hmp->rootvol->ondisk; hammer_mount_t hmp = trans->hmp; /* Fill the structure with the necessary information */ _hammer_checkspace(hmp, HAMMER_CHKSPC_WRITE, &info->rsvbigblocks); info->rsvbigblocks = info->rsvbigblocks >> HAMMER_BIGBLOCK_BITS; strlcpy(info->vol_label, ondisk->vol_label, sizeof(ondisk->vol_label)); info->vol_fsid = hmp->fsid; info->vol_fstype = ondisk->vol_fstype; info->version = hmp->version; info->inodes = ondisk->vol0_stat_inodes; info->bigblocks = ondisk->vol0_stat_bigblocks; info->freebigblocks = ondisk->vol0_stat_freebigblocks; info->nvolumes = hmp->nvolumes; info->rootvol = ondisk->vol_rootvol; return 0; }