mirror of
https://gitlab.com/bztsrc/bootboot.git
synced 2023-02-13 20:54:32 -05:00
More file system stuff
This commit is contained in:
parent
b7af3f6e22
commit
1ac24e3c06
19 changed files with 53 additions and 52 deletions
|
@ -38,14 +38,14 @@ file_t fsz_initrd(unsigned char *initrd_p, char *kernel)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
unsigned char passphrase[256],chk[32],iv[32];
|
unsigned char passphrase[256],chk[32],iv[32];
|
||||||
unsigned int i,j,k,l,ss=1<<(*((uint16_t*)(initrd_p+520))+11);
|
unsigned int i,j,k,l,ss=1<<(initrd_p[518]+11);
|
||||||
unsigned char *ent, *in=(initrd_p+*((uint64_t*)(initrd_p+560))*ss);
|
unsigned char *ent, *in=(initrd_p+*((uint64_t*)(initrd_p+560))*ss);
|
||||||
SHA256_CTX ctx;
|
SHA256_CTX ctx;
|
||||||
DBG(" * FS/Z ");
|
DBG(" * FS/Z ");
|
||||||
DBG(kernel);
|
DBG(kernel);
|
||||||
DBG("\n");
|
DBG("\n");
|
||||||
//decrypt initrd
|
//decrypt initrd
|
||||||
if(*((uint32_t*)(initrd_p+708))!=0 && ((initrd_p[518]>>2)&7)!=0) {
|
if(*((uint32_t*)(initrd_p+708))!=0 && initrd_p[519]!=0) {
|
||||||
puts("BOOTBOOT-PANIC: Unsupported cipher\n");
|
puts("BOOTBOOT-PANIC: Unsupported cipher\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -94,8 +94,8 @@ again:
|
||||||
if(*e=='/'){e++;}
|
if(*e=='/'){e++;}
|
||||||
if(!memcmp(in,"FSIN",4)){
|
if(!memcmp(in,"FSIN",4)){
|
||||||
//is it inlined?
|
//is it inlined?
|
||||||
if(!memcmp(initrd_p[518]&1? in + 2048 : in + 1024,"FSDR",4)){
|
if(!memcmp(initrd_p[520]&1? in + 2048 : in + 1024,"FSDR",4)){
|
||||||
ent=(initrd_p[518]&1? in + 2048 : in + 1024);
|
ent=(initrd_p[520]&1? in + 2048 : in + 1024);
|
||||||
} else if(!memcmp(initrd_p+*((uint64_t*)(in+448))*ss,"FSDR",4)){
|
} else if(!memcmp(initrd_p+*((uint64_t*)(in+448))*ss,"FSDR",4)){
|
||||||
// go, get the sector pointed
|
// go, get the sector pointed
|
||||||
ent=(initrd_p+*((uint64_t*)(in+448))*ss);
|
ent=(initrd_p+*((uint64_t*)(in+448))*ss);
|
||||||
|
@ -130,12 +130,12 @@ again:
|
||||||
switch(in[488]) {
|
switch(in[488]) {
|
||||||
case 0xFF:
|
case 0xFF:
|
||||||
// inline data
|
// inline data
|
||||||
ret.ptr=(uint8_t*)(initrd_p+i*ss+(initrd_p[518]&1? 2048 : 1024));
|
ret.ptr=(uint8_t*)(initrd_p+i*ss+(initrd_p[520]&1? 2048 : 1024));
|
||||||
break;
|
break;
|
||||||
case 0x80:
|
case 0x80:
|
||||||
case 0x7F:
|
case 0x7F:
|
||||||
// sector directory or list inlined
|
// sector directory or list inlined
|
||||||
ret.ptr=(uint8_t*)(initrd_p + *((uint64_t*)(initrd_p[518]&1? in + 2048 : in + 1024))*ss);
|
ret.ptr=(uint8_t*)(initrd_p + *((uint64_t*)(initrd_p[520]&1? in + 2048 : in + 1024))*ss);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
// direct data
|
// direct data
|
||||||
|
|
BIN
dist/bootboot.bin
vendored
BIN
dist/bootboot.bin
vendored
Binary file not shown.
BIN
dist/bootboot.efi
vendored
BIN
dist/bootboot.efi
vendored
Binary file not shown.
BIN
dist/bootboot.img
vendored
BIN
dist/bootboot.img
vendored
Binary file not shown.
BIN
dist/bootboot.rom
vendored
BIN
dist/bootboot.rom
vendored
Binary file not shown.
|
@ -19,7 +19,7 @@ fájlrendszerek:
|
||||||
| `fat` | ✗No | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/vfat.pdf) (csak nem-ESP, LFN-el) |
|
| `fat` | ✗No | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/vfat.pdf) (csak nem-ESP, LFN-el) |
|
||||||
| `minix` | ✗No | ✔Yes | [V2 spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/minix.pdf), [V3 forrás](https://github.com/Stichting-MINIX-Research-Foundation/minix/tree/master/minix/fs/mfs) (V3 támogatott, de csak V2-höz van spec) |
|
| `minix` | ✗No | ✔Yes | [V2 spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/minix.pdf), [V3 forrás](https://github.com/Stichting-MINIX-Research-Foundation/minix/tree/master/minix/fs/mfs) (V3 támogatott, de csak V2-höz van spec) |
|
||||||
| `ext2` | ✗No | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/ext2.pdf), [dokumentáció](https://www.nongnu.org/ext2-doc/ext2.html) |
|
| `ext2` | ✗No | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/ext2.pdf), [dokumentáció](https://www.nongnu.org/ext2-doc/ext2.html) |
|
||||||
| `lean` | ✗No | ✔Yes | [honlap](http://freedos-32.sourceforge.net/lean/specification.php) |
|
| `lean` | ✗No | ✔Yes | [V0.6 spec](http://freedos-32.sourceforge.net/lean/specification.php), [V0.7 spec](http://www.fysnet.net/leanfs/specification.php) |
|
||||||
|
|
||||||
A kód úgy lett megírva, hogy könnyű legyen bővíteni.
|
A kód úgy lett megírva, hogy könnyű legyen bővíteni.
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ also creates an initrd or a disk partition from a directory. Supported file syst
|
||||||
| `fat` | ✗No | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/vfat.pdf) (non-ESP only, with LFN) |
|
| `fat` | ✗No | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/vfat.pdf) (non-ESP only, with LFN) |
|
||||||
| `minix` | ✗No | ✔Yes | [V2 spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/minix.pdf), [V3 source](https://github.com/Stichting-MINIX-Research-Foundation/minix/tree/master/minix/fs/mfs) (V3 supported, but there's only V2 spec) |
|
| `minix` | ✗No | ✔Yes | [V2 spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/minix.pdf), [V3 source](https://github.com/Stichting-MINIX-Research-Foundation/minix/tree/master/minix/fs/mfs) (V3 supported, but there's only V2 spec) |
|
||||||
| `ext2` | ✗No | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/ext2.pdf), [documentation](https://www.nongnu.org/ext2-doc/ext2.html) |
|
| `ext2` | ✗No | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/ext2.pdf), [documentation](https://www.nongnu.org/ext2-doc/ext2.html) |
|
||||||
| `lean` | ✗No | ✔Yes | [homepage](http://freedos-32.sourceforge.net/lean/specification.php) |
|
| `lean` | ✗No | ✔Yes | [V0.6 spec](http://freedos-32.sourceforge.net/lean/specification.php), [V0.7 spec](http://www.fysnet.net/leanfs/specification.php) |
|
||||||
|
|
||||||
The code is written in a way that it is easily expandable.
|
The code is written in a way that it is easily expandable.
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3,11 +3,11 @@
|
||||||
#define sizeof_boot_bin 512
|
#define sizeof_boot_bin 512
|
||||||
extern unsigned char binary_boot_bin[512];
|
extern unsigned char binary_boot_bin[512];
|
||||||
#define sizeof_bootboot_bin 13312
|
#define sizeof_bootboot_bin 13312
|
||||||
extern unsigned char binary_bootboot_bin[9284];
|
extern unsigned char binary_bootboot_bin[9282];
|
||||||
#define sizeof_bootboot_efi 103614
|
#define sizeof_bootboot_efi 103614
|
||||||
extern unsigned char binary_bootboot_efi[46278];
|
extern unsigned char binary_bootboot_efi[46277];
|
||||||
#define sizeof_bootboot_img 35488
|
#define sizeof_bootboot_img 35488
|
||||||
extern unsigned char binary_bootboot_img[20150];
|
extern unsigned char binary_bootboot_img[20152];
|
||||||
#define sizeof_bootboot_rv64 8192
|
#define sizeof_bootboot_rv64 8192
|
||||||
extern unsigned char binary_bootboot_rv64[31];
|
extern unsigned char binary_bootboot_rv64[31];
|
||||||
#define sizeof_LICENCE_broadcom 1594
|
#define sizeof_LICENCE_broadcom 1594
|
||||||
|
|
|
@ -51,6 +51,7 @@ uint8_t *ech_data = NULL, ech_uuid[16];
|
||||||
uint64_t ech_size;
|
uint64_t ech_size;
|
||||||
uint64_t ech_numblk;
|
uint64_t ech_numblk;
|
||||||
|
|
||||||
|
/*** mkbootimg interface ***/
|
||||||
void ech_open(gpt_t *gpt_entry)
|
void ech_open(gpt_t *gpt_entry)
|
||||||
{
|
{
|
||||||
if(gpt_entry) {
|
if(gpt_entry) {
|
||||||
|
|
|
@ -240,6 +240,7 @@ uint8_t *ext_add_dirent(uint8_t *dir, uint32_t toinode, uint32_t ino, uint8_t ty
|
||||||
return dir + ((len + 3) & ~3) + 8;
|
return dir + ((len + 3) & ~3) + 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** mkbootimg interface ***/
|
||||||
void ext_open(gpt_t *gpt_entry)
|
void ext_open(gpt_t *gpt_entry)
|
||||||
{
|
{
|
||||||
uint32_t i, j, k, l, n, m, o;
|
uint32_t i, j, k, l, n, m, o;
|
||||||
|
|
|
@ -61,7 +61,7 @@ unsigned char *fat_readlfn(unsigned char *dir, int *clu, int *size, int parent)
|
||||||
{
|
{
|
||||||
uint16_t uc2[256], *u;
|
uint16_t uc2[256], *u;
|
||||||
unsigned char *s, *d;
|
unsigned char *s, *d;
|
||||||
int i, n;
|
int i = 0, n;
|
||||||
memset(fat_lfn, 0, sizeof(fat_lfn));
|
memset(fat_lfn, 0, sizeof(fat_lfn));
|
||||||
if(!dir[0]) return dir;
|
if(!dir[0]) return dir;
|
||||||
while(dir[0] == '.') dir += 32;
|
while(dir[0] == '.') dir += 32;
|
||||||
|
@ -77,7 +77,7 @@ unsigned char *fat_readlfn(unsigned char *dir, int *clu, int *size, int parent)
|
||||||
dir = fat_data + parent * fat_bpc;
|
dir = fat_data + parent * fat_bpc;
|
||||||
}
|
}
|
||||||
if(dir[0xB] != 0xF) {
|
if(dir[0xB] != 0xF) {
|
||||||
for(s = dir, d = fat_lfn; *s && *s != ' ' && i < 8; i++)
|
for(s = dir, d = fat_lfn, i = 0; *s && *s != ' ' && i < 8; i++)
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
if(dir[8] && dir[8] != ' ') {
|
if(dir[8] && dir[8] != ' ') {
|
||||||
*d++ = '.';
|
*d++ = '.';
|
||||||
|
@ -183,6 +183,7 @@ unsigned char *fat_writelfn(unsigned char *dir, char *name, int type, int size,
|
||||||
return dir + 32;
|
return dir + 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** mkbootimg interface ***/
|
||||||
void fat_open(gpt_t *gpt_entry)
|
void fat_open(gpt_t *gpt_entry)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -294,7 +294,6 @@ void fsz_open(gpt_t *gpt_entry)
|
||||||
sb->version_major=FSZ_VERSION_MAJOR;
|
sb->version_major=FSZ_VERSION_MAJOR;
|
||||||
sb->version_minor=FSZ_VERSION_MINOR;
|
sb->version_minor=FSZ_VERSION_MINOR;
|
||||||
sb->logsec=fsz_secsize==2048?0:(fsz_secsize==4096?1:2);
|
sb->logsec=fsz_secsize==2048?0:(fsz_secsize==4096?1:2);
|
||||||
sb->physec=fsz_secsize/512;
|
|
||||||
sb->maxmounts=255;
|
sb->maxmounts=255;
|
||||||
sb->currmounts=0;
|
sb->currmounts=0;
|
||||||
sb->createdate=sb->lastmountdate=sb->lastumountdate=t * 1000000;
|
sb->createdate=sb->lastmountdate=sb->lastumountdate=t * 1000000;
|
||||||
|
|
|
@ -54,10 +54,9 @@ typedef struct {
|
||||||
uint8_t magic[4]; /* 512 */
|
uint8_t magic[4]; /* 512 */
|
||||||
uint8_t version_major; /* 516 */
|
uint8_t version_major; /* 516 */
|
||||||
uint8_t version_minor; /* 517 */
|
uint8_t version_minor; /* 517 */
|
||||||
uint8_t flags; /* 518 flags */
|
uint8_t logsec; /* 518 logical sector size, 0=2048,1=4096(default),2=8192... */
|
||||||
uint8_t enctype; /* 519 encryption alogirthm */
|
uint8_t enctype; /* 519 encryption alogirthm */
|
||||||
uint16_t logsec; /* 520 logical sector size, 0=2048,1=4096(default),2=8192... */
|
uint32_t flags; /* 520 flags */
|
||||||
uint16_t physec; /* 522 how many physical sector gives up a logical one, defaults to 8 */
|
|
||||||
uint16_t maxmounts; /* 524 number of maximum mounts allowed to next fsck */
|
uint16_t maxmounts; /* 524 number of maximum mounts allowed to next fsck */
|
||||||
uint16_t currmounts; /* 526 current mount counter */
|
uint16_t currmounts; /* 526 current mount counter */
|
||||||
uint64_t numsec; /* 528 total number of logical sectors */
|
uint64_t numsec; /* 528 total number of logical sectors */
|
||||||
|
@ -95,16 +94,17 @@ typedef struct {
|
||||||
#define FSZ_MAGIC "FS/Z"
|
#define FSZ_MAGIC "FS/Z"
|
||||||
#define FSZ_RAIDMAGIC "FSRD"
|
#define FSZ_RAIDMAGIC "FSRD"
|
||||||
|
|
||||||
/* feature flags */
|
|
||||||
#define FSZ_SB_FLAG_BIGINODE (1<<0) /* indicates inode size is 2048 (ACL size 96 instead of 32) */
|
|
||||||
#define FSZ_SB_JOURNAL_DATA (1<<1) /* also put file content records in journal file, not just metadata */
|
|
||||||
#define FSZ_SB_SOFTRAID (1<<2) /* single disk when not set */
|
|
||||||
#define FSZ_SB_ACCESSDATE (1<<3) /* store last access timestamp in i-nodes */
|
|
||||||
/* bits 4 - 7 are reserved for future use */
|
|
||||||
#define FSZ_SB_EALG_SHACBC 0 /* encrypted with SHA-XOR-CBC */
|
#define FSZ_SB_EALG_SHACBC 0 /* encrypted with SHA-XOR-CBC */
|
||||||
#define FSZ_SB_EALG_AESCBC 1 /* encrypted with AES-256-CBC */
|
#define FSZ_SB_EALG_AESCBC 1 /* encrypted with AES-256-CBC */
|
||||||
/* values 2 - 255 are reserved for future use */
|
/* values 2 - 255 are reserved for future use */
|
||||||
|
|
||||||
|
/* feature flags */
|
||||||
|
#define FSZ_SB_BIGINODE (1<<0) /* indicates inode size is 2048 (ACL size 96 instead of 32) */
|
||||||
|
#define FSZ_SB_JOURNAL_DATA (1<<1) /* also put file content records in journal file, not just metadata */
|
||||||
|
#define FSZ_SB_SOFTRAID (1<<2) /* single disk when not set */
|
||||||
|
#define FSZ_SB_ACCESSDATE (1<<3) /* store last access timestamp in i-nodes */
|
||||||
|
/* bits 4 - 31 are reserved for future use */
|
||||||
|
|
||||||
/*********************************************************
|
/*********************************************************
|
||||||
* I-node sector *
|
* I-node sector *
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
|
@ -202,9 +202,7 @@ typedef struct {
|
||||||
|
|
||||||
#define FSZ_IN_MAGIC "FSIN"
|
#define FSZ_IN_MAGIC "FSIN"
|
||||||
|
|
||||||
/* (*) according to IANA, there's only two groups of mime types which does not fit into this (both vendor specific):
|
/* (*) according to IANA, all, more than 1700 mime types are unique on 4+60 bytes. */
|
||||||
* application/vnd.collabio.xodicuments.* and application/vnd.openxmlformats-officedocument.*
|
|
||||||
* those two must be shortend. All the other, more than 1700 mime types are unique on 4+36 bytes. */
|
|
||||||
|
|
||||||
/* regular files, 4th character never ':' */
|
/* regular files, 4th character never ':' */
|
||||||
#define FSZ_FILETYPE_REG_TEXT "text" /* main part of mime type */
|
#define FSZ_FILETYPE_REG_TEXT "text" /* main part of mime type */
|
||||||
|
@ -220,6 +218,7 @@ typedef struct {
|
||||||
#define FSZ_FILETYPE_SYMLINK "lnk:" /* symbolic link, inlined data is a path */
|
#define FSZ_FILETYPE_SYMLINK "lnk:" /* symbolic link, inlined data is a path */
|
||||||
#define FSZ_FILETYPE_PIPE "pip:" /* named pipe (FIFO) */
|
#define FSZ_FILETYPE_PIPE "pip:" /* named pipe (FIFO) */
|
||||||
#define FSZ_FILETYPE_DEV "dev:" /* device */
|
#define FSZ_FILETYPE_DEV "dev:" /* device */
|
||||||
|
#define FSZ_FILETYPE_SOCK "sck:" /* socket */
|
||||||
|
|
||||||
/* mime types for filesystem specific files */
|
/* mime types for filesystem specific files */
|
||||||
/* for FSZ_FILETYPE_DIR */
|
/* for FSZ_FILETYPE_DIR */
|
||||||
|
|
|
@ -26,12 +26,13 @@
|
||||||
* This file is part of the BOOTBOOT Protocol package.
|
* This file is part of the BOOTBOOT Protocol package.
|
||||||
* @brief LeanFS file system driver
|
* @brief LeanFS file system driver
|
||||||
* See http://freedos-32.sourceforge.net/lean/specification.php
|
* See http://freedos-32.sourceforge.net/lean/specification.php
|
||||||
|
* See http://www.fysnet.net/leanfs/specification.php
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#define LEAN_SUPER_MAGIC 0x4E41454C
|
#define LEAN_SUPER_MAGIC 0x4E41454C
|
||||||
#define LEAN_SUPER_VERSION 0x0006
|
#define LEAN_SUPER_VERSION 0x0007 /* could be 0x0006 as well, backwards compatible */
|
||||||
#define LEAN_INODE_MAGIC 0x45444F4E
|
#define LEAN_INODE_MAGIC 0x45444F4E
|
||||||
#define LEAN_INODE_EXTENT_CNT 6
|
#define LEAN_INODE_EXTENT_CNT 6
|
||||||
#define LEAN_FT_MT 0
|
#define LEAN_FT_MT 0
|
||||||
|
@ -63,15 +64,16 @@ typedef struct {
|
||||||
uint64_t bitmap_start;
|
uint64_t bitmap_start;
|
||||||
uint64_t root_inode;
|
uint64_t root_inode;
|
||||||
uint64_t bad_inode;
|
uint64_t bad_inode;
|
||||||
uint8_t reserved2[360];
|
uint64_t journal_inode;
|
||||||
|
uint8_t log_block_size;
|
||||||
|
uint8_t reserved2[344];
|
||||||
} __attribute__((packed)) lean_super_t;
|
} __attribute__((packed)) lean_super_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t checksum;
|
uint32_t checksum;
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
uint8_t extent_count;
|
uint8_t extent_count;
|
||||||
uint8_t inode_size;
|
uint8_t reserved[3];
|
||||||
uint16_t reserved;
|
|
||||||
uint32_t indirect_count;
|
uint32_t indirect_count;
|
||||||
uint32_t links_count;
|
uint32_t links_count;
|
||||||
uint32_t uid;
|
uint32_t uid;
|
||||||
|
@ -153,9 +155,6 @@ int len_alloc_inode(uint16_t mode, uint8_t type, uint64_t size, time_t t)
|
||||||
int n = len_alloc_blk(), i;
|
int n = len_alloc_blk(), i;
|
||||||
inode = (lean_inode_t*)(fs_base + n * 512);
|
inode = (lean_inode_t*)(fs_base + n * 512);
|
||||||
inode->magic = LEAN_INODE_MAGIC;
|
inode->magic = LEAN_INODE_MAGIC;
|
||||||
#if LEAN_SUPER_VERSION == 0x0007
|
|
||||||
inode->inode_size = sizeof(lean_inode_t) / 4;
|
|
||||||
#endif
|
|
||||||
inode->attributes = (mode & 0xFFF) | LEAN_ATTR_IFTYPE(type) | LEAN_ATTR_INLINEXTATTR |
|
inode->attributes = (mode & 0xFFF) | LEAN_ATTR_IFTYPE(type) | LEAN_ATTR_INLINEXTATTR |
|
||||||
(type == LEAN_FT_DIR ? LEAN_ATTR_PREALLOC : 0);
|
(type == LEAN_FT_DIR ? LEAN_ATTR_PREALLOC : 0);
|
||||||
inode->atime = inode->ctime = inode->mtime = inode->btime = (uint64_t)t * 1000000;
|
inode->atime = inode->ctime = inode->mtime = inode->btime = (uint64_t)t * 1000000;
|
||||||
|
@ -230,6 +229,7 @@ uint8_t *len_add_dirent(uint8_t *dir, uint64_t toinode, uint64_t ino, uint8_t ty
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** mkbootimg interface ***/
|
||||||
void len_open(gpt_t *gpt_entry)
|
void len_open(gpt_t *gpt_entry)
|
||||||
{
|
{
|
||||||
int i, j, numband;
|
int i, j, numband;
|
||||||
|
@ -250,6 +250,7 @@ void len_open(gpt_t *gpt_entry)
|
||||||
len_sb->state = 1;
|
len_sb->state = 1;
|
||||||
memcpy(&len_sb->uuid, &gpt_entry->guid, sizeof(guid_t));
|
memcpy(&len_sb->uuid, &gpt_entry->guid, sizeof(guid_t));
|
||||||
memcpy(&len_sb->volume_label, "NO NAME", 7);
|
memcpy(&len_sb->volume_label, "NO NAME", 7);
|
||||||
|
len_sb->log_block_size = 9;
|
||||||
len_sb->sector_count = len_numblk;
|
len_sb->sector_count = len_numblk;
|
||||||
len_sb->free_sector_count = len_numblk - 34 - numband * LEAN_BITMAPSIZE; /* loader, superblock, backup, bitmaps */
|
len_sb->free_sector_count = len_numblk - 34 - numband * LEAN_BITMAPSIZE; /* loader, superblock, backup, bitmaps */
|
||||||
len_sb->primary_super = 32;
|
len_sb->primary_super = 32;
|
||||||
|
|
|
@ -253,6 +253,7 @@ void mnx_enter_dir(ino_t parent, char const *name, ino_t child)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** mkbootimg interface ***/
|
||||||
void mnx_open(gpt_t *gpt_entry)
|
void mnx_open(gpt_t *gpt_entry)
|
||||||
{
|
{
|
||||||
zone_t z;
|
zone_t z;
|
||||||
|
|
|
@ -57,9 +57,7 @@ fsz_initrd:
|
||||||
; encrypted initrd?
|
; encrypted initrd?
|
||||||
cmp dword [esi+708], 0 ; FSZ_SuperBlock.enchash
|
cmp dword [esi+708], 0 ; FSZ_SuperBlock.enchash
|
||||||
jz .noenc
|
jz .noenc
|
||||||
mov al, byte [esi+518] ; FSZ_SuperBlock.flags
|
mov al, byte [esi+519] ; FSZ_SuperBlock.enctype
|
||||||
shr al, 2
|
|
||||||
and al, 7
|
|
||||||
or al, al
|
or al, al
|
||||||
jz @f
|
jz @f
|
||||||
prot_realmode
|
prot_realmode
|
||||||
|
@ -199,8 +197,8 @@ fsz_initrd:
|
||||||
|
|
||||||
; get root dir inode
|
; get root dir inode
|
||||||
.noenc: mov dword [_i], 1024
|
.noenc: mov dword [_i], 1024
|
||||||
mov al, byte [esi+518] ; FSZ_SuperBlock.flags
|
mov al, byte [esi+520] ; FSZ_SuperBlock.flags
|
||||||
bt ax, 0 ; FSZ_FLAG_BIGINODE?
|
bt ax, 0 ; FSZ_SB_BIGINODE?
|
||||||
jnc @f
|
jnc @f
|
||||||
mov dword [_i], 2048
|
mov dword [_i], 2048
|
||||||
@@: mov eax, dword [esi+560] ; FSZ_SuperBlock.rootdirfid
|
@@: mov eax, dword [esi+560] ; FSZ_SuperBlock.rootdirfid
|
||||||
|
|
|
@ -38,12 +38,12 @@ file_t fsz_initrd(unsigned char *initrd_p, char *kernel)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
unsigned char passphrase[256],chk[32],iv[32];
|
unsigned char passphrase[256],chk[32],iv[32];
|
||||||
unsigned int i,j,k,l,ss=1<<(*((uint16_t*)(initrd_p+520))+11);
|
unsigned int i,j,k,l,ss=1<<(initrd_p[518]+11);
|
||||||
unsigned char *ent, *in=(initrd_p+*((uint64_t*)(initrd_p+560))*ss);
|
unsigned char *ent, *in=(initrd_p+*((uint64_t*)(initrd_p+560))*ss);
|
||||||
SHA256_CTX ctx;
|
SHA256_CTX ctx;
|
||||||
DBG(" * FS/Z %s\n",kernel);
|
DBG(" * FS/Z %s\n",kernel);
|
||||||
//decrypt initrd
|
//decrypt initrd
|
||||||
if(*((uint32_t*)(initrd_p+708))!=0 && ((initrd_p[518]>>2)&7)!=0) {
|
if(*((uint32_t*)(initrd_p+708))!=0 && initrd_p[519]!=0) {
|
||||||
printf("BOOTBOOT-PANIC: Unsupported cipher\n");
|
printf("BOOTBOOT-PANIC: Unsupported cipher\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -92,8 +92,8 @@ again:
|
||||||
if(*e=='/'){e++;}
|
if(*e=='/'){e++;}
|
||||||
if(!memcmp(in,"FSIN",4)){
|
if(!memcmp(in,"FSIN",4)){
|
||||||
//is it inlined?
|
//is it inlined?
|
||||||
if(!memcmp(initrd_p[518]&1? in + 2048 : in + 1024,"FSDR",4)){
|
if(!memcmp(initrd_p[520]&1? in + 2048 : in + 1024,"FSDR",4)){
|
||||||
ent=(initrd_p[518]&1? in + 2048 : in + 1024);
|
ent=(initrd_p[520]&1? in + 2048 : in + 1024);
|
||||||
} else if(!memcmp(initrd_p+*((uint64_t*)(in+448))*ss,"FSDR",4)){
|
} else if(!memcmp(initrd_p+*((uint64_t*)(in+448))*ss,"FSDR",4)){
|
||||||
// go, get the sector pointed
|
// go, get the sector pointed
|
||||||
ent=(initrd_p+*((uint64_t*)(in+448))*ss);
|
ent=(initrd_p+*((uint64_t*)(in+448))*ss);
|
||||||
|
@ -128,12 +128,12 @@ again:
|
||||||
switch(in[488]) {
|
switch(in[488]) {
|
||||||
case 0xFF:
|
case 0xFF:
|
||||||
// inline data
|
// inline data
|
||||||
ret.ptr=(uint8_t*)(initrd_p+i*ss+(initrd_p[518]&1? 2048 : 1024));
|
ret.ptr=(uint8_t*)(initrd_p+i*ss+(initrd_p[520]&1? 2048 : 1024));
|
||||||
break;
|
break;
|
||||||
case 0x80:
|
case 0x80:
|
||||||
case 0x7F:
|
case 0x7F:
|
||||||
// sector directory or list inlined
|
// sector directory or list inlined
|
||||||
ret.ptr=(uint8_t*)(initrd_p + *((uint64_t*)(initrd_p[518]&1? in + 2048 : in + 1024))*ss);
|
ret.ptr=(uint8_t*)(initrd_p + *((uint64_t*)(initrd_p[520]&1? in + 2048 : in + 1024))*ss);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
// direct data
|
// direct data
|
||||||
|
|
|
@ -38,7 +38,7 @@ file_t fsz_initrd(unsigned char *initrd_p, char *kernel)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
unsigned char passphrase[256],chk[32],iv[32];
|
unsigned char passphrase[256],chk[32],iv[32];
|
||||||
unsigned int i,j,k,l,ss=1<<(*((uint16_t*)(initrd_p+520))+11);
|
unsigned int i,j,k,l,ss=1<<(initrd_p[519]+11);
|
||||||
unsigned char *ent, *in=(initrd_p+*((uint64_t*)(initrd_p+560))*ss);
|
unsigned char *ent, *in=(initrd_p+*((uint64_t*)(initrd_p+560))*ss);
|
||||||
SHA256_CTX ctx;
|
SHA256_CTX ctx;
|
||||||
DBG(L" * FS/Z %s\n",a2u(kernel));
|
DBG(L" * FS/Z %s\n",a2u(kernel));
|
||||||
|
@ -95,8 +95,8 @@ again:
|
||||||
if(*e=='/'){e++;}
|
if(*e=='/'){e++;}
|
||||||
if(!CompareMem(in,"FSIN",4)){
|
if(!CompareMem(in,"FSIN",4)){
|
||||||
//is it inlined?
|
//is it inlined?
|
||||||
if(!CompareMem(initrd_p[518]&1? in + 2048 : in + 1024,"FSDR",4)){
|
if(!CompareMem(initrd_p[520]&1? in + 2048 : in + 1024,"FSDR",4)){
|
||||||
ent=(initrd_p[518]&1? in + 2048 : in + 1024);
|
ent=(initrd_p[520]&1? in + 2048 : in + 1024);
|
||||||
} else if(!CompareMem(initrd_p+*((uint64_t*)(in+448))*ss,"FSDR",4)){
|
} else if(!CompareMem(initrd_p+*((uint64_t*)(in+448))*ss,"FSDR",4)){
|
||||||
// go, get the sector pointed
|
// go, get the sector pointed
|
||||||
ent=(initrd_p+*((uint64_t*)(in+448))*ss);
|
ent=(initrd_p+*((uint64_t*)(in+448))*ss);
|
||||||
|
@ -131,12 +131,12 @@ again:
|
||||||
switch(in[488]) {
|
switch(in[488]) {
|
||||||
case 0xFF:
|
case 0xFF:
|
||||||
// inline data
|
// inline data
|
||||||
ret.ptr=(uint8_t*)(initrd_p+i*ss+(initrd_p[518]&1? 2048 : 1024));
|
ret.ptr=(uint8_t*)(initrd_p+i*ss+(initrd_p[520]&1? 2048 : 1024));
|
||||||
break;
|
break;
|
||||||
case 0x80:
|
case 0x80:
|
||||||
case 0x7F:
|
case 0x7F:
|
||||||
// sector directory or list inlined
|
// sector directory or list inlined
|
||||||
ret.ptr=(uint8_t*)(initrd_p + *((uint64_t*)(initrd_p[518]&1? in + 2048 : in + 1024))*ss);
|
ret.ptr=(uint8_t*)(initrd_p + *((uint64_t*)(initrd_p[520]&1? in + 2048 : in + 1024))*ss);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
// direct data
|
// direct data
|
||||||
|
|
Loading…
Reference in a new issue