add: fsync(fd);
context: init_device_info(int32 index, virtual_drive_info *initInfo){	if (!is_valid_data_device_index(index) || !initInfo)		return B_BAD_VALUE;	device_info &info = gDeviceInfos[index];	if (!info.unused)		return B_BAD_VALUE;	bool readOnly = (initInfo->use_geometry && initInfo->geometry.read_only);	// open the file	int fd = open(initInfo->file_name, (readOnly ? O_RDONLY : O_RDWR));	if (fd < 0)		return errno;	status_t error = B_OK;	// get the file size	off_t fileSize = 0;	struct stat st;	if (fstat(fd, &st) == 0)		fileSize = st.st_size;	else		error = errno;	// If we shall use the supplied geometry, we enlarge the file, if	// necessary. Otherwise we fill in the geometry according to the size of the file.	off_t size = 0;	if (error == B_OK) {		if (initInfo->use_geometry) {			// use the supplied geometry			info.geometry = initInfo->geometry;			size = (off_t)info.geometry.bytes_per_sector				* info.geometry.sectors_per_track				* info.geometry.cylinder_count				* info.geometry.head_count;			if (size > fileSize) {				if (!readOnly) {					if (ftruncate(fd, size) != 0)						error = errno;				} else					error = B_NOT_ALLOWED;			}		} else {			// fill in the geometry			// default to 512 bytes block size			uint32 blockSize = 512;			// Optimally we have only 1 block per sector and only one head.			// Since we have only a uint32 for the cylinder count, this won't work			// for files > 2TB. So, we set the head count to the minimally possible			// value.			off_t blocks = fileSize / blockSize;			uint32 heads = (blocks + ULONG_MAX - 1) / ULONG_MAX;			if (heads == 0)				heads = 1;			info.geometry.bytes_per_sector = blockSize;		    info.geometry.sectors_per_track = 1;		    info.geometry.cylinder_count = blocks / heads;		    info.geometry.head_count = heads;		    info.geometry.device_type = B_DISK;	// TODO: Add a new constant.		    info.geometry.removable = false;		    info.geometry.read_only = false;		    info.geometry.write_once = false;			size = (off_t)info.geometry.bytes_per_sector				* info.geometry.sectors_per_track				* info.geometry.cylinder_count				* info.geometry.head_count;		}	}	if (error == B_OK) {		// Disable caching for underlying file! (else this driver will deadlock)		// We probably cannot resize the file once the cache has been disabled!		// This is a special reserved ioctl() opcode not defined anywhere in		// the Be headers.		if (ioctl(fd, 10000) != 0) {			dprintf("virtualdrive: disable caching ioctl failed\n");			return errno;		}	}	// fill in the rest of the device_info structure	if (error == B_OK) {		// open_count doesn't have to be changed here (virtualdrive_open() will do that for us)		info.fd = fd;		info.size = size;		info.unused = false;		info.registered = true;		strcpy(info.file, initInfo->file_name);		info.device_path = sVirtualDriveName[index];	} else {		// cleanup on error		close(fd);		if (info.open_count == 0)			clear_device_info(index);	}	return error;}