Initial commit

This commit is contained in:
Bahadir Balban
2008-01-13 13:53:52 +00:00
commit e2b791a3d8
789 changed files with 95825 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
#include <stdio.h>
#include <block.h>
#include <l4/lib/math.h>
#include <l4/macros.h>
#include <l4/types.h>
#include INC_GLUE(memory.h)
/*
* Romfs superblock descriptor:
*
* All words are Big-Endian.
*
* Word 0: | - | r | o | m |
* Word 1: | 1 | f | s | - |
* Word 2: | Size | The number of bytes in this fs.
* Word 3: | Checksum | The checksum of first 512 bytes.
* Word 4: | Volume Name | The name of volume, padded to 16-byte boundary.
* Rest: | File Headers | The rest of the data.
*/
struct romfs_superblock {
u32 word0;
u32 word1;
u32 size;
u32 checksum;
char name[0];
};
struct romfs_inode {
unsigned long mdata_size; /* Size of metadata */
unsigned long data_offset; /* Offset of data from start of fs */
};
static u32
romfs_checksum(void *data)
{
u32 sum = 0;
u32 *ptr = data;
size >>= 2;
while (size > 0) {
sum += be32_to_cpu(*ptr++);
size--;
}
return sum;
}
int romfs_fill_super(struct superblock *sb)
{
char buf[PAGE_SIZE];
struct romfs_superblock *romfs_sb = (struct romfs_superblock *)buf;
unsigned long vroot_offset;
struct vnode *vroot;
/* Read first page from block device */
bdev_readpage(0, buf);
/* Check superblock sanity */
if (strcmp(be32_to_cpu(romfs_sb->word0), ROMFS_SB_WORD0)) {
printf("Bad magic word 0\n");
}
if (strcmp(be32_to_cpu(romfs_sb->word1), ROMFS_SB_WORD1)) {
printf("Bad magic word 1\n");
}
if (romfs_checksum(romfs_sb, min(romfs_sb->size, PAGE_SIZE))) {
printf("Bad checksum.\n");
}
/* Copy some params to generic superblock */
sb->size = be32_to_cpu(romfs_sb->size);
sb->magic = ROMFS_MAGIC;
sb->ops = romfs_ops;
/* Offset of first vnode, which is the root vnode */
vroot_offset = align_up(strnlen(romfs_sb->name, ROMFS_MAXNAME) + 1, 16);
if (!(vroot = romfs_read_vnode(s, vroot_offset))) {
printf("Error, could not get root inode.\n");
}
/* Get the dirent for this vnode */
if (!(sb->root = new_dentry(vroot))) {
printf("Error: Could not get new dentry for root vnode.\n");
}
}

View File

@@ -0,0 +1,43 @@
#ifndef __ROMFS_H__
#define __ROMFS_H__
#define ROMFS_MAGIC 0x7275
#define ROMFS_FTYPE_MSK 0xF /* File mask */
#define ROMFS_FTYPE_HRD 0 /* Hard link */
#define ROMFS_FTYPE_DIR 1 /* Directory */
#define ROMFS_FTYPE_REG 2 /* Regular file */
#define ROMFS_FTYPE_SYM 3 /* Symbolic link */
#define ROMFS_FTYPE_BLK 4 /* Block device */
#define ROMFS_FTYPE_CHR 5 /* Char device */
#define ROMFS_FTYPE_SCK 6 /* Socket */
#define ROMFS_FTYPE_FIF 7 /* FIFO */
#define ROMFS_FTYPE_EXE 8 /* Executable */
#define ROMFS_NAME_ALIGN 16 /* Alignment size of names */
#define ROMFS_SB_WORD0 "-rom"
#define ROMFS_SB_WORD1 "1fs-"
/*
* Romfs superblock descriptor:
*
* All words are Big-Endian.
*
* Word 0: | - | r | o | m |
* Word 1: | 1 | f | s | - |
* Word 2: | Size | The number of bytes in this fs.
* Word 3: | Checksum | The checksum of first 512 bytes.
* Word 4: | Volume Name | The name of volume, padded to 16-byte boundary.
* Rest: | File Headers | The rest of the data.
*/
struct romfs_superblock {
u32 word0;
u32 word1;
u32 size;
u32 checksum;
char name[0];
};
#endif /* __ROMFS_H__ */

View File

@@ -0,0 +1,61 @@
#ifndef __LINUX_ROMFS_FS_H
#define __LINUX_ROMFS_FS_H
/* The basic structures of the romfs filesystem */
#define ROMBSIZE BLOCK_SIZE
#define ROMBSBITS BLOCK_SIZE_BITS
#define ROMBMASK (ROMBSIZE-1)
#define ROMFS_MAGIC 0x7275
#define ROMFS_MAXFN 128
#define __mkw(h,l) (((h)&0x00ff)<< 8|((l)&0x00ff))
#define __mkl(h,l) (((h)&0xffff)<<16|((l)&0xffff))
#define __mk4(a,b,c,d) cpu_to_be32(__mkl(__mkw(a,b),__mkw(c,d)))
#define ROMSB_WORD0 __mk4('-','r','o','m')
#define ROMSB_WORD1 __mk4('1','f','s','-')
/* On-disk "super block" */
struct romfs_super_block {
__be32 word0;
__be32 word1;
__be32 size;
__be32 checksum;
char name[0]; /* volume name */
};
/* On disk inode */
struct romfs_inode {
__be32 next; /* low 4 bits see ROMFH_ */
__be32 spec;
__be32 size;
__be32 checksum;
char name[0];
};
#define ROMFH_TYPE 7
#define ROMFH_HRD 0
#define ROMFH_DIR 1
#define ROMFH_REG 2
#define ROMFH_SYM 3
#define ROMFH_BLK 4
#define ROMFH_CHR 5
#define ROMFH_SCK 6
#define ROMFH_FIF 7
#define ROMFH_EXEC 8
/* Alignment */
#define ROMFH_SIZE 16
#define ROMFH_PAD (ROMFH_SIZE-1)
#define ROMFH_MASK (~ROMFH_PAD)
#ifdef __KERNEL__
/* Not much now */
#endif /* __KERNEL__ */
#endif