db5ae61884
wsa_event.h instead. * fhandler_socket.cc (NUM_SOCKS): Move to wsa_event.h. (wsa_events): Move from DLL shared area to cygwin_shared shared memory. Accommodate throughout. (socket_serial_number): Ditto. * fhandler_tape.cc (mt): Ditto. (mtinfo_init): Remove. (mt): Define as cygwin_shared->mt. * flock.cc (FLOCK_PARENT_DIR_ACCESS): Remove. (FLOCK_INODE_DIR_ACCESS): Move up in file. (FLOCK_MUTANT_ACCESS): Ditto. (FLOCK_EVENT_ACCESS): Ditto. (get_lock_parent_dir): Remove. (inode_t::inode_t): Call get_shared_parent_dir to get parent dir handle. Add a "flock-" prefix to file's lock directory name for clarity. * mtinfo.h (mtinfo_init): Drop declaration. * net.cc (last_used_bindresvport): Move from DLL shared area to cygwin_shared shared memory. (cygwin_bindresvport_sa): Accommodate above change. * sec_helper.cc (_everyone_sd): Move here from flock.cc. * security.h (SD_MIN_SIZE): Ditto. (everyone_sd): Ditto. * shared.cc (cygwin_shared_area): Remove. (cygwin_shared_h): New handle. (get_shared_parent_dir): New static function. (shared_name): Drop session_local argument. Call get_shared_parent_dir here. Add cygwin-shared subdir to object name. (offsets): Reinstantiate SH_CYGWIN_SHARED member. (open_shared): Revert change from 2007-03-29 for systems supporting SeCreateGlobalPrivilege. (shared_info::initialize): Call mtinfo's initialize here. (memory_init): Drop call to mtinfo_init. * shared_info.h (SHARED_INFO_CB): Accommodate change to shared_info. (CURR_SHARED_MAGIC): Ditto. (class shared_info): Add members for global socket and tape info sharing. (enum shared_locations): Reinstantiate SH_CYGWIN_SHARED. (get_shared_parent_dir): Declare. (shared_name): Drop session_local argument from declaration. * wsa_event.h: New file. Move definitions of NUM_SOCKS and struct wsa_event here.
143 lines
3.5 KiB
C++
143 lines
3.5 KiB
C++
/* mtinfo.h: Defininitions for the Cygwin tape driver class.
|
|
|
|
Copyright 2004, 2005, 2006 Red Hat, Inc.
|
|
|
|
This file is part of Cygwin.
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
details. */
|
|
|
|
#define MTINFO_MAGIC 0x179b2af0
|
|
#define MTINFO_VERSION 2
|
|
|
|
/* Maximum number of supported partitions per drive. */
|
|
#define MAX_PARTITION_NUM 64
|
|
/* Maximum number of supported drives. */
|
|
#define MAX_DRIVE_NUM 8
|
|
|
|
/* Values for bookkeeping of the tape position relative to filemarks
|
|
and eod/eom. */
|
|
enum eom_val
|
|
{
|
|
no_eof,
|
|
eof_hit,
|
|
eof,
|
|
eod_hit,
|
|
eod,
|
|
eom_hit,
|
|
eom
|
|
};
|
|
|
|
enum dirty_state
|
|
{
|
|
clean,
|
|
has_read,
|
|
has_written,
|
|
async_write_pending
|
|
};
|
|
|
|
enum lock_state
|
|
{
|
|
unlocked,
|
|
lock_error,
|
|
auto_locked,
|
|
locked
|
|
};
|
|
|
|
/* Partition specific information */
|
|
class mtinfo_part
|
|
{
|
|
public:
|
|
long block; /* logical block no */
|
|
long file; /* current file no */
|
|
long fblock; /* relative block no */
|
|
bool smark; /* At setmark? */
|
|
eom_val emark; /* "end-of"-mark */
|
|
|
|
void initialize (long nblock = -1);
|
|
};
|
|
|
|
class mtinfo_drive
|
|
{
|
|
int drive;
|
|
int lasterr;
|
|
long partition;
|
|
long block;
|
|
dirty_state dirty;
|
|
lock_state lock;
|
|
TAPE_GET_DRIVE_PARAMETERS _dp;
|
|
TAPE_GET_MEDIA_PARAMETERS _mp;
|
|
OVERLAPPED ov;
|
|
struct status_flags
|
|
{
|
|
unsigned buffer_writes : 1;
|
|
unsigned async_writes : 1;
|
|
unsigned two_fm : 1;
|
|
unsigned fast_eom : 1;
|
|
unsigned auto_lock : 1;
|
|
unsigned sysv : 1;
|
|
unsigned nowait : 1;
|
|
} status;
|
|
mtinfo_part _part[MAX_PARTITION_NUM];
|
|
|
|
inline int error (const char *str)
|
|
{
|
|
if (lasterr)
|
|
debug_printf ("%s: Win32 error %d", str, lasterr);
|
|
return lasterr;
|
|
}
|
|
inline bool get_feature (DWORD parm)
|
|
{
|
|
return ((parm & TAPE_DRIVE_HIGH_FEATURES)
|
|
? ((_dp.FeaturesHigh & parm) != 0)
|
|
: ((_dp.FeaturesLow & parm) != 0));
|
|
}
|
|
int get_pos (HANDLE mt, long *ppartition = NULL, long *pblock = NULL);
|
|
int _set_pos (HANDLE mt, int mode, long count, int partition, BOOL dont_wait);
|
|
int create_partitions (HANDLE mt, long count);
|
|
int set_partition (HANDLE mt, long count);
|
|
int write_marks (HANDLE mt, int marktype, DWORD count);
|
|
int erase (HANDLE mt, int mode);
|
|
int prepare (HANDLE mt, int action, bool is_auto = false);
|
|
int set_compression (HANDLE mt, long count);
|
|
int set_blocksize (HANDLE mt, long count);
|
|
int get_status (HANDLE mt, struct mtget *get);
|
|
int set_options (HANDLE mt, long options);
|
|
int async_wait (HANDLE mt, DWORD *bytes_written);
|
|
|
|
public:
|
|
void initialize (int num, bool first_time);
|
|
int get_dp (HANDLE mt);
|
|
int get_mp (HANDLE mt);
|
|
int open (HANDLE mt);
|
|
int close (HANDLE mt, bool rewind);
|
|
int read (HANDLE mt, HANDLE mt_evt, void *ptr, size_t &ulen);
|
|
int write (HANDLE mt, HANDLE mt_evt, const void *ptr, size_t &len);
|
|
int ioctl (HANDLE mt, unsigned int cmd, void *buf);
|
|
int set_pos (HANDLE mt, int mode, long count, bool sfm_func);
|
|
|
|
IMPLEMENT_STATUS_FLAG (bool, buffer_writes)
|
|
IMPLEMENT_STATUS_FLAG (bool, async_writes)
|
|
IMPLEMENT_STATUS_FLAG (bool, two_fm)
|
|
IMPLEMENT_STATUS_FLAG (bool, fast_eom)
|
|
IMPLEMENT_STATUS_FLAG (bool, auto_lock)
|
|
IMPLEMENT_STATUS_FLAG (bool, sysv)
|
|
IMPLEMENT_STATUS_FLAG (bool, nowait)
|
|
|
|
PTAPE_GET_DRIVE_PARAMETERS dp () { return &_dp; }
|
|
PTAPE_GET_MEDIA_PARAMETERS mp () { return &_mp; }
|
|
mtinfo_part *part (int num) { return &_part[num]; }
|
|
};
|
|
|
|
class mtinfo
|
|
{
|
|
DWORD magic;
|
|
DWORD version;
|
|
mtinfo_drive _drive[MAX_DRIVE_NUM];
|
|
|
|
public:
|
|
void initialize ();
|
|
mtinfo_drive *drive (int num) { return &_drive[num]; }
|
|
};
|