Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ntfs_device_size_get for file #46

Open
kgermanov opened this issue Jul 1, 2022 · 0 comments
Open

Improve ntfs_device_size_get for file #46

kgermanov opened this issue Jul 1, 2022 · 0 comments

Comments

@kgermanov
Copy link

For calculation size of device if passed file instead of device (https://github.com/tuxera/ntfs-3g/blob/edge/libntfs-3g/device.c#L599):

	/*
	 * We couldn't figure it out by using a specialized ioctl,
	 * so do binary search to find the size of the device.
	 */
	low = 0LL;
	for (high = 1024LL; !ntfs_device_offset_valid(dev, high); high <<= 1)
		low = high;
	while (low < high - 1LL) {
		const s64 mid = (low + high) / 2;
		if (!ntfs_device_offset_valid(dev, mid))
			low = mid;
		else
			high = mid;
	}
	dev->d_ops->seek(dev, 0LL, SEEK_SET);

But there is IO callback stat(https://github.com/tuxera/ntfs-3g/blob/edge/include/ntfs-3g/device.h#L113) whose contains size of file.
So we can call this callback for avoid count of random read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant