Newer
Older
ubixos-tools / include / superblock.h
#ifndef SUPERBLOCK_H
#define SUPERBLOCK_H

#include <sys/types.h>

#define UBIX_MAGIC1 0x0A0A0A0A;
#define UBIX_MAGIC2 0x0B0B0B0B;
#define UBIX_MAGIC3 0x0C0C0C0C;

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 ubixfs_superBlock{
  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));
  
  uInt32    inodeCount    __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
  struct 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));

  char     pad[372]        __attribute__ ((packed));
  
} ubixfs_superBlock;

#endif // !SUPERBLOCK_H