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

📄 pcdisk.h

📁 nucleus file NUCLEUS的文件系统源代码
💻 H
📖 第 1 页 / 共 4 页
字号:

} FINODE;


/* contain location information for a directory */
typedef struct dirblk
{
    UINT32      my_frstblock;       /* First block in this directory */
    UINT32      my_block;           /* Current block number */
    UINT16      my_index;           /* dirent number in my cluster   */
    /* fname[0] == "\0" entry blocks and index */
    UINT32      end_block;          /* End block number in this directory entry */
    UINT16      end_index;          /* End directory entry number in my cluster */

} DIRBLK;


/* Object used to find a dirent on a disk and its parent's */
#define FUSE_UPBAR      2            /* Short file name used upperbar
                                         First six characters of the file name plus ~n */
typedef struct drobj
{
    DDRIVE      *pdrive;            /* Block 0 image from the disk */
    FINODE      *finode;            /* Dos entry */
    DIRBLK      blkinfo;            /* Directory information */
    INT         isroot;             /* True if this is the root */
    BLKBUFF     *pblkbuff;          /* Block buffer pointer */
    LNAMINFO    linfo;              /* for long file name */

} DROBJ;


/* Date stamping buffer */
#define DSET_ACCESS     0           /* Set the only access-time,date */
#define DSET_UPDATE     1           /* Set the access-time,date and update-time,date */
#define DSET_CREATE     2           /* Set the all time and date.(access-time,date, update-time,date 
                                        create-time,date) */
typedef struct datestr
{
    UINT8       cmsec;              /* Centesimal mili second */
    UINT16      date;               /* Date */
    UINT16      time;               /* Time */

} DATESTR;


/* Internal file representation */
typedef struct pc_file
{
    DROBJ       *pobj;              /* Info for getting at the inode */
    UINT16      flag;               /* Acces flags from NU_Open(). */
    UINT32      fptr;               /* Current file pointer */
    UINT32      fptr_cluster;       /* Current cluster boundary for fptr */
    UINT32      fptr_block;         /* Block address at boundary of fprt_cluster */
    INT         is_free;            /* If YES this FILE may be used (see pc_memry.c) */
    INT         fupdate;            /* File update flag */
    INT         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;


/* File search structure */
typedef struct dstat
{
    CHAR       sfname[9];          /* Null terminated file and extension */
    CHAR       fext[4];
    CHAR       lfname[EMAXPATH+1]; /* Null terminated long file name */
    UINT8       fattribute;         /* File attributes */
    UINT8       fcrcmsec;           /* File create centesimal mili second */
    UINT16      fcrtime;            /* File create time */
    UINT16      fcrdate;            /* File create date */
    UINT16      faccdate;           /* Access date */
    UINT16      fclusterhigh;       /* High cluster for data file */
    UINT16      fuptime;            /* File update time */
    UINT16      fupdate;            /* File update */
    UINT16      fclusterlow;        /* Low cluster for data file */
    UINT32      fsize;              /* File size */

    /* INTERNAL */
    UINT8       pname[EMAXPATH+1];  /* Pattern. */
    UINT8       pext[4];
    INT8        path[EMAXPATH+1];
    DROBJ       *pobj;              /* Info for getting at the inode */
    DROBJ       *pmom;              /* Info for getting at parent inode */

} DSTAT;


/* User supplied parameter block for formatting */
typedef struct fmtparms
{
    UINT8       partdisk;           /* 1 : Partitioned disk, 0 : Not paritioned disk */
    UINT16      bytepsec;           /* Bytes per sectors */
    UINT8       secpalloc;          /* Sectors per cluster */
    UINT16      secreserved;        /* Reserved sectors before the FAT */
    UINT8       numfats;            /* Number of FATS on the disk */
    UINT16      numroot;            /* Maximum # of root dir entries. FAT32 always 0 */
    UINT8       mediadesc;          /* Media descriptor byte */
    UINT16      secptrk;            /* Sectors per track */
    UINT16      numhead;            /* Number of heads */
    UINT16      numcyl;             /* Number of cylinders */
    UINT32      totalsec;           /* Total sectors */

    INT8        oemname[9];             /* Only first 8 bytes are used */
    UINT8       physical_drive_no;      /* Boot Drive Information */
                                        /* 80h BootDrive  00h NotBootDrive */
    UINT32      binary_volume_label;    /* Volume ID or Serial Number */
    INT8        text_volume_label[12];  /* Volume Label */

} FMTPARMS;

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


/* User structure: Each task that accesses the file system may have one of 
   these structures. The pointer fs_user points to the current user. In 
   a real time exec you might put this in the process control block or
   have an array of them an change the fs_user pointer at task switch time

   Note: Having one of these structures per task is NOT absolutely necessary.
     If you do not these properties are simply system globals. 

   Code in pc_memory.c and pc_user.c provide a plausible way of managing the
   user structure.
*/

typedef struct file_system_user
{
    INT         p_errno;            /* error number */
    INT16       dfltdrv;            /* Default drive to use if no drive specified */
    DROBJ       *lcwd[NDRIVES];     /* current working dirs */
#if (NUM_USERS > 1)
    /* If multitasking. We place the task's handle here when we register it
       as a USER. This allows us to validate users when API calls are made. */
    CONTEXT_HANDLE_TYPE context_handle;
#endif

} FILE_SYSTEM_USER;

typedef FILE_SYSTEM_USER *PFILE_SYSTEM_USER;


/* Internal Error codes */
#define PCERR_FAT_FLUSH         0       /* Cant flush FAT */
#define PCERR_FAT_NULLP         1       /* Flushfat called with null pointer */
#define PCERR_NOFAT             2       /* No FAT type in this partition., Can't Format */
#define PCERR_FMTCSIZE          3       /* Too many clusters for this partition., Can't Format */
#define PCERR_FMTFSIZE          4       /* File allocation Table Too Small, Can't Format */
#define PCERR_FMTRSIZE          5       /* Numroot must be an even multiple of INOPBLOCK */
#define PCERR_FMTWBZERO         6       /* Failed writing block 0  */
#define PCERR_FMTWFAT           7       /* Failed writing FAT block */
#define PCERR_FMTWROOT          8       /* Failed writing root block */
#define PCERR_FMT2BIG           9       /* Total sectors may not exceed 64k.  */
#define PCERR_FSTOPEN           10      /* pc_free_all freeing a file */
#define PCERR_INITMEDI          11      /* Not a DOS disk:pc_dskinit */
#define PCERR_INITDRNO          12      /* Invalid driveno to pc_dskinit */
#define PCERR_INITCORE          13      /* Out of core:pc_dskinit */
#define PCERR_INITDEV           14      /* Can't initialize device:pc_dskinit */
#define PCERR_INITREAD          15      /* Can't read block 0:pc_dskinit */
#define PCERR_BLOCKCLAIM        16      /* PANIC: Buffer Claim */
#define PCERR_INITALLOC         17      /* Fatal error: Not enough core at startup */
#define PCERR_BLOCKLOCK         18      /* Warning: freeing a locked buffer */
#define PCERR_FREEINODE         19      /* Bad free call to freei */
#define PCERR_FREEDROBJ         20      /* Bad free call to freeobj */
#define PCERR_FATCORE           21      /* "Not Enough Core To Load FAT" */
#define PCERR_FATREAD           22      /* "IO Error While Failed Reading FAT" */
#define PCERR_BLOCKALLOC        23      /* "Block Alloc Failure Memory Not Initialized" */
#define PCERR_DROBJALLOC        24      /* "Memory Failure: Out of DROBJ Structures" */
#define PCERR_FINODEALLOC       25      /* "Memory Failure: Out of FINODE Structures" */
/* The next two are only relaventin a multi tasking environment */
#define PCERR_USERS             26      /* Out of User structures increase NUM_USERS */
#define PCERR_BAD_USER          27      /* Trying to use the API without calling 
                                          pc_rtfs_become_user() first */
#define PCERR_NO_DISK           28      /* No disk      */
#define PCERR_DISK_CHANGED      29      /* Disk changed */
#define PCERR_DRVALLOC          30      /* Memory Failure: Out of DDRIVE Structures */

#define PCERR_PATHL             31      /* Path name too long */


/* File creation permissions for open */
/* Note: OCTAL */
#define PS_IWRITE       0000400         /* Write permitted      */
#define PS_IREAD        0000200         /* Read permitted. (Always true anyway)*/

/* File access flags */
#define PO_RDONLY       0x0000          /* Open for read only*/
#define PO_WRONLY       0x0001          /* Open for write only*/
#define PO_RDWR         0x0002          /* Read/write access allowed.*/
#define PO_APPEND       0x0008          /* Seek to eof on each write*/
#define PO_CREAT        0x0100          /* Create the file if it does not exist.*/
#define PO_TRUNC        0x0200          /* Truncate the file if it already exists*/
#define PO_EXCL         0x0400          /* Fail if creating and already exists*/
#define PO_TEXT         0x4000          /* Ignored*/
#define PO_BINARY       0x8000          /* Ignored. All file access is binary*/
#define PO_NOSHAREANY   0x0004          /* Wants this open to fail if already
                                           open.  Other opens will fail while
                                           this open is active */
#define PO_NOSHAREWRITE 0x0800          /* Wants this opens to fail if already
                                           open for write. Other open for
                                           write calls will fail while this
                                           open is active. */

/* Errno values */
#define PEBADF          9               /* Invalid file descriptor*/
#define PENOENT         2               /* File not found or path to file not found*/
#define PEMFILE         24              /* No file descriptors available (too many
                                           files open)*/
#define PEEXIST         17              /* Exclusive access requested but file
                                           already exists.*/
#define PEACCES         13              /* Attempt to open a read only file or a
                                           special (directory)*/
#define PEINVAL         22              /* Seek to negative file pointer attempted.*/
#define PENOSPC         28              /* Write failed. Presumably because of no space */
#define PESHARE         30              /* Open failed do to sharing */

/* Arguments to SEEK */
#define PSEEK_SET       0               /* offset from begining of file*/

⌨️ 快捷键说明

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