UbixOS V2 2.0

Data Structures | Macros | Typedefs | Functions
ufs.h File Reference
`#include <sys/types.h>`
`#include <sys/device.h>`
Include dependency graph for ufs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
struct | csum
struct | csum_total
struct | dirent
struct | fs
struct | ufs1_dinode
struct | ufs2_dinode

## Macros
#define | blkoff(fs, loc) ((loc) & (fs)->fs_qbmask)
#define | cgbase(fs, c) (((ufs2_daddr_t)(fs)->fs_fpg) * (c))
#define | cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */
#define | cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */
#define | cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */
#define | cgstart(fs, c) ((fs)->fs_magic == FS_UFS2_MAGIC ? cgbase(fs, c) : (cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask))))
#define | cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */
#define | dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb)
#define | DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
#define | DEV_BSIZE (1<<DEV_BSHIFT)
#define | DT_DIR 4
#define | DT_REG 8
#define | fragroundup(fs, size) (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask)
#define | FS_UFS1_MAGIC 0x011954 /* UFS1 fast filesystem magic number */
#define | FS_UFS2_MAGIC 0x19540119 /* UFS2 fast filesystem magic number */
#define | fsbtodb(fs, b) ((daddr_t)(b) << (fs)->fs_fsbtodb)
#define | FSMAXSNAP 20
#define | ino_to_cg(fs, x) ((x) / (fs)->fs_ipg)
#define | ino_to_fsba(fs, x) ((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, x)) + (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs))))))
#define | ino_to_fsbo(fs, x) ((x) % INOPB(fs))
#define | lblkno(fs, loc) ((loc) >> (fs)->fs_bshift)
#define | MAXBSIZE 65536
#define | MAXMNTLEN 468
#define | MAXNAMLEN 255
#define | MAXVOLLEN 32
#define | NDADDR 12 /* Direct addresses in inode. */
#define | NIADDR 3 /* Indirect addresses in inode. */
#define | NINDIR(fs) ((fs)->fs_nindir)
#define | NOCSPTRS ((128 / sizeof(void *)) - 4)
#define | NXADDR 2 /* External addresses in inode. */
#define | ROOTINO ((ino_t)2)
#define | sblksize(fs, size, lbn) (((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) ? (fs)->fs_bsize : (fragroundup(fs, blkoff(fs, (size)))))
#define | SBLOCK_FLOPPY 0
#define | SBLOCK_PIGGY 262144
#define | SBLOCK_UFS1 8192
#define | SBLOCK_UFS2 65536
#define | SBLOCKSEARCH { SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 }
#define | SBLOCKSIZE 8192

## Typedefs
typedef int32_t | ufs1_daddr_t
typedef int64_t | ufs2_daddr_t
typedef int64_t | ufs_lbn_t
typedef int64_t | ufs_time_t

## Functions
int | ufs_init ()
int | ufs_initialize ()

## Macro Definition Documentation

## ◆ blkoff

#define blkoff | ( |  | fs,
|  |  | loc
| ) |  | ((loc) & (fs)->fs_qbmask)

Definition at line 80 of file ufs.h.

## ◆ cgbase

#define cgbase | ( |  | fs,
|  |  | c
| ) |  | (((ufs2_daddr_t)(fs)->fs_fpg) * (c))

Definition at line 60 of file ufs.h.

## ◆ cgdmin

#define cgdmin | ( |  | fs,
|  |  | c
| ) |  | (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */

Definition at line 61 of file ufs.h.

## ◆ cgimin

#define cgimin | ( |  | fs,
|  |  | c
| ) |  | (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */

Definition at line 62 of file ufs.h.

## ◆ cgsblock

#define cgsblock | ( |  | fs,
|  |  | c
| ) |  | (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */

Definition at line 63 of file ufs.h.

## ◆ cgstart

#define cgstart | ( |  | fs,
|  |  | c
| ) |  | ((fs)->fs_magic == FS_UFS2_MAGIC ? cgbase(fs, c) : (cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask))))

Definition at line 65 of file ufs.h.

## ◆ cgtod

#define cgtod | ( |  | fs,
|  |  | c
| ) |  | (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */

Definition at line 64 of file ufs.h.

## ◆ dbtofsb

#define dbtofsb | ( |  | fs,
|  |  | b
| ) |  | ((b) >> (fs)->fs_fsbtodb)

Definition at line 68 of file ufs.h.

## ◆ DEV_BSHIFT

#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */

Definition at line 39 of file ufs.h.

## ◆ DEV_BSIZE

#define DEV_BSIZE (1<<DEV_BSHIFT)

Definition at line 40 of file ufs.h.

## ◆ DT_DIR

#define DT_DIR 4

Definition at line 38 of file ufs.h.

## ◆ DT_REG

#define DT_REG 8

Definition at line 35 of file ufs.h.

## ◆ fragroundup

#define fragroundup | ( |  | fs,
|  |  | size
| ) |  | (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask)

Definition at line 82 of file ufs.h.

## ◆ FS_UFS1_MAGIC

#define FS_UFS1_MAGIC 0x011954 /* UFS1 fast filesystem magic number */

Definition at line 47 of file ufs.h.

## ◆ FS_UFS2_MAGIC

#define FS_UFS2_MAGIC 0x19540119 /* UFS2 fast filesystem magic number */

Definition at line 48 of file ufs.h.

## ◆ fsbtodb

#define fsbtodb | ( |  | fs,
|  |  | b
| ) |  | ((daddr_t)(b) << (fs)->fs_fsbtodb)

Definition at line 67 of file ufs.h.

## ◆ FSMAXSNAP

#define FSMAXSNAP 20

Definition at line 52 of file ufs.h.

## ◆ ino_to_cg

#define ino_to_cg | ( |  | fs,
|  |  | x
| ) |  | ((x) / (fs)->fs_ipg)

Definition at line 76 of file ufs.h.

## ◆ ino_to_fsba

#define ino_to_fsba | ( |  | fs,
|  |  | x
| ) |  | ((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, x)) + (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs))))))

Definition at line 77 of file ufs.h.

## ◆ ino_to_fsbo

#define ino_to_fsbo | ( |  | fs,
|  |  | x
| ) |  | ((x) % INOPB(fs))

Definition at line 78 of file ufs.h.

## ◆ lblkno

#define lblkno | ( |  | fs,
|  |  | loc
| ) |  | ((loc) >> (fs)->fs_bshift)

Definition at line 81 of file ufs.h.

## ◆ MAXBSIZE

#define MAXBSIZE 65536

Definition at line 53 of file ufs.h.

## ◆ MAXMNTLEN

#define MAXMNTLEN 468

Definition at line 49 of file ufs.h.

## ◆ MAXNAMLEN

#define MAXNAMLEN 255

Definition at line 36 of file ufs.h.

## ◆ MAXVOLLEN

#define MAXVOLLEN 32

Definition at line 50 of file ufs.h.

## ◆ NDADDR

#define NDADDR 12 /* Direct addresses in inode. */

Definition at line 101 of file ufs.h.

## ◆ NIADDR

#define NIADDR 3 /* Indirect addresses in inode. */

Definition at line 102 of file ufs.h.

## ◆ NINDIR

#define NINDIR | ( |  | fs | ) | ((fs)->fs_nindir)

Definition at line 54 of file ufs.h.

## ◆ NOCSPTRS

#define NOCSPTRS ((128 / sizeof(void *)) - 4)

Definition at line 51 of file ufs.h.

## ◆ NXADDR

#define NXADDR 2 /* External addresses in inode. */

Definition at line 100 of file ufs.h.

## ◆ ROOTINO

#define ROOTINO ((ino_t)2)

Definition at line 37 of file ufs.h.

## ◆ sblksize

#define sblksize | ( |  | fs,
|  |  | size,
|  |  | lbn
| ) |  | (((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) ? (fs)->fs_bsize : (fragroundup(fs, blkoff(fs, (size)))))

Definition at line 84 of file ufs.h.

## ◆ SBLOCK_FLOPPY

#define SBLOCK_FLOPPY 0

Definition at line 41 of file ufs.h.

## ◆ SBLOCK_PIGGY

#define SBLOCK_PIGGY 262144

Definition at line 44 of file ufs.h.

## ◆ SBLOCK_UFS1

#define SBLOCK_UFS1 8192

Definition at line 42 of file ufs.h.

## ◆ SBLOCK_UFS2

#define SBLOCK_UFS2 65536

Definition at line 43 of file ufs.h.

## ◆ SBLOCKSEARCH

#define SBLOCKSEARCH { SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 }

Definition at line 46 of file ufs.h.

## ◆ SBLOCKSIZE

#define SBLOCKSIZE 8192

Definition at line 45 of file ufs.h.

## Typedef Documentation

## ◆ ufs1_daddr_t

typedef int32_t ufs1_daddr_t

Definition at line 86 of file ufs.h.

## ◆ ufs2_daddr_t

typedef int64_t ufs2_daddr_t

Definition at line 87 of file ufs.h.

## ◆ ufs_lbn_t

typedef int64_t ufs_lbn_t

Definition at line 88 of file ufs.h.

## ◆ ufs_time_t

typedef int64_t ufs_time_t

Definition at line 89 of file ufs.h.

## Function Documentation

## ◆ ufs_init()

int ufs_init | ( |  | ) |

Definition at line 313 of file ufs.c.

## ◆ ufs_initialize()

int ufs_initialize | ( |  | ) |