1
0
Fork 0
mirror of https://gitlab.com/bztsrc/bootboot.git synced 2023-02-13 20:54:32 -05:00

FS/Z update

This commit is contained in:
bzt 2021-03-23 17:54:13 +01:00
parent e018b9b5e5
commit 6b0a5504c1
15 changed files with 150 additions and 130 deletions

View file

@ -107,7 +107,7 @@ again:
//iterate on directory entries
int j=*((uint64_t*)(hdr+16));
while(j-->0){
if(!memcmp(ent + 17,s,e-s)) {
if(!memcmp(ent + 16,s,e-s)) {
if(*e==0) {
i=*((uint64_t*)(ent+0));
break;

BIN
dist/bootboot.bin vendored

Binary file not shown.

BIN
dist/bootboot.efi vendored

Binary file not shown.

BIN
dist/bootboot.img vendored

Binary file not shown.

BIN
dist/bootboot.rom vendored

Binary file not shown.

View file

@ -14,7 +14,7 @@ fájlrendszerek:
| `cpio` | ✔Yes | ✗No | [wikipédia](https://en.wikipedia.org/wiki/Cpio) |
| `tar` | ✔Yes | ✔Yes | [wikipédia](https://wiki.osdev.org/USTAR) |
| `echfs` | ✔Yes | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/blob/binaries/specs/echfs.md), [forrás](https://github.com/echfs/echfs) |
| `FS/Z` | ✔Yes | ✔Yes | [forrás](https://gitlab.com/bztsrc/bootboot/blob/master/mkbootimg/fsZ.h) |
| `FS/Z` | ✔Yes | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/fsz.pdf) [forrás](https://gitlab.com/bztsrc/bootboot/blob/master/mkbootimg/fsZ.h) |
| `boot` | ✗No | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/efifat.pdf) (csak ESP, 8+3 nevek) |
| `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) |

View file

@ -13,7 +13,7 @@ also creates an initrd or a disk partition from a directory. Supported file syst
| `cpio` | ✔Yes | ✗No | [wikipedia](https://en.wikipedia.org/wiki/Cpio) |
| `tar` | ✔Yes | ✔Yes | [wikipedia](https://wiki.osdev.org/USTAR) |
| `echfs` | ✔Yes | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/blob/binaries/specs/echfs.md), [source](https://github.com/echfs/echfs) |
| `FS/Z` | ✔Yes | ✔Yes | [source](https://gitlab.com/bztsrc/bootboot/blob/master/mkbootimg/fsZ.h) |
| `FS/Z` | ✔Yes | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/fsz.pdf) [source](https://gitlab.com/bztsrc/bootboot/blob/master/mkbootimg/fsZ.h) |
| `boot` | ✗No | ✔Yes | [spec](https://gitlab.com/bztsrc/bootboot/raw/binaries/specs/efifat.pdf) (ESP only, 8+3 names) |
| `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) |

File diff suppressed because one or more lines are too long

View file

@ -3,11 +3,11 @@
#define sizeof_boot_bin 512
extern unsigned char binary_boot_bin[512];
#define sizeof_bootboot_bin 13312
extern unsigned char binary_bootboot_bin[9285];
extern unsigned char binary_bootboot_bin[9284];
#define sizeof_bootboot_efi 103614
extern unsigned char binary_bootboot_efi[46278];
#define sizeof_bootboot_img 35488
extern unsigned char binary_bootboot_img[20151];
extern unsigned char binary_bootboot_img[20150];
#define sizeof_bootboot_rv64 8192
extern unsigned char binary_bootboot_rv64[31];
#define sizeof_LICENCE_broadcom 1594

View file

@ -61,11 +61,11 @@ int fsz_add_inode(char *filetype, char *mimetype)
memcpy(in->filetype,filetype,i>4?4:i);
if(!strcmp(filetype,FSZ_FILETYPE_DIR)){
hdr=(FSZ_DirEntHeader *)(in->data.small.inlinedata);
in->sec=fs_len/fsz_secsize;
in->sec=hdr->fid=fs_len/fsz_secsize;
in->flags=FSZ_IN_FLAG_INLINE;
in->size=sizeof(FSZ_DirEntHeader);
memcpy(in->data.small.inlinedata,FSZ_DIR_MAGIC,4);
hdr->checksum=crc32_calc((unsigned char*)hdr+sizeof(FSZ_DirEntHeader),hdr->numentries*sizeof(FSZ_DirEnt));
hdr->checksum=crc32_calc((unsigned char*)hdr+16,hdr->numentries*sizeof(FSZ_DirEnt));
}
}
if(mimetype!=NULL){
@ -79,7 +79,7 @@ int fsz_add_inode(char *filetype, char *mimetype)
if(j!=36)
in->size=i;
}
in->changedate=t * 1000000;
in->changedate=in->createdate=t * 1000000;
in->modifydate=t * 1000000;
in->checksum=crc32_calc(in->filetype,1016);
fs_len+=fsz_secsize;
@ -88,7 +88,7 @@ int fsz_add_inode(char *filetype, char *mimetype)
void fsz_link_inode(int inode, char *path, int toinode)
{
unsigned int ns=0,cnt=0;
unsigned int ns=0,cnt=0,l=strlen(path);
FSZ_DirEntHeader *hdr;
FSZ_DirEnt *ent;
FSZ_Inode *in, *in2;
@ -107,10 +107,10 @@ void fsz_link_inode(int inode, char *path, int toinode)
in=((FSZ_Inode *)(fs_base+toinode*fsz_secsize));
in2=((FSZ_Inode *)(fs_base+inode*fsz_secsize));
ent->fid=inode;
ent->length=strlen(path);
memcpy(ent->name,path,strlen(path));
if(l > 110) l = 110;
memcpy(ent->name,path,l);
if(!strncmp((char *)(((FSZ_Inode *)(fs_base+inode*fsz_secsize))->filetype),FSZ_FILETYPE_DIR,4)){
ent->name[ent->length++]='/';
ent->name[l]='/';
}
/* the format can hold 2^127 directory entries, but we only implement directories embedded in inodes here, up to 23 */
if(hdr->numentries >= (fsz_secsize - 1024 - sizeof(FSZ_DirEntHeader)) / sizeof(FSZ_DirEnt)) {
@ -120,7 +120,7 @@ void fsz_link_inode(int inode, char *path, int toinode)
in->modifydate=t * 1000000;
in->size+=sizeof(FSZ_DirEnt);
qsort((char*)hdr+sizeof(FSZ_DirEntHeader), hdr->numentries, sizeof(FSZ_DirEnt), fsz_direntcmp);
hdr->checksum=crc32_calc((unsigned char*)hdr+sizeof(FSZ_DirEntHeader),hdr->numentries*sizeof(FSZ_DirEnt));
hdr->checksum=crc32_calc((unsigned char*)hdr+16,hdr->numentries*sizeof(FSZ_DirEnt));
in->checksum=crc32_calc(in->filetype,1016);
in2->numlinks++;
in2->checksum=crc32_calc(in2->filetype,1016);
@ -158,12 +158,12 @@ void fsz_add_file(char *name, unsigned char *data, unsigned long int size)
if(j*16>fsz_secsize){ fprintf(stderr,"mkbootimg: partition #%d %s: %s\n", fs_no, lang[ERR_TOOBIG], name); exit(1); }
if(j*16<=fsz_secsize-1024) {
ptr=(unsigned char*)&in->data.small.inlinedata;
in->flags=FSZ_IN_FLAG_SDINLINE;
in->flags=FSZ_IN_FLAG_SD0;
in->numblocks=0;
l=0;
} else {
ptr=fs_base+size;
in->flags=FSZ_IN_FLAG_SD;
in->flags=FSZ_IN_FLAG_SD1;
in->numblocks=1;
l=1;
}
@ -181,7 +181,7 @@ void fsz_add_file(char *name, unsigned char *data, unsigned long int size)
}
ptr+=16;
}
if(in->flags==FSZ_IN_FLAG_SD)
if(in->flags==FSZ_IN_FLAG_SD1)
size+=fsz_secsize;
} else {
in->flags=FSZ_IN_FLAG_DIRECT;
@ -291,17 +291,15 @@ void fsz_open(gpt_t *gpt_entry)
memset(fs_base,0,2*fsz_secsize);
sb=(FSZ_SuperBlock *)(fs_base);
memcpy(sb->magic,FSZ_MAGIC,4);
memcpy((char*)&sb->owner,"root",4);
sb->version_major=FSZ_VERSION_MAJOR;
sb->version_minor=FSZ_VERSION_MINOR;
sb->raidtype=FSZ_SB_SOFTRAID_NONE;
sb->logsec=fsz_secsize==2048?0:(fsz_secsize==4096?1:2);
sb->physec=fsz_secsize/512;
sb->maxmounts=255;
sb->currmounts=0;
sb->createdate=sb->lastchangedate=t * 1000000;
sb->createdate=sb->lastmountdate=sb->lastumountdate=t * 1000000;
if(gpt_entry) {
memcpy(&sb->uuid, (void*)(gpt_entry + 16), sizeof(guid_t));
memcpy(&sb->uuid, &gpt_entry->guid, 16);
fsz_max = (gpt_entry->last - gpt_entry->start + 1) * 512;
sb->numsec = fsz_max / fsz_secsize;
} else {

View file

@ -46,25 +46,6 @@
/* for CRC32 the Castagnoli method is used, polynomial 0x1EDC6F41 (differs to ANSI
* CRC32a in EFI GPT and in gzip) but has hardware support on many architectures */
/* sizeof = 16, one Access Control Entry, UUID without the last byte */
typedef struct {
uint32_t Data1;
uint16_t Data2;
uint16_t Data3;
uint8_t Data4[7];
uint8_t access;
} __attribute__((packed)) FSZ_Access;
/* access rights are stored in the last byte. Make sure this matches
* the system access flags A_* in sys/types.h */
#define FSZ_READ (1<<0)
#define FSZ_WRITE (1<<1)
#define FSZ_EXEC (1<<2) /* execute or search */
#define FSZ_APPEND (1<<3)
#define FSZ_DELETE (1<<4)
#define FSZ_SUID (1<<6) /* Set user id on execution */
#define FSZ_SGID (1<<7) /* Inherit ACL, no set group per se in OS/Z */
/*********************************************************
* 1st sector, the super block *
*********************************************************/
@ -74,7 +55,7 @@ typedef struct {
uint8_t version_major; /* 516 */
uint8_t version_minor; /* 517 */
uint8_t flags; /* 518 flags */
uint8_t raidtype; /* 519 raid type */
uint8_t enctype; /* 519 encryption alogirthm */
uint16_t logsec; /* 520 logical sector size, 0=2048,1=4096(default),2=8192... */
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 */
@ -102,42 +83,60 @@ typedef struct {
uint32_t enchash; /* 708 password CRC32, to avoid decryption with bad passwords */
uint64_t createdate; /* 712 creation timestamp UTC */
uint64_t lastmountdate; /* 720 last time fs was mounted */
uint64_t lastcheckdate; /* 728 last time fs was checked with fsck */
uint64_t lastchangedate; /* 736 time when superblock was written to disk */
uint64_t lastumountdate; /* 728 time when superblock was written to disk, must be zero when its mounted */
uint64_t lastcheckdate; /* 736 last time fs was checked with fsck */
uint8_t uuid[16]; /* 744 filesystem UUID */
FSZ_Access owner; /* 760 owner UUID */
uint8_t reserved[240]; /* 776 reserved for access list */
uint8_t reserved[256]; /* 760 reserved for access list */
uint8_t magic2[4]; /*1016 */
uint32_t checksum; /*1020 CRC32 of bytes at 512-1020 */
uint8_t raidspecific[FSZ_SECSIZE-1024];
} __attribute__((packed)) FSZ_SuperBlock;
#define FSZ_MAGIC "FS/Z"
#define FSZ_MAGIC "FS/Z"
#define FSZ_RAIDMAGIC "FSRD"
#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_EALG_SHACBC (0<<2) /* encrypted with SHA-XOR-CBC */
#define FSZ_SB_EALG_AESCBC (1<<2) /* encrypted with AES-256-CBC */
/* bits 3 and 4 reserved for future encryption algos */
#define FSZ_SB_EALG(x) ((x>>2)&7)
#define FSZ_SB_SOFTRAID_NONE 0xff /* single disk */
#define FSZ_SB_SOFTRAID0 0 /* mirror */
#define FSZ_SB_SOFTRAID1 1 /* concatenate */
#define FSZ_SB_SOFTRAID5 5 /* xored blocks */
/* 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_AESCBC 1 /* encrypted with AES-256-CBC */
/* values 2 - 255 are reserved for future use */
/*********************************************************
* I-node sector *
*********************************************************/
/* fid: file id, logical sector number where the sector contains an inode structure. */
/* sizeof = 16, one Access Control Entry, UUID without the last byte */
typedef struct {
uint32_t Data1;
uint16_t Data2;
uint16_t Data3;
uint8_t Data4[7];
uint8_t access;
} __attribute__((packed)) FSZ_Access;
/* access rights are stored in the last byte. Make sure this matches
* the system access flags A_* in sys/types.h */
#define FSZ_READ (1<<0)
#define FSZ_WRITE (1<<1)
#define FSZ_EXEC (1<<2) /* execute or search */
#define FSZ_APPEND (1<<3)
#define FSZ_DELETE (1<<4)
#define FSZ_GROUP (1<<5)
#define FSZ_SUID (1<<6) /* Set user id on execution */
#define FSZ_SGID (1<<7) /* Inherit ACL, no set group per se in OS/Z */
/* sizeof = 32 */
typedef struct {
uint64_t sec;
uint64_t sec_hi;
uint64_t numsec;
uint32_t numsec_hi;
uint32_t chksum;
uint32_t flags;
} __attribute__((packed)) FSZ_SectorList;
/* used at several places, like free and bad block list inodes, and with FSZ_IN_FLAG_SECLIST* mappings. */
@ -166,15 +165,14 @@ typedef struct {
uint8_t magic[4]; /* 0 magic 'FSIN' */
uint32_t checksum; /* 4 CRC32, filetype to inlinedata (exclusive) */
uint8_t filetype[4]; /* 8 first 4 bytes of mime main type, eg: text,imag,vide,audi,appl etc. */
uint8_t mimetype[36]; /* 12 mime sub type, eg.: plain, html, gif, jpeg etc. (*) */
uint8_t encrypt[28]; /* 56 encryption key mask or zero */
uint32_t enchash; /* 76 password CRC32, to avoid decryption with bad passwords */
uint64_t changedate; /* 80 number of microseconds since 1970. jan. 1 00:00:00 UTC, inode change time */
uint8_t mimetype[60]; /* 12 mime sub type, eg.: plain, html, gif, jpeg etc. (*) */
uint64_t createdate; /* 72 number of microseconds since 1970. jan. 1 00:00:00 UTC, inode creation time */
uint64_t changedate; /* 80 number of microseconds since 1970. jan. 1 00:00:00 UTC, inode status change time */
uint64_t accessdate; /* 88 last data access time (if implemented, otherwise zero) */
uint64_t numblocks; /* 96 number of blocks allocated for this inode (**) */
uint64_t numlinks; /* 104 number of references to this inode */
uint64_t metalabel; /* 112 logical sector number of meta label block */
uint64_t metalabel_hi;
uint64_t metasec; /* 112 logical sector number of meta label block */
uint64_t metasec_hi;
FSZ_Version version5; /* 128 previous oldest version (if versioning enabled) */
FSZ_Version version4; /* 192 all the same format as the current one */
FSZ_Version version3; /* 256 see FSZ_Version structure above */
@ -202,7 +200,7 @@ typedef struct {
} data;
} __attribute__((packed)) FSZ_Inode;
#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):
* application/vnd.collabio.xodicuments.* and application/vnd.openxmlformats-officedocument.*
@ -220,14 +218,17 @@ typedef struct {
#define FSZ_FILETYPE_UNION "uni:" /* directory union, inlined data is a zero separated list of paths with jokers */
#define FSZ_FILETYPE_INTERNAL "int:" /* internal files, like free and bad sectors and meta info */
#define FSZ_FILETYPE_SYMLINK "lnk:" /* symbolic link, inlined data is a path */
#define FSZ_FILETYPE_PIPE "pip:" /* named pipe (FIFO) */
#define FSZ_FILETYPE_DEV "dev:" /* device */
/* mime types for filesystem specific files */
/* for FSZ_FILETYPE_DIR */
#define FSZ_MIMETYPE_DIR_ROOT "fs-root" /* root directory (for recovery it has a special mime type) */
#define FSZ_MIMETYPE_DIR_ROOT "fs-root" /* root directory (for recovery it has a special mime type) */
/* for FSZ_FILETYPE_INTERNAL */
#define FSZ_MIMETYPE_INT_FREELST "fs-free-sectors" /* for free sector list */
#define FSZ_MIMETYPE_INT_BADLST "fs-bad-sectors" /* for bad sector list */
#define FSZ_MIMETYPE_INT_META "fs-meta-labels" /* meta labels */
#define FSZ_MIMETYPE_INT_INDEX "fs-search-index" /* search cache */
#define FSZ_MIMETYPE_INT_META "fs-meta-labels" /* meta labels */
#define FSZ_MIMETYPE_INT_JOURNAL "fs-journal" /* journaling records (contains only metadata) */
#define FSZ_MIMETYPE_INT_JOURDAT "fs-journal-data" /* journaling records (file contents also journaled) */
@ -237,9 +238,7 @@ typedef struct {
/* flags */
#define FSZ_IN_FLAG_HIST (1<<8) /* indicates that previous file versions are kept */
#define FSZ_IN_FLAG_CHKSUM (1<<9) /* file has content data checksums too */
#define FSZ_IN_EALG_SHACBC (0<<10) /* file encrypted with SHA-XOR-CBC */
#define FSZ_IN_EALG_AESCBC (1<<10) /* file encrypted with AES-256-CBC */
/* bits 10 and 11 reserved for future encryption algos */
/* bits 10 to 63 are reserved for future use */
/* (***) logical sector address to data sector translation. These file sizes
* were calculated with 4096 sector size. That is configurable in the
@ -269,13 +268,13 @@ typedef struct {
FSZ_Inode.sec points to itself, sector directory inlined.
with BIGINODE, this format supports 512k mapping.
FSZ_Inode.sec -> FSZ_Inode.sec; sd -> data */
#define FSZ_IN_FLAG_SDINLINE (0x7F<<0)
#define FSZ_IN_FLAG_SD0 (0x7F<<0)
/* data size < sector size * sector size / 16 (1 M)
FSZ_Inode.sec points to a sector directory,
which is a sector with up to 256 sector addresses
FSZ_Inode.sec -> sd -> data */
#define FSZ_IN_FLAG_SD (1<<0)
#define FSZ_IN_FLAG_SD1 (1<<0)
/* data size < sector size * sector size / 16 * sector size / 16 (256 M)
FSZ_Inode.sec points to a sector directory,
@ -317,28 +316,27 @@ typedef struct {
/* inlined sector list ((sector size - 1024) / 32, up to 96 entries)
FSZ_Inode.sec points to itself, FSZ_SectorList entries inlined.
FSZ_Inode.sec -> FSZ_Inode.sec; sl -> data */
#define FSZ_IN_FLAG_SECLIST (0x80<<0)
#define FSZ_IN_FLAG_SECLIST0 (0x80<<0)
/* normal sector list ((sector size - 1024) * sector size / 16 / 32, up to 24576 entries)
FSZ_Inode.sec points to itself, with an inlined sector directory
pointing to sectors with FSZ_SectorList entries.
FSZ_Inode.sec -> FSZ_Inode.sec; sd -> sl -> data */
#define FSZ_IN_FLAG_SECLIST0 (0x81<<0)
FSZ_Inode.sec points to a sector list with FSZ_SectorList entries.
FSZ_Inode.sec -> sl -> data */
#define FSZ_IN_FLAG_SECLIST1 (0x81<<0)
/* indirect sector list (up to 32768 entries)
FSZ_Inode.sec points to a sector directory with FSZ_SectorLists
FSZ_Inode.sec -> sd -> sl -> data */
#define FSZ_IN_FLAG_SECLIST1 (0x82<<0)
#define FSZ_IN_FLAG_SECLIST2 (0x82<<0)
/* double-indirect sector list (up to 8388608 entries)
FSZ_Inode.sec points to a sector directory pointing to
sector directories with FSZ_SectorLists
FSZ_Inode.sec -> sd -> sd -> sl -> data */
#define FSZ_IN_FLAG_SECLIST2 (0x83<<0)
#define FSZ_IN_FLAG_SECLIST3 (0x83<<0)
/* triple-indirect sector list (up to 2147483648 entries)
FSZ_Inode.sec -> sd -> sd -> sd -> sl -> data */
#define FSZ_IN_FLAG_SECLIST3 (0x84<<0)
#define FSZ_IN_FLAG_SECLIST4 (0x84<<0)
/*********************************************************
* Directory *
@ -348,14 +346,19 @@ typedef struct {
/* sizeof = 128 */
typedef struct {
uint8_t magic[4];
uint32_t checksum; /* CRC32 of entries */
uint64_t flags;
uint32_t checksum; /* CRC32 of entries from byte 16 to the end */
uint8_t display_type;
uint8_t sorting_order;
uint8_t reserved0[6];
uint64_t numentries;
uint64_t numentries_hi;
uint8_t reserved[96];
uint64_t fid;
uint64_t fid_hi;
uint8_t reserved[79];
uint8_t flags;
} __attribute__((packed)) FSZ_DirEntHeader;
#define FSZ_DIR_MAGIC "FSDR"
#define FSZ_DIR_MAGIC "FSDR"
#define FSZ_DIR_FLAG_UNSORTED (1<<0)
#define FSZ_DIR_FLAG_HASHED (2<<0)
@ -366,46 +369,67 @@ typedef struct {
typedef struct {
uint64_t fid;
uint64_t fid_hi;
uint8_t length; /* number of UNICODE characters in name */
unsigned char name[111]; /* zero terminated UTF-8 string */
unsigned char name[112]; /* zero terminated UTF-8 string */
} __attribute__((packed)) FSZ_DirEnt;
/* names must not contain zero, '/' and ';'. If the entry points to a
* directory i-node, then name must be suffixed by '/' */
/*********************************************************
* Directory union *
*********************************************************/
/* inlined data is a list of asciiz paths that may contain the '...' joker directory.
* Terminated by and empty path.
/* inlined data is a list of zero terminated UTF-8 paths that may contain the
* '...' joker directory. Terminated by and empty path.
* Example union for /usr/bin: inlinedata=/bin(zero)/usr/.../bin(zero)(zero)
*/
/*********************************************************
* Meta labels *
*********************************************************/
/* meta labels are list of sector aligned, key value pairs (with possibly binary values),
* filled up with zeros to be multiple of sector size.
*
* Example (assuming meta label file starts at lsn 1234):
* (length) "icon" (zero) "/usr/firefox/share/icon.png" (zero) (zeros padding to sector size)
* (length) "icon" (zero) "/usr/vlc/share/icon.svg" (zeros padding to sector size)
*
* Inode of /usr/firefox/bin/firefox: metalabel=1234
* Inode of /usr/vlc/bin/vlc: metalabel=1235
*
* Normally meta labels do not exceed logical sector size. But when they do, the allocation
* must be careful to allocate contiguous sectors for a meta block. This complicates things
* a bit when large meta label blocks (>4096) are written, but simplifies a lot on read by
* eliminating the need of translating LSNs for meta labels file. As meta labels are read more
* often than written, and usually one meta is smaller than 4096, this is intentional.
* In other words, meta label blocks are one or more contiguous sectors per inode on disk, and
* meta labels file covers them just like bad sectors file covers bad sectors.
*/
/*********************************************************
* Search index *
*********************************************************/
/* to be specified. Inode lists for search keywords ("search" meta labels) */
/* superblock indexfid points to a directory with type "dir:fs-search-index"
* that directory contains files, with mime type names, like "imagjpeg/". Names
* starting with "dir:" or "int:" not allowed. Those directory entries must
* point to files of type "int:fs-search-index", which is a list of fid and
* path pairs. Each record starts witha 16 byte fid (to the original i-node),
* followed by a zero terminated UTF-8 path. */
/*********************************************************
* Meta labels *
*********************************************************/
/* meta labels are stored in two places. Meta label file (pointed by metafid in superblock)
* records the UTF-8 encoded keys for 16 bit meta ids, the same way as unions. Each key is
* terminated by a zero and cannot be longer than 255 bytes, and the entire list is terminated
* by an empty string. Meta label sectors in i-nodes point to the starting logical sector with
* contiguous meta values in a key id value pairs (with possibly binary values), filled up
* with zeros to be multiple of sector size.
*
* Normally meta labels do not exceed logical sector size. But when they do, the allocation
* must be careful to allocate contiguous sectors for a meta block. This complicates things
* a bit when large meta label blocks (>4096) are written, but simplifies a lot on read by
* eliminating the need of translating LSNs for meta labels file. As meta labels are read more
* often than written, and usually one meta is smaller than 4096, this is intentional.
*/
/* sizeof = 32 */
typedef struct {
uint8_t magic[4];
uint32_t checksum; /* CRC32 of entries from byte 8 to end */
uint16_t numentries; /* number of meta label key-value pairs */
uint16_t size; /* total size of the meta label values in bytes */
uint32_t reserved;
uint64_t fid; /* back reference to the i-node */
uint64_t fid_hi;
} __attribute__((packed)) FSZ_MetaHeader;
#define FSZ_META_MAGIC "FSMT"
typedef struct {
uint16_t key;
uint16_t size;
} __attribute__((packed)) FSZ_MetaLabel;
/* followed by size bytes, the actual data */
/*********************************************************
* Journal data *
@ -413,19 +437,21 @@ typedef struct {
/* If journal file is specified in SB, then journalhead, journaltail is used to create a circular
* buffer. Journal file must be allocated with FSZ_IN_FLAG_SECLIST and one extent. Each write
* transaction contains data sectors, and is terminated with a transaction end block, which contains
* 16 bytes records (the sector addresses for the data sectors in this transaction). First record is
* the header. */
* transaction contains a header and data sectors. Only meta data is journaled, unless the
* FSZ_SB_JOURNAL_DATA flag is set in the superblock, when both meta and file data written. */
/* sizeof = 16 */
/* sizeof = 32 */
typedef struct {
uint8_t magic[4];
uint32_t checksum; /* CRC32 of entries */
uint64_t numentries; /* number of sectors written in this transaction */
uint32_t checksum; /* CRC32 of entries from byte 8 to end */
uint64_t numentries; /* number of extents written in this transaction */
uint64_t transdate; /* transaction's date and time timestamp */
uint64_t reserved;
} __attribute__((packed)) FSZ_JournalTransaction;
/* followed by 16 bytes sector addresses corresponding to the data sectors in this transaction, up to FSZ_SECSIZE */
/* followed by 32 bytes long FSZ_SectorList entries, padded to logical sector size,
* followed by the data sectors pointed by those FSZ_SectorList entries */
#define FSZ_JT_MAGIC "JRTR"
#define FSZ_JT_MAGIC "FSTR"
/*********************************************************
* Encryption *

View file

@ -337,11 +337,7 @@ again:
void len_close()
{
FILE *f;
if(!fs_base || (uint64_t)fs_len < (len_sb->backup_super + 1) * 512) return;
len_sb->checksum = len_checksum(fs_base + len_sb->primary_super * 512, 128);
memcpy(fs_base + len_sb->backup_super * 512, fs_base + len_sb->primary_super * 512, 512);
f = fopen("test.bin", "w");
fwrite(fs_base, fs_len, 1, f);
fclose(f);
}

View file

@ -235,7 +235,7 @@ fsz_initrd:
mov ecx, dword [esi+16] ; FSZ_DirEntHeader.numentries
mov eax, dword [edi]
@@: add esi, 128 ; directories than
cmp dword [esi+17], eax
cmp dword [esi+16], eax
je @f
dec ecx
jnz @b
@ -279,9 +279,9 @@ fsz_initrd:
mov eax, dword [edi]
mov edx, dword [edi+4]
@@: add esi, 128
cmp dword [esi+21], edx
cmp dword [esi+20], edx
jne .not
cmp dword [esi+17], eax
cmp dword [esi+16], eax
je @f
.not: dec ecx
jnz @b

View file

@ -105,7 +105,7 @@ again:
//iterate on directory entries
int j=*((uint64_t*)(hdr+16));
while(j-->0){
if(!memcmp(ent + 17,s,e-s)) {
if(!memcmp(ent + 16,s,e-s)) {
if(*e==0) {
i=*((uint64_t*)(ent+0));
break;

View file

@ -108,7 +108,7 @@ again:
//iterate on directory entries
int j=*((uint64_t*)(hdr+16));
while(j-->0){
if(!CompareMem(ent + 17,s,e-s)) {
if(!CompareMem(ent + 16,s,e-s)) {
if(*e==0) {
i=*((uint64_t*)(ent+0));
break;