⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcdisk.h

📁 ertfs文件系统里面既有完整ucos程序
💻 H
📖 第 1 页 / 共 3 页
字号:
#if (VFAT)
        SEGDESC s;
#endif
        } FINODE;


/* contain location information for a directory */
    typedef struct dirblk {
        BLOCKT  my_frstblock;      /* First block in this directory */
        BLOCKT  my_block;          /* Current block number */
        int     my_index;          /* dirent number in my cluster   */
    } DIRBLK;


/* Block buffer */
typedef struct blkbuff {
        struct blkbuff *pnext;
        dword lru;
        DDRIVE *pdrive;
        BLOCKT blockno;
        int  use_count;
        int  pad_to_4_align;
        byte  data[512];
        } BLKBUFF;

/* Object used to find a dirent on a disk and its parent's */
typedef struct drobj {
        DDRIVE  *pdrive;
        FINODE  *finode;
        DIRBLK  blkinfo;
        BOOLEAN isroot;      /* True if this is the root */
        BLKBUFF *pblkbuff;
        } DROBJ;

/* Internal file representation */
typedef struct pc_file {
    DROBJ *     pobj;           /* Info for getting at the inode */
    word        flag;           /* Acces flags from po_open(). */
    dword       fptr;           /* Current file pointer */
    CLUSTERTYPE fptr_cluster;   /* Current cluster boundary for fptr */
    dword       fptr_block;     /* Block address at boundary of fprt_cluster */
    BOOLEAN     needs_flush;    /* If TRUE this FILE must be flushed */
    BOOLEAN     is_free;        /* If TRUE this FILE may be used (see pc_memry.c) */
    BOOLEAN     at_eof;         /* True if fptr was > alloced size last time we set
                                   it. If so synch_file pointers will fix it if the
                                   file has expanded. */
    } PC_FILE;

/* INTERNAL !! */
/* Structure to contain block 0 image from the disk */
#if (FAT32)
struct pcblk0 {
        byte  jump;               /* Should be E9 or EB on formatted disk */
        char  oemname[9];
        word  bytspsector;        /* Must be 512 for this implementation */
        byte  secpalloc;          /* Sectors per cluster */
        word  secreserved;        /* Reserved sectors before the FAT */
        byte  numfats;            /* Number of FATS on the disk */
        word  numroot;            /* Maximum # of root dir entries */
        word  numsecs;            /* Total # sectors on the disk */
        byte  mediadesc;          /* Media descriptor byte */
        word  secpfat;            /* Size of each fat */
        word  secptrk;            /* sectors per track */
        word  numhead;            /* number of heads */
        word  numhide;            /* # hidden sectors High word if DOS4 */
        word  numhide2;           /* # hidden sectors Low word if DOS 4 */
        dword numsecs2;           /* # secs if numhid+numsec > 32M (4.0) */
        dword secpfat2;           /* Size of FAT in sectors */
        byte  physdrv;            /* Physical Drive No. (4.0) */
        byte  filler;             /* Reserved (4.0) */
        byte  xtbootsig;          /* Extended signt 29H if 4.0 stuf valid */
        dword volid;              /* Unique number per volume (4.0) */
        char  vollabel[11];       /* Volume label (4.0) */
        byte  filler2[8];         /* Reserved (4.0) */

        word  flags;              /* Defined below */

#define NOFATMIRROR 0x0080
#define ACTIVEFAT   0x000F

        word    fs_version;         /* Version of FAT32 used */
        dword   rootbegin;          /* Location of 1st cluster in root dir */
        word    infosec;            /* Location of information sector */
        word    backup;             /* Location of backup boot sector */
        dword   free_alloc;         /* Free clusters on drive (-1 if unknown) */
        dword   next_alloc;         /* Most recently allocated cluster */
        };

struct fat32_info {
        dword   fs_sig;             /* Signature of FAT32 (0x61417272) */

#define FSINFOSIG 0x61417272ul

        dword   free_alloc;         /* Free clusters on drive (-1 if unknown) */
        dword   next_alloc;         /* Most recently allocated cluster */
        dword   reserved;           /* Reserved - ignore */
        };
#else
struct pcblk0 {
        byte  jump;             /* Should be E9 or EB on formatted disk */
        char  oemname[9];
        word  bytspsector;      /* Must be 512 for this implementation */
        byte  secpalloc;        /* Sectors per cluster */
        word  secreserved;      /* Reserved sectors before the FAT */
        byte  numfats;          /* Number of FATS on the disk */
        word  numroot;          /* Maximum # of root dir entries */
        word  numsecs;          /* Total # sectors on the disk */
        byte  mediadesc;        /* Media descriptor byte */
        word  secpfat;          /* Size of each fat */
        word  secptrk;          /* sectors per track */
        word  numhead;          /* number of heads */
        word  numhide;          /* # hidden sectors High word if DOS4 */
        word  numhide2;         /* # hidden sectors Low word if DOS 4 */
        dword numsecs2;         /* # secs if numhid+numsec > 32M (4.0) */
        byte  physdrv;          /* Physical Drive No. (4.0) */
        byte  filler;           /* Reserved (4.0) */
        byte  xtbootsig;        /* Extended signt 29H if 4.0 stuf valid */
        dword volid;            /* Unique number per volume (4.0) */
        char  vollabel[11];     /* Volume label (4.0) */
        byte  filler2[8];       /* Reserved (4.0) */
        };
#endif


/* Table for calculating sectors per cluster */
typedef struct format_dec_tree {
   word  sec_p_alloc;
   word  ents_p_root;
   dword n_blocks;
} FORMAT_DEC_TREE;


/* Partition table descriptions. */
/* One disk partition table */
typedef struct ptable_entry {
    byte  boot;
    byte  s_head;
    word  s_cyl;
    byte  p_typ;
    byte  e_head;
    word e_cyl;
    dword  r_sec;   /* Relative sector of start of part */
    dword  p_size;  /* Size of partition */
    } PTABLE_ENTRY;

typedef struct ptable {
    PTABLE_ENTRY ents[4];
    word signature; /* should be 0xaa55 */
    } PTABLE;


#ifndef GLOBAL_INSTANCE
extern FINODE KS_FAR *inoroot;
extern DDRIVE KS_FAR *drv_array[NDRIVES];     /* Array of open drives */
extern DDRIVE KS_FAR *drno_to_dr_map[NDRIVES];

extern DDRIVE  KS_FAR *mem_drives_structures;
extern BLKBUFF KS_FAR *mem_block_pool;
extern PC_FILE KS_FAR *mem_file_pool;
extern BLOCK_ALLOC KS_FAR fat_drive_0[FAT_BUFFER_SIZE];     
#if (NDRIVES>1)
extern BLOCK_ALLOC KS_FAR fat_drive_1[FAT_BUFFER_SIZE];
#endif
#if (NDRIVES>2)
extern BLOCK_ALLOC KS_FAR fat_drive_2[FAT_BUFFER_SIZE];
#endif
#if (NDRIVES>3)
extern BLOCK_ALLOC KS_FAR fat_drive_3[FAT_BUFFER_SIZE];
#endif
#if (NDRIVES>4)
extern BLOCK_ALLOC KS_FAR fat_drive_4[FAT_BUFFER_SIZE];
#endif
#if (NDRIVES>5)
extern BLOCK_ALLOC KS_FAR fat_drive_5[FAT_BUFFER_SIZE];
#endif
#if (NDRIVES>6)
extern BLOCK_ALLOC KS_FAR fat_drive_6[FAT_BUFFER_SIZE];
#endif
#if (NDRIVES>7)
extern BLOCK_ALLOC KS_FAR fat_drive_7[FAT_BUFFER_SIZE];
#endif
#if (NDRIVES>8)
extern BLOCK_ALLOC KS_FAR fat_drive_8[FAT_BUFFER_SIZE];
#endif
#if (NDRIVES>9)
#error extern BLOCK_ALLOC KS_FAR fat_drive_9[FAT_BUFFER_SIZE];
#endif

#endif

#ifndef BUILDING_CONST
/* String constants */
extern KS_CONSTANT char string_star[2];
extern KS_CONSTANT char string_padded_dot_dot[9];
extern KS_CONSTANT char string_3_spaces[4];
extern KS_CONSTANT char string_dot[2];
extern KS_CONSTANT char string_dot_dot[3];
extern KS_CONSTANT char string_null[1];
extern KS_CONSTANT char string_backslash[3];
extern KS_CONSTANT char string_fat_12[6];
extern KS_CONSTANT char string_fat_16[6];
extern KS_CONSTANT char char_backslash;

#endif
#define RTFS_FILE(X,Y)   /* This is used to split source files into 1 subroutrine
                           per file */
/* Make sure memory is initted prolog for api functions */
#define CHECK_MEM(TYPE, RET)  if (!mem_drives_structures) return((TYPE) RET);
#define VOID_CHECK_MEM()  if (!mem_drives_structures) return;
#define IS_AVOLORDIR(X) ((X->isroot) || (X->finode->fattribute & AVOLUME|ADIRENT))

/* Prototypes */

// File INIT.C:
BOOLEAN pc_ertfs_init(void);

// File API.C:
long _po_lseek(PC_FILE *pfile, long offset, int origin);
BOOLEAN _po_flush(PC_FILE *pfile);
BOOLEAN pc_is(int op, char *path);
dword pc_find_contig_clusters(DDRIVE *pdr, CLUSTERTYPE startpt, CLUSTERTYPE  *pchain, CLUSTERTYPE min_clusters, int method);
int po_chsize(PCFD fd, long offset);

// File APIUTIL.C:
BOOLEAN pc_i_dskopen(int driveno);
int check_drive(char *name);
PC_FILE *pc_fd2file(PCFD fd,int flags);
PCFD pc_allocfile(void);
void pc_freefile(PCFD fd);
int pc_enum_file(DDRIVE *pdrive, int chore);
void pc_free_all_fil(DDRIVE *pdrive);
BOOLEAN pc_flush_all_fil(DDRIVE *pdrive);
int pc_test_all_fil(DDRIVE *pdrive);
int pc_log_base_2(word n);
BOOLEAN pc_dskinit(int driveno);
BOOLEAN get_disk_volume(int driveno, byte *pvollabel, dword *pserialno);
BOOLEAN pc_idskclose(int driveno);
DROBJ *pc_get_cwd(DDRIVE *pdrive);
void pc_upstat(DSTAT *statobj);
void  _synch_file_ptrs(PC_FILE *pfile);
void pc_finode_stat(FINODE *pi, STAT *pstat);
int pc_read_partition_table(int driveno, DDRIVE *pdr);

// File BLOCK.C:
BOOLEAN pc_alloc_blk(BLKBUFF **ppblk, DDRIVE *pdrive, BLOCKT blockno);
BLKBUFF *pc_blkpool(DDRIVE *pdrive);
void pc_free_all_blk(DDRIVE *pdrive);
void pc_free_buf(BLKBUFF *pblk, BOOLEAN waserr);
BLKBUFF *pc_init_blk(DDRIVE *pdrive, BLOCKT blockno);
BLKBUFF *pc_read_blk(DDRIVE *pdrive, BLOCKT blockno);
BOOLEAN pc_write_blk(BLKBUFF *pblk);
BLKBUFF *pc_scratch_blk(void);

// File CHKMEDIA.C:
BOOLEAN check_media_entry(int driveno);
BOOLEAN check_media_io(int driveno, BOOLEAN raw);
BOOLEAN check_media(int driveno, BOOLEAN ok_to_automount, BOOLEAN raw_access_requested, BOOLEAN call_crit_err);

int check_media_status(int driveno);
// File DEVIO.C:
BOOLEAN devio_read(int driveno, dword blockno, byte * buf, word n_to_read, BOOLEAN raw);
BOOLEAN devio_write(int driveno, dword blockno, byte * buf, word n_to_write, BOOLEAN raw);
// File DROBJ.C:
DROBJ *pc_fndnode(char *path);
DROBJ *pc_get_inode( DROBJ *pobj, DROBJ *pmom, byte *filename, byte *fileext, BOOLEAN dowildcard);
#if (VFAT)
void pcdel2lfi(LFNINODE *lfi, int nsegs);
void pc_zeroseglist(SEGDESC *s);
void pc_addtoseglist(SEGDESC *s, BLOCKT my_block, int my_index);
void pc_reduceseglist(SEGDESC *s);
BOOLEAN pc_deleteseglist(DDRIVE *pdrive, SEGDESC *s);
void text2lfi(char *lfn, LFNINODE *lfi, int nsegs, byte ncksum, byte order);
BOOLEAN pc_seglist2disk(DDRIVE * pdrive, SEGDESC *s, char *lfn);
void lfi2text(char *lfn, LFNINODE *lfi, int nsegs);
char *pc_seglist2text(DDRIVE * pdrive, SEGDESC *s, char *lfn);
#endif

BOOLEAN pc_findin( DROBJ *pobj, byte *filename, byte *fileext, BOOLEAN dowildcard);
DROBJ *pc_get_mom(DROBJ *pdotdot);
DROBJ *pc_mkchild( DROBJ *pmom);
DROBJ *pc_mknode(DROBJ *pmom ,char *filename, char *fileext, byte attributes);
#if (VFAT)
BOOLEAN pc_insert_inode( DROBJ *pobj, DROBJ *pmom, char *lfn);
#else
BOOLEAN pc_insert_inode( DROBJ *pobj, DROBJ *pmom);
#endif
BOOLEAN pc_rmnode( DROBJ *pobj);
BOOLEAN pc_update_inode(DROBJ *pobj, BOOLEAN set_archive, BOOLEAN set_date);
DROBJ *pc_get_root( DDRIVE *pdrive);
BLOCKT pc_firstblock( DROBJ *pobj);
BOOLEAN pc_next_block( DROBJ *pobj);
BLOCKT pc_l_next_block(DDRIVE *pdrive, BLOCKT curblock);
void pc_marki( FINODE *pfi, DDRIVE *pdrive, BLOCKT sectorno, int  index);
FINODE *pc_scani( DDRIVE *pdrive, BLOCKT sectorno, int index);
DROBJ *pc_allocobj(void);
FINODE *pc_alloci(void);
void pc_free_all_i( DDRIVE *pdrive);
void pc_freei( FINODE *pfi);
void pc_freeobj( DROBJ *pobj);
void pc_dos2inode (FINODE *pdir, DOSINODE *pbuff);
void pc_init_inode(FINODE *pdir, KS_CONSTANT char *filename, 
            KS_CONSTANT char *fileext, byte attr, 
            CLUSTERTYPE cluster, dword size, DATESTR *crdate);
void pc_ino2dos (DOSINODE *pbuff, FINODE *pdir);
BOOLEAN pc_isavol( DROBJ *pobj);
BOOLEAN pc_isadir( DROBJ *pobj);
BOOLEAN pc_isroot( DROBJ *pobj);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -