You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
4.3 KiB
148 lines
4.3 KiB
/*
|
|
* Copyright (c) 2000 Opsycon AB (www.opsycon.se)
|
|
* Copyright (c) 2002 Patrik Lindergren (www.lindergren.com)
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
* must display the following acknowledgement:
|
|
* This product includes software developed by Opsycon AB.
|
|
* This product includes software developed by Patrik Lindergren.
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
* derived from this software without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*
|
|
*/
|
|
/* $Id: diskfs.h,v 1.1.1.1 2006/09/14 01:59:06 root Exp $ */
|
|
|
|
#ifndef __DISKFS_H__
|
|
#define __DISKFS_H__
|
|
|
|
#include <sys/queue.h>
|
|
#define FS_TYPE_EXT2 0x0
|
|
#define FS_TYPE_SWAP 0x1
|
|
#define FS_TYPE_FAT 0x2
|
|
#define FS_TYPE_ISO9660 0x3
|
|
#define FS_TYPE_NTFS 0x4
|
|
#define FS_TYPE_BSD 0x5
|
|
#define FS_TYPE_COMPOUND 0xFE
|
|
#define FS_TYPE_UNKNOWN 0xFF
|
|
|
|
//#define FS_SHOW_INFO
|
|
#ifdef FS_SHOW_INFO
|
|
#define fs_info(format, arg...) printf("FS_INFO: " format "\n", ## arg)
|
|
#else
|
|
#define fs_info(format, arg...) do {} while(0)
|
|
#endif
|
|
|
|
typedef struct DiskFileSystem {
|
|
char *fsname;
|
|
int (*open) __P((int, const char *, int, int));
|
|
int (*read) __P((int , void *, size_t));
|
|
int (*write) __P((int , const void *, size_t));
|
|
off_t (*lseek) __P((int , off_t, int));
|
|
int (*close) __P((int));
|
|
int (*ioctl) __P((int , unsigned long , ...));
|
|
SLIST_ENTRY(DiskFileSystem) i_next;
|
|
} DiskFileSystem;
|
|
#if 0
|
|
typedef struct DiskFile {
|
|
char *devname;
|
|
DiskFileSystem *dfs;
|
|
} DiskFile;
|
|
#endif
|
|
|
|
int diskfs_init(DiskFileSystem *fs);
|
|
|
|
typedef struct DiskPartitionTable {
|
|
struct DiskPartitionTable* Next;
|
|
struct DiskPartitionTable* logical;
|
|
unsigned char bootflag;
|
|
unsigned char tag;
|
|
unsigned char id;
|
|
unsigned int sec_begin;
|
|
unsigned int size;
|
|
unsigned int sec_end;
|
|
unsigned int part_fstype;
|
|
DiskFileSystem* fs;
|
|
}DiskPartitionTable;
|
|
|
|
|
|
#define MAX_PARTS 8
|
|
typedef struct DeviceDisk {
|
|
struct DeviceDisk* Next;
|
|
char device_name[20];
|
|
unsigned int dev_fstype;
|
|
// DiskPartitionTable* part;
|
|
DiskPartitionTable* part[MAX_PARTS];
|
|
}DeviceDisk;
|
|
typedef struct DiskFile {
|
|
char *devname;
|
|
DiskFileSystem *dfs;
|
|
DiskPartitionTable* part;
|
|
int part_index;
|
|
} DiskFile;
|
|
|
|
/*GPT header magic: EFI''PART*/
|
|
static unsigned char gpt_magic[8] = {
|
|
0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54
|
|
};
|
|
|
|
/*EFI PatitiontypeGUID*/
|
|
static unsigned char gpt_boot_type[16] = {
|
|
0x28, 0x73, 0x2a, 0xc1, 0x1f, 0xf8, 0xd2, 0x11,
|
|
0xba, 0x4b, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b
|
|
};
|
|
|
|
/*GPT header*/
|
|
typedef union {
|
|
struct {
|
|
unsigned char magic[8];
|
|
unsigned int version;
|
|
unsigned int headersize;
|
|
unsigned int crc32;
|
|
unsigned int unused1;
|
|
unsigned long long primary;
|
|
unsigned long long backup;
|
|
unsigned long long start;
|
|
unsigned long long end;
|
|
unsigned char guid[16];
|
|
unsigned long long partitions;
|
|
unsigned int maxpart;
|
|
unsigned int partentry_size;
|
|
unsigned int partentry_crc32;
|
|
};
|
|
unsigned char gpt[512];
|
|
} gpt_header;
|
|
|
|
/*GPT patition table*/
|
|
typedef union {
|
|
struct {
|
|
char type[16];
|
|
char guid[16];
|
|
unsigned long long start;
|
|
unsigned long long end;
|
|
unsigned long long attrib;
|
|
char name[72];
|
|
};
|
|
unsigned char ent[128];
|
|
} gpt_partentry;
|
|
|
|
#endif /* __DISKFS_H__ */
|
|
|