/*static char *SCCSID = "@(#)filesys.h	6.3 91/10/01";*/
/*      SCCSID = @(#)filesys.h	6.3 91/10/01
 **** Master file for File System Equates
 *
 * This file contains the equates that are used by the file system that
 * cannot go in any other file.
 */

/*
 * BIT Equates for the values that can be placed in the PTDA byte variable
 * PathNameType. These are used to indicate the "type" of the path name
 * that was passed in by a user.
 */
#define PNType_LOCDEV       0x01        // Path for a local device
#define PNType_PSDEV        0x02        // Path for a pseudo-device
#define PNType_LOCFILE      0x04        // Path for a local file
#define PNType_REMFILE      0x08        // Path for a remote file
#define PNType_UNC          0x10        // Path is in UNC form
#define PNType_NMPIPE       0x20        // Path is a name pipe
#define PNType_NEWFILE      0x40        // Path is non-8.3

#define PNType_ALL_REMOTES  (PNType_PSDEV | PNType_REMFILE | PNType_UNC | PNType_NMPIPE)

/* BIT equates used for the flag passed to DoDiskRead and DoDiskWrite to
 * allow them to distinguish between I/O for extended attributes and I/O
 * for a file or direct device.
 */
#define IOTYPE_FILE         0x01        // I/O is for a file or direct device
#define IOTYPE_EA           0x02        // I/O is for extended attributes


/* The following equates are used in verifying access to segments used for
 * I/O. See ProbeBuff in SETFETUM.ASM.
 */
#define ACCTYPE_READ    0       // Read access only
#define ACCTYPE_RW      1       // Read/Write access needed

/* This equate is used by DOS_Delete to check for valid cluster number.
 */
#define MINCLUS         2       // minimum cluster number


/*  Flag values indicating set or retrieve for FS_FSINFO, FS_FILEINFO,
 *  FS_FILEATTRIBUTE, and possibly others.
 */

#define FSF_QINFO       0       // retrieve
#define FSF_SETINFO     1       // set


/* Flag values for FS_FlushBuf and FlushFsdBuf */
#define FLU_KEEP        0       // keep cached data after flushing
#define FLU_DISCARD     1       // discard cached data after flushing
#define FLU_HDISCARD2   2       // discard cached data after flushing
                                // for hybernation w/o reset of cache flags
#define FLU_HDISCARD    3       // discard cached data after flushing
                                // for hybernation

/* Advisory bits for DoVolIO. These bits are related to the FSH_DOV_OP bits
 * by a shift count. Check usage in DoVolIO before changing them.
 */

#define DOV_AUTOFAIL    0x0001  // don't generate hard error
#define DOV_WRTHRU      0x0002  // do write thru I/O
#define DOV_NCACHE      0x0004  // don't cache data
#define DOV_USED        (DOV_AUTOFAIL | DOV_WRTHRU | DOV_NCACHE)

/* Route types for DosFsCtl */
#define MAXFSCTLROUTETYPE   FSCTL_FSDROUTE

#define FSCTL_HANDLEROUTE   1   // Route by a handle
#define FSCTL_PATHROUTE     2   // Route by path name
#define FSCTL_FSDROUTE      3   // Route by FSD name

/* defined FSCTL functions   */
#define FSCTL_ERROR_INFO            1  /* return error info from FSD  */
#define FSCTL_MAX_EASIZE            2  /* Max ea size for the FSD     */
#define FSCTL_GET_NEXT_ROUTE_NAME   3  /* Rtrn next valid FSD name    */
#define FSCTL_DAEMON_QUERY          4  /* FSD query for daemon rqrmnt */


/* Equates for the AsgCheckDrive routine */

#define ASG_NOREF     0x00      // no referenced to the drive
#define ASG_CURDIR    0x01      // some process has current dir. there
#define ASG_CURDRIVE  0x02      // some process has current drive there
#define ASG_OPENFILE  0x04      // there is an open file ref to the drive

/* Flag  values for GET/SETPATHINFO common procedures */
#define fGSPI_GETINFO   0       // get path info
#define fGSPI_SETINFO   1       // set path info

#define fGSPI_WRTTHRU   0x10    // write through flag for SETPATHINFO

/* pathinfo flag equates for SETPATHINFO */
#define fSPI_FLAGS_RESERVED     (~fGSPI_WRTTHRU)
                                // currently only write through bit
                                // can be specified.

/* the following describes a structure know variously as the partition table,
 * the master boot record, or the extended boot record. it resides at cylinder
 * zero, head zero, sector zero of each non-removeable disk volume and partition
 */
#define BOOT_PROG_SIZE  0x01be  // size of the boot program area.
#define MAXPART         4       // maximum number of partitions.

struct RawPartRec {

    BYTE boot_flag;             // zero if not bootable,
                                // x'80' if bootable.
    BYTE begin_head;            // bits 7 and 6: high order two
                                // bits of first cylinder in
                                // partition.
                                // bits 5 thru 0: first head
                                // in partition.
    BYTE begin_sector;          // first sector in partition.
    BYTE begin_cylinder;        // low order eight bits of
                                // first cylinder in partition.
    BYTE system_index;          // partition type - see equates
                                // below.
    BYTE end_head;              // bits 7 and 6: high order two
                                // bits of last cylinder in
                                // partition.
                                // bits 5 thru 0: last head
                                // in partition.
    BYTE end_sector;            // last sector in partition.
    BYTE end_cylinder;          // low order eight bits of
                                // last cylinder in partition.
    ULONG rel_sector;           // number of hidden sectors
                                // preceding usable data area
                                // in this partition.
    ULONG length_of_part;       // number of sectors in this
                                // partition.

};

struct BootRec {

    BYTE program [BOOT_PROG_SIZE];
    BYTE parttbl [MAXPART * sizeof (struct RawPartRec)];
    USHORT signature;
};

/*
 *the following are the valid values for "system_index", above
 */
#define PART_SMALL_DOS  0x01    // dos parition < 16 mB.
#define PART_MED_DOS    0x04    // 16 mB < dos parition =< 32 mB.
#define PART_LINK       0x05    // link to next volume.
#define PART_HUGE_DOS   0x06    // dos parition > 32 mB.
#define PART_IFS        0x07    // ifs parition.

/*
 * the following defines the data structure to be used with
 * sw_DevIOCtl
 */
struct iop {

    BYTE iop_command;           // command.
    USHORT iop_head;            // head number.
    USHORT iop_cyl;             // cylinder number.
    USHORT iop_sect;            // sector number.
    USHORT iop_sect_ct;         // number of sectors.
    USHORT iop_sec_num;         // track format
    USHORT iop_sec_siz;         // map.

};

/*
 * The following are used by the path-based routines, especially in macro.asm
 * and their callers.
 */
#define FPATH_PCNAME        1   // Call FSD_ProcessName from TransPath2
#define FPATH_ERRNMP        2   // complain about relative named pipes
#define FPATH_JOIN          4   // do join (subject to FPATH_JOIN_N_EXACT)
#define FPATH_JOIN_N_EXACT  8   // join if not exact match

/*
 * The following structure is used by CritErrPause in fshelper.asm
 */

struct CharData {
    BYTE kbdcharcode;           // ASCII Character code
    BYTE kbdscancode;           // Scan Code
    BYTE kbdstatus;             // Status
    BYTE kbdnlsshifstat;        // NLS Shift Status
    USHORT kbdshiftstate;       // Shift State
    ULONG kbdtimestamp;         // Time Stamp
};

/*
 * The following structure is used by the new style reqlist management for the
 * new FAT file system cache.
 */

struct RLCB_Header {
    USHORT RLCB_Pointer;        // Current pointer to start new request or SG.
    USHORT RLCB_CurrReqPtr;     // pointer to current request header.
    USHORT RLCB_HeaderPtr;      // pointer to request list header.
    ULONG  RLCB_ClientPtr;      // ClientPtr link.
    BYTE   RLCB_Sem;            // Semaphore for serailization.
    BYTE   RLCB_Flags;          // Flags;
    USHORT RLCB_hVPB;           // Handle to volume.
    USHORT RLCB_NextReadSel;    // AsyncRead next request list selector.
    USHORT RLCB_NextReadOff;    // AsyncRead next request list offset.
    ULONG  RLCB_CurrByteCount;  // Current bytecount of all S/G entries in
                                // current request.
};
#define RLCB_KEEP_REQ    0x01   // Keep request list after I/O completed.
#define RLCB_HOTFIX      0x02   // Hot Fix if error on write.
#define RLCB_NO_HARDERR  0x04   // No hard error popup

