📄 diskform.h
字号:
/* *---------------------------------------------------------------------- * T-Kernel / Standard Extension * * Copyright (C) 2006 by Ken Sakamura. All rights reserved. * T-Kernel / Standard Extension is distributed * under the T-License for T-Kernel / Standard Extension. *---------------------------------------------------------------------- * * Version: 1.00.00 * Released by T-Engine Forum(http://www.t-engine.org) at 2006/8/11. * *---------------------------------------------------------------------- *//* * diskform.h * * STDFS standard disk format * * (Note) When defining disk format structure, * prevent padding by compiler. * For this reason, UW is sometimes defined as "UH [2]". * * < - >Bracket-enclosed section represents a definition of STDFS extension format 1. * [ - ]Bracket-enclosed section represents a definition of STDFS extension format 2. * Format 1 definitions are included in format 2 definitions. */#ifndef __SYS_DISKFORM_H__#define __SYS_DISKFORM_H__#include <basic.h>#ifdef __cplusplusextern "C" {#endif/* * Maximum value of index level (that can be supported by file management) */#define MaxIndexLevel 3/* * Logical block address */typedef struct { unsigned int cnt:8; /* Consecutive block count */ unsigned int adr:24; /* Logical block address */} LogBlk;/* * Normal index */typedef struct { UB always0; UB rtype; /* Record type */ UH stype; /* Record subtype*/ VB reserved1[2]; UH offset; /* Start offset */ UW size; /* Record size */ LogBlk blk; /* Block address */} DfNormalIndex;/* * Connection index */typedef struct { LogBlk blk[4]; /* Block address */} DfConnectIndex;/* * Link index */typedef struct { UB always00; UB always80; UH stype; /* Record subtype*/ UH fid; /* File ID */ UH atr[5]; /* Attribute data */} DfLinkIndex;/* * Record index */typedef union { UB type[2]; DfNormalIndex n; DfConnectIndex c; DfLinkIndex l;} DfRecordIndex;/* * Indirect index */typedef struct { UW nrec; /* Number of valid records */ UW blk; /* Logical block address */} DfIndirectIndex;/* * Fragment table elements */typedef struct { UH size; /* Fragment size */ UH locate[2]; /* Position (byte address) */} DfFragment;typedef struct { UH size; /* Fragment size */ UH offset; /* [Offset within block] */ UW blk; /* [Logical block address] */} DfFragment2;/* * File location data of link file */typedef struct { UH fid; /* Intended file ID */ UH ctime[2]; /* Generation date/time of intended file */ VB reserved1[4]; VB fsnm[40]; /* Name of intended file system */ VB devnm[40]; /* Device location name of intended file system */} DfLinkFile;/* * File header */typedef struct { UW startid; /* File header start ID (0x54726F6E) */ UH ftype; /* File type */ UH atype; /* Application type */ VB own[28]; /* Owner name + hidden name */ VB grp[28]; /* Group name + hidden name */ UH gacclv; /* Group access level */ UH pacclv; /* General access level */ H nlnk; /* Number of included links */ H idxlv; /* Index level */ W size; /* Total number of file bytes */ W nblk; /* Total number of used logical blocks */ W nrec; /* Total number of records */ VB reserved1[8]; W ltime; /* Storage period */ W atime; /* Latest date/time of access */ W mtime; /* Latest date/time of update */ W ctime; /* Generation date/time of file */ VB name[40]; /* File name */ VB pswd[24]; /* Password */ W refcnt; /*<File reference count (>=255) >*/ UH ridxofs; /*[Record index start position]*/ VB reserved2[8]; UH fid; /* File ID */ UW endid; /* File header end ID (0x82DDE96B) */} DfFileHeader;#define FileHeaderTopID 0x54726F6EU /* File header start ID */#define FileHeaderEndID 0x82DDE96BU /* File header end ID *//* * File header block * [In Extension Format 2, the format of fragment table is DfFragment2 * and its size becomes variable. * The start position of record index is indicated by file header ridxofs. * ridxofs indicates positions on a 16-byte basis (because record index is * 16 bytes in size). Therefore, the number of fragment table entries is * always an even number.] */typedef struct { DfFileHeader head; /* File header */ union { DfFragment frag [32]; /* Fragment table */ DfFragment2 frag2[24]; /* [Fragment table] */ DfLinkFile link; /* Link file location data */ } f; union { /* Use this size when logical block size is 1KB */ DfRecordIndex r[40]; /* Record index */ DfIndirectIndex i[80]; /* Indirect index */ } idx;} DfFileHeaderBlock;/* * Abbreviated file name */typedef UW DfShortName;/* * File ID table elements */typedef union { struct DfFileID {#if BIGENDIAN unsigned int refcnt:8; /* File reference count */ unsigned int blkadr:24; /* File start block address */#else unsigned int blkadr:24; /* File start block address */ unsigned int refcnt:8; /* File reference count */#endif } s; UW w;} DfFileID;/* * System header */typedef struct { UH fsid; /* STDFS disk ID (0x42FE) */ UH diskid; /* Disk format ID (0x6400) */ UH ssys; /* System block size */ UH sfidt; /* File ID table size */ UH sfnmt; /* Abbreviated file name table size */ UH nbmp; /* Number of bitmap bytes <number of words> */ VB reserved1[12]; UH sblk; /* Number of logical block bytes (change H to UH) */ UH nfmax; /* Maximum number of files */ H lang; /* Language to use (Japanese = 0x0021) */ H acclv; /* Access management level */ W nlb; /* Total number of logical blocks */ W nflb; /* Number of free logical blocks*/ W mtime; /* Date/time of latest system block update */ W ctime; /* Generation date/time of file system */ VB fsnm[40]; /* File system name */ VB devnm[40]; /* Device location name */} DfSystemHeader; /* STDFS disk ID */#define StdfsDiskMagic 0x42FEU /* STDFS standard format */#define StdfsDiskMagic_E 0x52FEU /* STDFS extended format */ /* Disk format ID */#define StdfsDiskID_A 0x6400U /* STDFS standard format */#define StdfsDiskID_A2 0x8400U /* STDFS standard format (HD) */#define StdfsDiskID_B 0x6401U /* STDFS extended format 1 */#define StdfsDiskID_C 0x6402U /* STDFS extended format 2 */#ifdef __cplusplus}#endif#endif /* __SYS_DISKFORM_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -