* fhandler.h (struct part_t): New type.

(class fhandler_dev_floppy): Convert partitions to part_t pointer.
	Add lock_partition method.
	* fhandler_floppy.cc (fhandler_dev_floppy::lock_partition): New method
	to implement ondemand partition locking.
	(fhandler_dev_floppy::write_file): Call lock_partition from here if
	writing failed due to a potential write restriction on a disk
	partition.
	(fhandler_dev_floppy::open): Don't lock partitions here.
	(fhandler_dev_floppy::close): Keep track of partition handle reference
	count.  Close handles and remove partitions pointer ony if count is 0.
	(fhandler_dev_floppy::dup): Just copy partitions pointer and increment
	reference count.
This commit is contained in:
Corinna Vinschen
2011-01-12 09:16:51 +00:00
parent 95a5c969ab
commit 667f187146
3 changed files with 193 additions and 67 deletions

View File

@@ -689,12 +689,18 @@ class fhandler_dev_raw: public fhandler_base
#define MAX_PARTITIONS 15
struct part_t
{
LONG refcnt;
HANDLE hdl[MAX_PARTITIONS];
};
class fhandler_dev_floppy: public fhandler_dev_raw
{
private:
_off64_t drive_size;
unsigned long bytes_per_sector;
HANDLE partitions[MAX_PARTITIONS];
part_t *partitions;
struct status_flags
{
unsigned eom_detected : 1;
@@ -707,6 +713,8 @@ class fhandler_dev_floppy: public fhandler_dev_raw
inline _off64_t get_current_position ();
int get_drive_info (struct hd_geometry *geo);
int lock_partition (DWORD to_write);
BOOL write_file (const void *buf, DWORD to_write, DWORD *written, int *err);
BOOL read_file (void *buf, DWORD to_read, DWORD *read, int *err);