Re: [PATCH, RFC] mke2fs: get device topology values from blkid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 17, 2009 at 05:22:49PM -0500, Eric Sandeen wrote:
> +static errcode_t ext2fs_get_device_geometry(const char *file,
> +					    struct ext2_super_block *fs_param)
> +{
> +	int fd;
> +	int rc = 1;
> +	int blocksize;
> +	blkid_probe pr;
> +	blkid_topology tp;
> +	unsigned long min_io;
> +	unsigned long opt_io;
> +
> +#ifdef HAVE_OPEN64
> +	fd = open64(file, O_RDONLY);
> +#else
> +	fd = open(file, O_RDONLY);
> +#endif
> +	if (fd < 0)
> +		return errno;
> +
> +	pr = blkid_new_probe();
> +	if (!pr)
> +		goto out;
> +
> +	rc = blkid_probe_set_device(pr, fd, 0, 0);
> +	if (rc)
> +		goto out;
> +
> +	tp = blkid_probe_get_topology(pr);
> +	if (!tp)
> +		goto out;
> +
> +	min_io = blkid_topology_get_minimum_io_size(tp);
> +	opt_io = blkid_topology_get_optimal_io_size(tp);
> +	blocksize = EXT2_BLOCK_SIZE(fs_param);
> +
> +	fs_param->s_raid_stride = min_io / blocksize;
> +	fs_param->s_raid_stripe_width = opt_io / blocksize;
> +	rc = 0;
> +out:

   blkid_free_probe(pr);

just in case you want to keep valgrind mem-leak checkers silent :-) 

> +	close(fd);
> +	return rc;
> +}

    Karel
-- 
 Karel Zak  <kzak@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux