Exemple #1
0
/* Called by the kernel when asking for stats */
static int ntfs_statfs(struct super_block *sb, struct statfs *sf)
{
	struct inode *mft;
	ntfs_volume *vol;
	ntfs_u64 size;
	int error;

	ntfs_debug(DEBUG_OTHER, "ntfs_statfs\n");
	vol=NTFS_SB2VOL(sb);
	sf->f_type=NTFS_SUPER_MAGIC;
	sf->f_bsize=vol->clustersize;

	error = ntfs_get_volumesize( NTFS_SB2VOL( sb ), &size );
	if( error )
		return -error;
	sf->f_blocks = size;	/* volumesize is in clusters */
	sf->f_bfree=ntfs_get_free_cluster_count(vol->bitmap);
	sf->f_bavail=sf->f_bfree;

	mft=iget(sb,FILE_MFT);
	if (!mft)
		return -EIO;
	/* So ... we lie... thus this following cast of loff_t value
	   is ok here.. */
	sf->f_files = (unsigned long)mft->i_size / vol->mft_recordsize;
	iput(mft);

	/* should be read from volume */
	sf->f_namelen=255;
	return 0;
}
Exemple #2
0
/* Called by the kernel when asking for stats. */
static int ntfs_statfs(struct super_block *sb, struct statfs *sf)
{
	struct inode *mft;
	ntfs_volume *vol;
	__s64 size;
	int error;

	ntfs_debug(DEBUG_OTHER, "ntfs_statfs\n");
	vol = NTFS_SB2VOL(sb);
	sf->f_type = NTFS_SUPER_MAGIC;
	sf->f_bsize = vol->cluster_size;
	error = ntfs_get_volumesize(NTFS_SB2VOL(sb), &size);
	if (error)
		return error;
	sf->f_blocks = size;	/* Volumesize is in clusters. */
	size = (__s64)ntfs_get_free_cluster_count(vol->bitmap);
	/* Just say zero if the call failed. */
	if (size < 0LL)
		size = 0;
	sf->f_bfree = sf->f_bavail = size;
	ntfs_debug(DEBUG_OTHER, "ntfs_statfs: calling mft = iget(sb, "
			"FILE_Mft)\n");
	mft = iget(sb, FILE_Mft);
	ntfs_debug(DEBUG_OTHER, "ntfs_statfs: iget(sb, FILE_Mft) returned "
			"0x%x\n", mft);
	if (!mft)
		return -EIO;
	sf->f_files = mft->i_size >> vol->mft_record_size_bits;
	ntfs_debug(DEBUG_OTHER, "ntfs_statfs: calling iput(mft)\n");
	iput(mft);
	/* Should be read from volume. */
	sf->f_namelen = 255;
	return 0;
}
Exemple #3
0
/* Called by the kernel when asking for stats */
static int ntfs_statfs(struct super_block *sb, struct statfs *sf, int bufsize)
{
	struct statfs fs;
	struct inode *mft;
	ntfs_volume *vol;
	int error;

	ntfs_debug(DEBUG_OTHER, "ntfs_statfs\n");
	vol=NTFS_SB2VOL(sb);
	memset(&fs,0,sizeof(fs));
	fs.f_type=NTFS_SUPER_MAGIC;
	fs.f_bsize=vol->clustersize;

	error = ntfs_get_volumesize( NTFS_SB2VOL( sb ), &fs.f_blocks );
	if( error )
		return -error;
	fs.f_bfree=ntfs_get_free_cluster_count(vol->bitmap);
	fs.f_bavail=fs.f_bfree;

	/* Number of files is limited by free space only, so we lie here */
	fs.f_ffree=0;
	mft=iget(sb,FILE_MFT);
	fs.f_files=mft->i_size/vol->mft_recordsize;
	iput(mft);

	/* should be read from volume */
	fs.f_namelen=255;
	copy_to_user(sf,&fs,bufsize);
	return 0;
}