Newer
Older
ubixos / src / sys / ubixfsv2 / superblock.h
#ifndef SUPERBLOCK_H
#define SUPERBLOCK_H

#include <sys/types.h>

typedef struct blockRun {
  int            allocationGroup  __attribute__ ((packed));
  unsigned short start            __attribute__ ((packed));
  unsigned short len              __attribute__ ((packed));
} inodeAddr;

// typedef unsigned long long  off_t;
typedef signed char  int8;
typedef unsigned char uInt8;
typedef unsigned int        uInt32;
typedef int                 int32;
typedef unsigned long long  uInt64;
typedef signed long long    int64;

typedef struct diskSuperBlock {
  char      name[32]      __attribute__ ((packed));
  int32     magic1        __attribute__ ((packed));
  int32     fsByteOrder   __attribute__ ((packed));
 
// blockSize on disk (4096 for UbixFS v2)
  uInt32    blockSize     __attribute__ ((packed));

// number of bits needed to shift a block number to get a byte address
  uInt32    blockShift    __attribute__ ((packed));
  
// numBlocks must be divisible by 8 for the getFreeBlock function to work
  off_t     numBlocks     __attribute__ ((packed));
  off_t     usedBlocks    __attribute__ ((packed));
  
  int32     inodeSize     __attribute__ ((packed));
  int32     magic2        __attribute__ ((packed));
  int32     blocksPerAG   __attribute__ ((packed));
  int32     AGShift       __attribute__ ((packed));
  int32     numAGs        __attribute__ ((packed));
  int32     lastUsedAG    __attribute__ ((packed));
 
// flags tells whether the FS is clean (0x434C454E) or dirty (0x44495954)
  int32     flags         __attribute__ ((packed));

// journal information
  blockRun  logBlocks     __attribute__ ((packed));
  off_t     logStart      __attribute__ ((packed));
  off_t     logEnd        __attribute__ ((packed));

  int32     magic3        __attribute__ ((packed));

// root dir of the SYS container
  inodeAddr rootDir       __attribute__ ((packed));

// indicies
  inodeAddr indicies      __attribute__ ((packed));

// container list
  inodeAddr containers    __attribute__ ((packed));

  int32     pad[92]        __attribute__ ((packed));
  
} diskSuperBlock;

#endif // !SUPERBLOCK_H