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

📄 fat32.h

📁 c语言编的网络操作系统。具备网络操作系统基本功能。
💻 H
字号:
/*
nexOS: nexos generic ata driver - generic ata driver FAT32 dir reader
Copyright 2004 nexOS development team

This file is part of nexOS.

nexOS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

nexOS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with nexOS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ 

/* this file just contains a test and gets removed after devfs is done */

#ifndef __FAT32_H__
#define __FAT32_H__

#include <types.h>

/* MBR and partition structs */
typedef struct partition_t {
  BYTE  bootid;   /* bootable?  0=no, 128=yes  */
  BYTE  beghead;  /* beginning head number */
  BYTE  begsect;  /* beginning sector number */
  BYTE  begcyl;   /* 10 bit nmbr, with high 2 bits put in begsect */	
  BYTE  systid;   /* Operating System type indicator code */
  BYTE  endhead;  /* ending head number */
  BYTE  endsect;  /* ending sector number */
  BYTE  endcyl;   /* also a 10 bit nmbr, with same high 2 bit trick */
  DWORD relsect;  /* first sector relative to start of disk */
  DWORD numsect;  /* number of sectors in partition */
}__attribute__((packed)) PARTITION;

typedef struct mbr_t {
  BYTE      bootinst[446];   /* space to hold actual boot code */
  PARTITION partitions[4];
  WORD      signature;       /* set to 0xAA55 to indicate PC MBR format */
}__attribute__((packed)) MBR;

#define FAT32_MIRRORED 0x0080

typedef struct fat32bootsect_t {
    BYTE jmp[3];
    char oemname[8];
    WORD bytespersec;
    BYTE secpercluster;
    WORD resseccnt;
    BYTE numfats;
    WORD rootentrycnt;
    WORD totsec16;
    BYTE media;
    WORD fatsize16;
    WORD secpertrk;
    WORD numheads;
    DWORD hiddensec;
    DWORD totsec32;//-OK-
    DWORD fatsize32;
    WORD extflags;
    WORD fsver;
    DWORD rootcluster;
    WORD fsinfo;
    WORD backupbootsec;
    BYTE reserved[12];
    BYTE drvnum;
    BYTE res1;
    BYTE bootsig;
    DWORD volid;
    char vollabel[11];
    char fstype[8];
    char bscode[420];
    WORD signature;
}__attribute__((packed)) FAT32BS;

#define FAT32_ATTR_READ_ONLY 0x01
#define FAT32_ATTR_HIDDEN 0x02
#define FAT32_ATTR_SYSTEM 0x04
#define FAT32_ATTR_VOLUME_ID 0x08
#define FAT32_ATTR_DIRECTORY 0x10
#define FAT32_ATTR_ARCHIVE 0x20

typedef struct fat32direntry_t {
    char name[11];
    BYTE attr;
    BYTE ntres;
    BYTE sectenths;
    WORD time;
    WORD date;
    WORD lastaccdate;
    WORD firstclhi;
    WORD writetime;
    WORD writedate;
    WORD firstcllo;
    DWORD size;
}__attribute__((packed)) FAT32DIRENT;    

int fat32_readdir(int argc, char *argv[]);

#endif

⌨️ 快捷键说明

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