Commit 825a35f1 authored by bzt's avatar bzt

FS/Z content data checksums moved to extents for effectiveness

parent 0332ecfa
......@@ -18,5 +18,5 @@ VARSIZE = 4
HOMESIZE = 4
# --- build system ---
CC=clang --target=${ARCH}-elf
LD=ld.lld -m elf_x86_64
CC=${ARCH}-elf-gcc
LD=${ARCH}-elf-ld
......@@ -33,5 +33,5 @@
./src/sh/main.c:109: // TODO: batch mode
./src/sh/cmd.c:314: // TODO: handle streams, '|', '>', '%d>', '<', '<<EOF'; more cmd_exec() calls for pipes
./src/libui/main.c:159:// TODO: high level api for pixbuf primitives
./src/libc/aarch64/stdlib.S:262: /* TODO: getentropy */
./src/libc/aarch64/stdlib.S:266: /* TODO: getentropy */
./src/libc/x86_64/stdlib.S:479: /* TODO: getentropy */
......@@ -65,8 +65,8 @@ Sector Directory
----------------
A sector that has (logical sector size)/16 entries. The building block of memory paging like translations. As with sector lists,
sector directories can handle LSNs up to 2^128, but describe fix sized, non-continous areas on disk. Not to confuse with common
directories which are used to assign names to fids.
sector directories can handle LSNs up to 2^128 (or 2^96 if data checksum enabled), but describe fix sized, non-continous areas on
disk. Not to confuse with common directories which are used to assign names to fids.
Directory
---------
......
......@@ -52,6 +52,15 @@ typedef struct {
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 *
......@@ -89,11 +98,12 @@ typedef struct {
uint8_t encrypt[28]; // 680 encryption mask for AES or zero
uint32_t enchash; // 708 password Castagnoli CRC32, to avoid decryption with bad passwords
uint64_t createdate; // 712 creation timestamp UTC
uint64_t lastmountdate; // 720
uint64_t lastcheckdate; // 728
uint64_t lastdefragdate; // 736
FSZ_Access owner; // 744 owner UUID
uint8_t reserved[256]; // 760 reserved for access list
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
uint8_t uuid[16]; // 744 filesystem UUID
FSZ_Access owner; // 760 owner UUID
uint8_t reserved[240]; // 776 reserved for access list
uint8_t magic2[4]; //1016
uint32_t checksum; //1020 Castagnoli CRC32 of bytes at 512-1020
uint8_t raidspecific[FSZ_SECSIZE-1024];
......@@ -103,7 +113,7 @@ typedef struct {
#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 serpent SHA-256
#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)
......@@ -123,19 +133,18 @@ typedef struct {
uint64_t sec;
uint64_t sec_hi;
uint64_t numsec;
uint64_t numsec_hi;
uint32_t chksum;
uint32_t flags;
} __attribute__((packed)) FSZ_SectorList;
// used at several places, like free and bad block list inodes.
// used at several places, like free and bad block list inodes, and with FSZ_IN_FLAG_SECLIST* mappings.
//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
//sizeof = 16
typedef struct {
uint64_t sec;
uint32_t sec_hi;
uint32_t chksum;
} __attribute__((packed)) FSZ_SDEntry;
// used with FSZ_IN_FLAG_SD* mappings.
//file version structure. You can use this to point to version5, version4 etc.
//sizeof = 64
......@@ -145,8 +154,7 @@ typedef struct {
uint64_t size;
uint64_t size_hi;
uint64_t modifydate;
uint32_t filechksum;
uint32_t flags;
uint64_t flags;
FSZ_Access owner;
} __attribute__((packed)) FSZ_Version;
......@@ -175,8 +183,7 @@ typedef struct {
uint64_t size; // 464 file size
uint64_t size_hi;
uint64_t modifydate;// 480
uint32_t filechksum;// 488 Castagnoli CRC32 of data or zero
uint32_t flags; // 492 see FSZ_IN_FLAG_* (***)
uint64_t flags; // 488 see FSZ_IN_FLAG_* (***)
//owner is the last in FSZ_Version to followed by ACL, so it can be considered to be the first
//entry in the Access Control List. It is the control ACE, specifies who can modify the ACL.
FSZ_Access owner; // 496
......@@ -196,7 +203,7 @@ typedef struct {
// (*) 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.*
// those must be shortend. All the other, more than 1700 mime types are unique on 4+36 bytes.
// those two must be shortend. All the other, more than 1700 mime types are unique on 4+36 bytes.
// regular files, 4th character never ':'
#define FSZ_FILETYPE_REG_TEXT "text" // main part of mime type
......@@ -225,19 +232,23 @@ typedef struct {
// flags
#define FSZ_IN_FLAG_HIST (1<<8) // indicates that previous file versions are kept
#define FSZ_IN_EALG_SHACBC (1<<9) // file encrypted with serpent SHA-256
#define FSZ_IN_EALG_AESCBC (1<<9) // file encrypted with AES-256-CBC
#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 */
// (***) logical sector address to data sector translation. These file sizes
// were calculated with 4096 sector size. That is configurable in the
// FSZ_SuperBlock if you think 11 sector reads is too much to access
// data at any arbitrary position in a Yotta magnitude file.
// if even that's not enough, you can use FSZ_SectorList (extents) to store file data.
// Sector directory supports 2^128 LSNs, except when FSZ_IN_FLAG_CHECKSUM is set on the
// file version, in which case LSNs are limited to "only" 2^96 bits.
// If even that's not enough, you can use FSZ_SectorList (extents) to store file data, which
// store contiguous runs of sectors with separated checksum fields.
// sector translation part of flags
#define FSZ_FLAG_TRANSLATION(x) ((x>>0)&0xFF)
#define FSZ_FLAG_TRANSLATION(x) (uint8_t)((x>>0)&0xFF)
/* data size < sector size - 1024 (3072 bytes)
FSZ_Inode.sec points to itself.
......@@ -398,7 +409,8 @@ 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
* is terminated with a transaction end block, which contains 16 bytes records. First record is
* 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. */
//sizeof = 16
......@@ -417,7 +429,7 @@ typedef struct {
/* Encryption can be applied to the disk and to individual files (if enchash is not zero):
* enckey=sha256(sha256(password+salt)-4 bytes xored with encrypt[])
* if EALG_SHACBC: serpentine sha, very fast, and pretty good cyclic block cipher, uses enckey as iv
* if EALG_SHACBC: XOR SHA blocks, very fast, and pretty good cyclic block cipher, uses enckey as iv
* if EALG_AESCBC: AES-256-CBC, key=enckey, iv=substr(enckey,enckey[0]&15,16)
* This way the encrypted disk/file doesn't need to be rewritten when password changes. Also you can
* re-encrypt the disk without changing the password. The enchash CRC is only used to avoid decryption with
......
......@@ -25,19 +25,19 @@
* @brief OS/Z system calls for inet service. Include with osZ.h
*/
#define SYS_accept (0x05)
#define SYS_bind (0x06)
#define SYS_connect (0x07)
#define SYS_getpeername (0x08)
#define SYS_getsockname (0x09)
#define SYS_getsockopt (0x0a)
#define SYS_connect (0x02)
#define SYS_recvfrom (0x03)
#define SYS_socket (0x04)
#define SYS_accept (0x06)
#define SYS_bind (0x07)
#define SYS_setsockopt (0x08)
#define SYS_sendmsg (0x09)
#define SYS_sendto (0x0a)
#define SYS_listen (0x0b)
#define SYS_recvfrom (0x0c)
#define SYS_recvmsg (0x0d)
#define SYS_sendmsg (0x0e)
#define SYS_sendto (0x0f)
#define SYS_setsockopt (0x10)
#define SYS_shutdown (0x11)
#define SYS_socket (0x12)
#define SYS_socketpair (0x13)
#define SYS_shutdown (0x0d)
#define SYS_getpeername (0x0e)
#define SYS_getsockopt (0x0f)
#define SYS_socketpair (0x10)
#define SYS_recvmsg (0x12)
#define SYS_getsockname (0x13)
......@@ -25,8 +25,8 @@
* @brief OS/Z system calls for init service. Include with osZ.h
*/
#define SYS_start (0x07)
#define SYS_restart (0x08)
#define SYS_start (0x09)
#define SYS_stop (0x09)
#define SYS_status (0x0a)
#define SYS_stop (0x0b)
......@@ -25,8 +25,8 @@
* @brief OS/Z system calls for syslog service. Include with osZ.h
*/
#define SYS_closelog (0x05)
#define SYS_openlog (0x06)
#define SYS_syslog (0x07)
#define SYS_openlog (0x03)
#define SYS_closelog (0x04)
#define SYS_syslog (0x06)
#define SYS_vsyslog (0x08)
......@@ -125,6 +125,7 @@ typedef struct {
uint32_t w;
uint32_t h;
uint32_t type;
void *gc;
void *data;
} win_t; // window handle
......
......@@ -25,22 +25,22 @@
* @brief OS/Z system calls for ui service. Include with osZ.h
*/
#define SYS_opendisplay (0x27)
#define SYS_createwindow (0x2c)
#define SYS_datapacket (0x2d)
#define SYS_destroywindow (0x2e)
#define SYS_eventmask (0x2f)
#define SYS_flush (0x30)
#define SYS_focuswindow (0x32)
#define SYS_mapwindow (0x33)
#define SYS_movewindow (0x34)
#define SYS_resizewindow (0x37)
#define SYS_setcursor (0x38)
#define SYS_setpixbuf2 (0x39)
#define SYS_setwindowtitle (0x3a)
#define SYS_unmapwindow (0x3c)
#define SYS_pointer (0x42)
#define SYS_devprogress (0x44)
#define SYS_keypress (0x4f)
#define SYS_keyrelease (0x50)
#define SYS_flush (0x0c)
#define SYS_devprogress (0x0f)
#define SYS_keyrelease (0x18)
#define SYS_setpixbuf2 (0x19)
#define SYS_setcursor (0x1b)
#define SYS_eventmask (0x22)
#define SYS_pointer (0x26)
#define SYS_resizewindow (0x2c)
#define SYS_opendisplay (0x2d)
#define SYS_unmapwindow (0x31)
#define SYS_mapwindow (0x36)
#define SYS_setwindowtitle (0x38)
#define SYS_createwindow (0x47)
#define SYS_destroywindow (0x48)
#define SYS_focuswindow (0x4f)
#define SYS_movewindow (0x50)
#define SYS_datapacket (0x52)
#define SYS_keypress (0x53)
......@@ -18,7 +18,7 @@ nrmqmax=1
quantum=10
// clock source configuration
clock=pit
clock=
// override time zone (in minutes, or "ask")
//tz=0
......
......@@ -4,6 +4,6 @@ VERSION = "0.0.1a"
HOME_URL = "https://gitlab.com/bztsrc/osz"
SUPPORT_URL = "https://gitlab.com/bztsrc/osz/issues"
BUG_REPORT_URL = "https://gitlab.com/bztsrc/osz/issues"
BUILD = "2018-11-16 15:19:32 UTC"
BUILD = "2018-11-22 22:22:40 UTC"
ARCH = "x86_64"
PLATFORM = "ibmpc"
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -9,7 +9,8 @@ SRCS += dbg.c dbgstr.c
#endif
OBJS = $(SRCS:.c=.o)
LIBS =
LDFLAGS = -nostdlib --build-id=none -x
# max-page-size is required for lld so that it won't mess up the program headers
LDFLAGS = -nostdlib --build-id=none -x -z max-page-size=16
ifeq ($(LD),$(ARCH)-elf-ld)
LDFLAGS += -nostartfiles -nolibc -nodefaultlibs
endif
......
......@@ -44,12 +44,12 @@
#define getcurrip() (((tcb_t*)0)->pc)
#define breakpoint asm volatile("brk #0")
#define vmm_switch(m) asm volatile("msr ttbr0_el1, %0;tlbi vmalle1;dsb ish;isb"::"r"(m|1))
#if DEBUG
#define vmm_enable(t) dbg_enable("Unimplemented",true)
//#if DEBUG
#define vmm_enable(t) kpanic("Unimplemented")
/*
#else
#define vmm_enable(t) asm volatile("1: wfe; b 1b")
#endif
/*
#define vmm_enable(t) asm volatile( \
"msr ttbr0_el1, %0;tlbi vmalle1;isb;" \
"msr elr_el1, %1;" \
......
......@@ -282,9 +282,9 @@ unsigned char *env_debug(unsigned char *s)
}
/** helper function to set time */
void env_asktime_setdigit(int8_t c, uint32_t i)
void env_asktime_setdigit(uint8_t c, uint32_t i)
{
char *p=(char*)&bootboot.datetime;
uint8_t *p=bootboot.datetime;
if(c>'9') c='0';
if(c<'0') c='9';
c-='0';
......@@ -313,16 +313,17 @@ void env_asktime_setdigit(int8_t c, uint32_t i)
/**
* Ask the user for the current time
* This is very early, before everything. We don't have user input drivers
* or memory management for example yet. Not even syslog_early() available
* or memory management yet for example. Not even syslog_early() available
*/
void env_asktime()
{
char t[32], *p;
uint8_t t[32], *p;
uint32_t i=0,e=0,cur=0;
uint16_t c;
int tz,t1,t2,t3,t4;
/* Clang miscompiles division if these are not 64 bit... */
uint64_t tz,t1,t2,t3,t4;
while(true) {
p=(char*)&bootboot.datetime;
p=bootboot.datetime;
tz=bootboot.timezone<0?-bootboot.timezone:bootboot.timezone;
t1=tz/600; t2=(tz/60)%10; t3=(tz%60)/10; t4=tz%10;
sprintf((char*)&t, "%1x%1x-%1x-%1x %1x:%1x:%1x GMT%c%1d%1d:%1d%1d", p[0], p[1], p[2], p[3], p[4], p[5], p[6],
......@@ -404,9 +405,10 @@ void env_asktime()
// down
case 336: env_asktime_setdigit(e<14?t[cur]-1:'0', e); break;
// numbers
default: env_asktime_setdigit(c+'0'-1, e); break;
default: env_asktime_setdigit(c+'0'-1, e); if(e<17) e++; break;
}
}
kprintf("\r \r");
kx=0;
#if DEBUG || defined(__rpi__)
platform_dbgputc('\r');
......
......@@ -541,15 +541,15 @@ void kprintf_scrollscr()
arg=(int)((unsigned char)msg[0]);
if((arg & 128) != 0) {
if((arg & 32) == 0 ) {
arg=((msg[0] & 0x1F)<<6)+(msg[1] & 0x3F);
arg=((msg[0] & 0x1F)<<6)|(msg[1] & 0x3F);
msg++;
} else
if((arg & 16) == 0 ) {
arg=((((msg[0] & 0xF)<<6)+(msg[1] & 0x3F))<<6)+(msg[2] & 0x3F);
arg=((((msg[0] & 0xF)<<12)|(msg[1] & 0x3F))<<6)|(msg[2] & 0x3F);
msg+=2;
} else
if((arg & 8) == 0 ) {
arg=((((((msg[0] & 0x7)<<6)+(msg[1] & 0x3F))<<6)+(msg[2] & 0x3F))<<6)+(msg[3] & 0x3F);
arg=((((((msg[0] & 0x7)<<18)|(msg[1] & 0x3F))<<12)|(msg[2] & 0x3F))<<6)|(msg[3] & 0x3F);
msg+=3;
} else
arg=0;
......@@ -761,15 +761,15 @@ void vkprintf(char *fmt, va_list args)
put: arg=(uint64_t)((unsigned char)fmt[0]);
if((arg & 128) != 0) {
if((arg & 32) == 0 ) {
arg=((fmt[0] & 0x1F)<<6)+(fmt[1] & 0x3F);
arg=((fmt[0] & 0x1F)<<6)|(fmt[1] & 0x3F);
fmt++;
} else
if((arg & 16) == 0 ) {
arg=((((fmt[0] & 0xF)<<6)+(fmt[1] & 0x3F))<<6)+(fmt[2] & 0x3F);
arg=((((fmt[0] & 0xF)<<12)|(fmt[1] & 0x3F))<<6)|(fmt[2] & 0x3F);
fmt+=2;
} else
if((arg & 8) == 0 ) {
arg=((((((fmt[0] & 0x7)<<6)+(fmt[1] & 0x3F))<<6)+(fmt[2] & 0x3F))<<6)+(fmt[3] & 0x3F);
arg=((((((fmt[0] & 0x7)<<18)|(fmt[1] & 0x3F))<<12)|(fmt[2] & 0x3F))<<6)|(fmt[3] & 0x3F);
fmt+=3;
} else
arg=0;
......
......@@ -37,10 +37,8 @@ PHDRS
SECTIONS
{
. = CORE_ADDRESS;
bootboot = .;
. += 4096;
environment = .;
. += 4096;
bootboot = .; . += 4096;
environment = .; . += 4096;
.text . + SIZEOF_HEADERS : AT(ADDR(.text) - . + SIZEOF_HEADERS) {
PROVIDE(__code = .);
KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) /* code */
......
......@@ -42,7 +42,7 @@ extern uint64_t *vmm_tmp;
extern uint64_t locks;
extern char *loadedelf;
/* Main scructure */
/* Main structure */
pmm_t pmm;
#if DEBUG
......
......@@ -54,7 +54,7 @@ char *sprintf_putascii(char *dst, int64_t c)
char *sprintf_putdec(char *dst, int64_t c)
{
int64_t i=18,s=c<0;
int64_t i=18,s=c<0,k=i<=cnt*2?0:i-cnt*2;
if(s) c*=-1;
if(c>99999999999999999LL)
c=99999999999999999LL;
......@@ -62,10 +62,10 @@ char *sprintf_putdec(char *dst, int64_t c)
do {
tmpstr[--i]='0'+(c%10);
c/=10;
} while(c!=0&&i>0);
} while(c!=0&&i>k);
if(s)
tmpstr[--i]='-';
if(cnt>0&&cnt<18) {
if(i>k&&cnt>0&&cnt<18) {
while(i>18-cnt) {
tmpstr[--i]=' ';
}
......@@ -75,14 +75,14 @@ char *sprintf_putdec(char *dst, int64_t c)
char *sprintf_puthex(char *dst, int64_t c)
{
int i=16;
int i=16,k=i<=cnt*2?0:i-cnt*2;
tmpstr[i]=0;
do {
char n=c & 0xf;
tmpstr[--i]=n<10?'0'+n:'A'+n-10;
c>>=4;
} while(c!=0&&i>0);
if(cnt>0&&cnt<=8) {
} while(c!=0&&i>k);
if(i>k&&cnt>0&&cnt<=8) {
while(i>16-cnt*2) {
tmpstr[--i]='0';
}
......
......@@ -29,8 +29,10 @@
#include <limits.h>
#include <syscall.h>
#include <errno.h>
#include "../../core/aarch64/tcb.h"
#include <tcb.h>
.global _init
.type _init, STT_FUNC
.global mq_call
.type mq_call, STT_FUNC
.global mq_send
......@@ -117,6 +119,8 @@
*/
mq_send:
mymq_send:
_init:
ret
/**
......
......@@ -28,7 +28,7 @@
#include <osZ.h>
#include "../libui/pixbuf.h"
private uint8_t ui_pixbuf_type;
private uint8_t ui_pixbuf_type=-1;
// maximum dimensions on this display
private uint32_t ui_pixbuf_width;
private uint32_t ui_pixbuf_height;
......@@ -212,7 +212,7 @@ public void ui_resizewindow(win_t *win, uint32_t w, uint32_t h)
}
/**
* Destroy window of off-screen pixel buffer
* Destroy window or off-screen pixel buffer
*/
public void ui_destroywindow(win_t *win)
{
......
......@@ -216,6 +216,7 @@ while true; do
rpi "Raspberry Pi 3+" \
2>&1 1>&3)
fi
clock=""
;;
2)
......
......@@ -29,7 +29,8 @@
* Without arguments prints out usage.
*
* It's a minimal implementation, has several limitations compared to the FS/Z spec.
* For example it supports only 24 entries per directory (only inlined entries in inode).
* For example it supports only 24 entries per directory (only inlined entries in inode),
* and it can't modify an encrypted image (only encrypts / decrypts entire images).
*/
#define HAS_AES 1
......@@ -129,18 +130,21 @@ static int direntcmp(const void *a, const void *b)
{
return strcasecmp((char *)((FSZ_DirEnt *)a)->name,(char *)((FSZ_DirEnt *)b)->name);
}
void printf_uuid(FSZ_Access *mem)
void printf_uuid(FSZ_Access *mem, int accessflags)
{
printf("%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x:",mem->Data1,mem->Data2,mem->Data3,
printf("%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x",mem->Data1,mem->Data2,mem->Data3,
mem->Data4[0],mem->Data4[1],mem->Data4[2],mem->Data4[3],mem->Data4[4],mem->Data4[5],mem->Data4[6]);
printf("%c%c%c%c%c%c%c",
mem->access&FSZ_READ?'r':'-',
mem->access&FSZ_WRITE?'w':'-',
mem->access&FSZ_EXEC?'e':'-',
mem->access&FSZ_APPEND?'a':'-',
mem->access&FSZ_DELETE?'d':'-',
mem->access&FSZ_SUID?'u':'-',
mem->access&FSZ_SGID?'s':'-');
if(!accessflags)
printf("%02x",mem->access);
else
printf(":%c%c%c%c%c%c%c",
mem->access&FSZ_READ?'r':'-',
mem->access&FSZ_WRITE?'w':'-',
mem->access&FSZ_EXEC?'e':'-',
mem->access&FSZ_APPEND?'a':'-',
mem->access&FSZ_DELETE?'d':'-',
mem->access&FSZ_SUID?'u':'-',
mem->access&FSZ_SGID?'s':'-');
}
/**
......@@ -838,6 +842,7 @@ void chcrypt(int argc, char **argv)
void add_superblock()
{
FSZ_SuperBlock *sb;
int i;
fs=realloc(fs,size+secsize);
if(fs==NULL) exit(4);
memset(fs+size,0,secsize);
......@@ -851,7 +856,9 @@ void add_superblock()
sb->physec=secsize/512; //logsec/mediasectorsize
sb->maxmounts=255;
sb->currmounts=0;
sb->createdate=ts;
sb->createdate=sb->lastchangedate=ts;
srand(time(NULL));
for(i=0;i<sizeof(sb->uuid);i++) sb->uuid[i]=rand();
memcpy(sb->magic2,FSZ_MAGIC,4);
size+=secsize;
}
......@@ -986,7 +993,7 @@ void add_file(char *name, char *datafile)
}
k=inode+1+l;
for(i=0;i<j;i++){
// no spare files (holes) for initrd, as core/fs.c maps the
// no sparse files (holes) for initrd, as core/fs.c maps the
// files on it as-is, and we will gzip the initrd anyway
if(initrd || memcmp(data+i*secsize,emptysec,secsize)) {
memcpy(ptr,&k,4);
......@@ -1161,7 +1168,7 @@ void checkcompilation()
// These numbers MUST match the ones in: etc/include/sys/fsZ.h
if( (uint64_t)(&sb.numsec) - (uint64_t)(&sb) != 528 ||
(uint64_t)(&sb.rootdirfid) - (uint64_t)(&sb) != 560 ||
(uint64_t)(&sb.owner) - (uint64_t)(&sb) != 744 ||
(uint64_t)(&sb.owner) - (uint64_t)(&sb) != 760 ||
(uint64_t)(&sb.magic2) - (uint64_t)(&sb) != 1016 ||
(uint64_t)(&in.filetype) - (uint64_t)(&in) != 8 ||
(uint64_t)(&in.version5) - (uint64_t)(&in) != 128 ||
......@@ -1887,8 +1894,9 @@ void dump(int argc, char **argv)
j=sb->createdate/1000000; printf("\tcreatedate: %ld %s",sb->createdate,ctime((time_t*)&j));
j=sb->lastmountdate/1000000; printf("\tlastmountdate: %ld %s",sb->lastmountdate,ctime((time_t*)&j));
j=sb->lastcheckdate/1000000; printf("\tlastcheckdate: %ld %s",sb->lastcheckdate,ctime((time_t*)&j));
j=sb->lastdefragdate/1000000; printf("\tlastdefragdate: %ld %s",sb->lastmountdate,ctime((time_t*)&j));
printf("\towner: "); printf_uuid((FSZ_Access*)&sb->owner); printf("\n");
j=sb->lastchangedate/1000000; printf("\tlastchangedate: %ld %s",sb->lastchangedate,ctime((time_t*)&j));
printf("\tuuid: "); printf_uuid((FSZ_Access*)&sb->uuid,0); printf(" (volume unique identifier)\n");
printf("\towner: "); printf_uuid((FSZ_Access*)&sb->owner,1); printf("\n");
printf("\tmagic2: %s\n",FSZ_MAGIC);
printf("\tchecksum: 0x%04x %s\n",sb->checksum,
sb->checksum==crc32_calc((char *)sb->magic,508)?"correct":"invalid");
......@@ -1903,7 +1911,7 @@ void dump(int argc, char **argv)
in->checksum==crc32_calc((char*)in->filetype,1016)?"correct":"invalid");
printf("\tfiletype: \"%c%c%c%c\", mimetype: \"%s\"\n",in->filetype[0],in->filetype[1],
in->filetype[2],in->filetype[3],in->mimetype);
printf("\tenchash: 0x%08x %s %s\n",in->enchash, in->enchash==0?"none":"encrypted",in->enchash==0?"":(
printf("\tenchash: 0x%08x %s %s\n",in->enchash, in->enchash==0?"not encrypted":"encrypted",in->enchash==0?"":(
in->flags&FSZ_IN_EALG_AESCBC?"(AES-256-CBC)":"(SHA-XOR-CBC)"
));
j=in->changedate/1000000; printf("\tchangedate: %ld %s",in->changedate,ctime((time_t*)&j));
......@@ -1911,11 +1919,10 @@ void dump(int argc, char **argv)
printf("\tnumblocks: %ld\n\tnumlinks: %ld\n",in->numblocks,in->numlinks);
printf("\tmetalabel: LSN %ld\n",in->metalabel);
printf("\tFSZ_Version {\n");
printf("\t\tsec: LSN %ld %s\n",in->sec,in->sec==0?"spare":(in->sec==i?"self-reference (inlined)":""));
printf("\t\tsec: LSN %ld %s\n",in->sec,in->sec==0?"sparse":(in->sec==i?"self-reference (inlined)":""));
printf("\t\tsize: %ld bytes\n",in->size);
j=in->modifydate/1000000; printf("\t\tmodifydate: %ld %s",in->modifydate,ctime((time_t*)&j));
printf("\t\tfilechksum: 0x%08x %s\n",in->filechksum,in->filechksum==0?"not implemented":"");
printf("\t\tflags: 0x%04x ",in->flags);
printf("\t\tflags: 0x%08lx ",in->flags);
switch(FSZ_FLAG_TRANSLATION(in->flags)){
case FSZ_IN_FLAG_INLINE: printf("FSZ_IN_FLAG_INLINE"); break;
case FSZ_IN_FLAG_DIRECT: printf("FSZ_IN_FLAG_DIRECT"); break;
......@@ -1930,7 +1937,7 @@ void dump(int argc, char **argv)
}
printf(" %s %s\n\t};\n",in->flags&FSZ_IN_FLAG_HIST?"FSZ_IN_FLAG_HIST":"",in->enchash?(
in->flags&FSZ_IN_EALG_AESCBC?"FSZ_IN_EALG_AESCBC":"FSZ_IN_EALG_SHACBC"):"");
printf("\towner: "); printf_uuid(&in->owner);
printf("\towner: "); printf_uuid(&in->owner,1);
printf("\n\tinlinedata: ");
if(FSZ_FLAG_TRANSLATION(in->flags)==FSZ_IN_FLAG_SDINLINE)
printf("sector directory\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment