[klibc] [git patch] dmesg + fstype ocfs2

maximilian attems max at stro.at
Tue Aug 21 02:43:52 PDT 2007


hello hpa,

please pull
git pull git://brane.itp.tuwien.ac.at/~mattems/klibc.git maks

for those changes:

Kyle McMartin (1):
      klibc-utils: add dmesg

maximilian attems (2):
      klibc comment fix
      fstype: add ocfs2 support

with the following diffstat
 README                      |    2 
 usr/Kbuild                  |    2 
 usr/kinit/fstype/fstype.c   |   15 +++++++
 usr/kinit/fstype/ocfs2_fs.h |   90 ++++++++++++++++++++++++++++++++++++++++++++
 usr/utils/Kbuild            |    4 +
 usr/utils/dmesg.c           |   71 ++++++++++++++++++++++++++++++++++
 6 files changed, 181 insertions(+), 3 deletions(-)

thanks to latest utils i intend to allow dropping busybox
out of initramfs soon.
i've added on my fstype TODO md and udf

-- 
maks


commit 6789167791ff5364c2b85bb440b731b599774de8
Author: maximilian attems <max at stro.at>
Date:   Tue Aug 21 11:41:00 2007 +0200

    fstype: add ocfs2 support
    
    mkfs.ocfs2 /dev/mapper/nancy_vg1-ocfs2  > /dev/null
    mkfs.ocfs2 1.2.1
    
    ./usr/kinit/fstype/static/fstype /dev/mapper/nancy_vg1-ocfs2
    FSTYPE=ocfs2
    FSSIZE=0
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index 197a259..2f219e6 100644
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -32,6 +32,7 @@
 #include "iso9660_sb.h"
 #include "squashfs_fs.h"
 #include "gfs2_fs.h"
+#include "ocfs2_fs.h"
 
 /*
  * Slightly cleaned up version of jfs_superblock to
@@ -312,6 +313,19 @@ static int gfs2_image(const void *buf, unsigned long long *bytes)
 	return 0;
 }
 
+static int ocfs2_image(const void *buf, unsigned long long *bytes)
+{
+	const struct ocfs2_dinode *sb =
+		(const struct ocfs2_dinode *)buf;
+
+	if (!memcmp(sb->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE,
+			sizeof(OCFS2_SUPER_BLOCK_SIGNATURE) - 1)) {
+		*bytes = 0;
+		return 1;
+	}
+	return 0;
+}
+
 struct imagetype {
 	off_t block;
 	const char name[12];
@@ -340,6 +354,7 @@ static struct imagetype images[] = {
 	{1, "ext3", ext3_image},
 	{1, "ext2", ext2_image},
 	{1, "minix", minix_image},
+	{2, "ocfs2", ocfs2_image},
 	{8, "reiserfs", reiserfs_image},
 	{64, "reiserfs", reiserfs_image},
 	{64, "reiser4", reiser4_image},
diff --git a/usr/kinit/fstype/ocfs2_fs.h b/usr/kinit/fstype/ocfs2_fs.h
new file mode 100644
index 0000000..b71cb61
--- /dev/null
+++ b/usr/kinit/fstype/ocfs2_fs.h
@@ -0,0 +1,90 @@
+#ifndef _OCFS2_FS_H
+#define _OCFS2_FS_H
+
+/* Object signatures */
+#define OCFS2_SUPER_BLOCK_SIGNATURE     "OCFSV2"
+
+#define OCFS2_VOL_UUID_LEN              16
+#define OCFS2_MAX_VOL_LABEL_LEN         64
+
+/*
+ * On disk superblock for OCFS2
+ * Note that it is contained inside an ocfs2_dinode, so all offsets
+ * are relative to the start of ocfs2_dinode.id2.
+ */
+struct ocfs2_super_block {
+/*00*/	uint16_t s_major_rev_level;
+	uint16_t s_minor_rev_level;
+	uint16_t s_mnt_count;
+	int16_t s_max_mnt_count;
+	uint16_t s_state;			/* File system state */
+	uint16_t s_errors;			/* Behaviour when detecting errors */
+	uint32_t s_checkinterval;		/* Max time between checks */
+/*10*/	uint64_t s_lastcheck;		/* Time of last check */
+	uint32_t s_creator_os;		/* OS */
+	uint32_t s_feature_compat;		/* Compatible feature set */
+/*20*/	uint32_t s_feature_incompat;	/* Incompatible feature set */
+	uint32_t s_feature_ro_compat;	/* Readonly-compatible feature set */
+	uint64_t s_root_blkno;		/* Offset, in blocks, of root directory
+					   dinode */
+/*30*/	uint64_t s_system_dir_blkno;	/* Offset, in blocks, of system
+					   directory dinode */
+	uint32_t s_blocksize_bits;		/* Blocksize for this fs */
+	uint32_t s_clustersize_bits;	/* Clustersize for this fs */
+/*40*/	uint16_t s_max_slots;		/* Max number of simultaneous mounts
+					   before tunefs required */
+	uint16_t s_reserved1;
+	uint32_t s_reserved2;
+	uint64_t s_first_cluster_group;	/* Block offset of 1st cluster
+					 * group header */
+/*50*/	uint8_t  s_label[OCFS2_MAX_VOL_LABEL_LEN];	/* Label for mounting, etc. */
+/*90*/	uint8_t  s_uuid[OCFS2_VOL_UUID_LEN];	/* 128-bit uuid */
+/*A0*/
+} __attribute__ ((packed));
+
+/*
+ * On disk inode for OCFS2
+ */
+struct ocfs2_dinode {
+/*00*/	uint8_t i_signature[8];		/* Signature for validation */
+	uint32_t i_generation;		/* Generation number */
+	uint16_t i_suballoc_slot;		/* Slot suballocator this inode
+					   belongs to */
+	int16_t i_suballoc_bit;		/* Bit offset in suballocator
+					   block group */
+/*10*/	uint32_t i_reserved0;
+	uint32_t i_clusters;		/* Cluster count */
+	uint32_t i_uid;			/* Owner UID */
+	uint32_t i_gid;			/* Owning GID */
+/*20*/	uint64_t i_size;			/* Size in bytes */
+	uint16_t i_mode;			/* File mode */
+	uint16_t i_links_count;		/* Links count */
+	uint32_t i_flags;			/* File flags */
+/*30*/	uint64_t i_atime;			/* Access time */
+	uint64_t i_ctime;			/* Creation time */
+/*40*/	uint64_t i_mtime;			/* Modification time */
+	uint64_t i_dtime;			/* Deletion time */
+/*50*/	uint64_t i_blkno;			/* Offset on disk, in blocks */
+	uint64_t i_last_eb_blk;		/* Pointer to last extent
+					   block */
+/*60*/	uint32_t i_fs_generation;		/* Generation per fs-instance */
+	uint32_t i_atime_nsec;
+	uint32_t i_ctime_nsec;
+	uint32_t i_mtime_nsec;
+	uint32_t i_attr;
+	uint16_t i_orphaned_slot;		/* Only valid when OCFS2_ORPHANED_FL
+					   was set in i_flags */
+	uint16_t i_reserved1;
+/*70*/	uint64_t i_reserved2[8];
+/*B8*/	uint64_t i_pad1;
+	uint64_t i_rdev;	/* Device number */
+	uint32_t i_used;	/* Bits (ie, clusters) used  */
+	uint32_t i_total;	/* Total bits (clusters)
+					   available */
+	uint32_t ij_flags;	/* Mounted, version, etc. */
+	uint32_t ij_pad;
+/*C0*/	struct ocfs2_super_block	i_super;
+/* Actual on-disk size is one block */
+} __attribute__ ((packed));
+
+#endif  /* _OCFS2_FS_H */

commit 9c5a7acda064daa7482148b5a45ee3b7ed39356c
Author: Kyle McMartin <kyle at parisc-linux.org>
Date:   Mon Aug 20 19:57:50 2007 +0200

    klibc-utils: add dmesg
    
    read and/or clear kernel message ring buffer
    
    Signed-off-by: Kyle McMartin <kyle at parisc-linux.org>
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/utils/Kbuild b/usr/utils/Kbuild
index 4ce17be..09157a8 100644
--- a/usr/utils/Kbuild
+++ b/usr/utils/Kbuild
@@ -4,7 +4,7 @@
 
 progs := chroot dd mkdir mkfifo mknod mount pivot_root umount
 progs += true false sleep ln nuke minips cat
-progs += insmod uname halt kill readlink cpio sync
+progs += insmod uname halt kill readlink cpio sync dmesg
 
 static-y := $(addprefix static/, $(progs))
 shared-y := $(addprefix shared/, $(progs))
@@ -14,6 +14,8 @@ static/chroot-y     := chroot.o
 shared/chroot-y     := chroot.o
 static/dd-y         := dd.o
 shared/dd-y         := dd.o
+static/dmesg-y      := dmesg.o
+shared/dmesg-y      := dmesg.o
 static/mkdir-y      := mkdir.o file_mode.o
 shared/mkdir-y      := mkdir.o file_mode.o
 static/mkfifo-y     := mkfifo.o file_mode.o
diff --git a/usr/utils/dmesg.c b/usr/utils/dmesg.c
new file mode 100644
index 0000000..5369c03
--- /dev/null
+++ b/usr/utils/dmesg.c
@@ -0,0 +1,71 @@
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+static void usage(char *name)
+{
+	fprintf(stderr, "usage: %s [-c]\n", name);
+}
+
+int main(int argc, char *argv[])
+{
+	char *buf = NULL;
+	int bufsz = 0;
+	int cmd = 3;	/* Read all messages remaining in the ring buffer */
+	int len = 0;
+	int opt;
+	int i = 0;
+
+	while ((opt = getopt(argc, argv, "c")) != -1) {
+		switch(opt) {
+		/* Read and clear all messages remaining in the ring buffer */
+		case 'c':
+			cmd = 4;
+			break;
+		case '?':
+		default:
+			usage(argv[0]);
+			exit(1);
+		}
+	}
+
+	if (!bufsz) {
+		len = klogctl(10, NULL, 0);	/* Return size of the log buffer */
+		if (len > 0)
+			bufsz = len;
+	}
+
+	if (bufsz) {
+		int sz = bufsz + 8;
+
+		buf = (char *)malloc(sz);
+		len = klogctl(cmd, buf, sz);
+	}
+
+	if (len < 0) {
+		perror("klogctl");
+		exit(1);
+	}
+
+	while (buf[i] && i < len)
+		switch (buf[i]) {
+		case '<':
+			if (i == 0 || buf[i-1] == '\n')	
+				i++;
+		case '0' ... '9':
+			if (i > 0 && buf[i-1] == '<')	
+				i++;
+		case '>':
+			if (i > 0 && isdigit(buf[i-1]))
+				i++;
+		default:
+			putchar(buf[i++]);
+		}
+
+	if (buf[i-1] != '\n')
+		putchar('\n');
+
+	return 0;
+}

commit 20f1bff2bc8a7e120f13f275ceed90b6704babbb
Author: maximilian attems <max at stro.at>
Date:   Wed Aug 15 20:47:00 2007 +0200

    klibc comment fix
    
    * nowadays git is quite feature full, no need of a Cogito ref
    * wrong capitalization
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/README b/README
index 41836d0..30e4b59 100644
--- a/README
+++ b/README
@@ -16,7 +16,7 @@ repository can be viewed on the web at:
 
 	http://www.kernel.org/git/?p=libs/klibc/klibc.git;a=summary
 
-To clone the klibc repository using Cogito:
+To clone the klibc repository using git:
 
 	git clone git://git.kernel.org/pub/scm/libs/klibc/klibc.git <workdir>
 
diff --git a/usr/Kbuild b/usr/Kbuild
index f874f51..890811c 100644
--- a/usr/Kbuild
+++ b/usr/Kbuild
@@ -12,7 +12,7 @@ subdir-      := $(include-subdir) $(klibc-subdir) $(usr-subdirs)
 usr-subdirs  := $(addprefix _usr_,$(usr-subdirs))
 klibc-subdir := $(addprefix _usr_,$(klibc-subdir))
 
-# Klibc binaries
+# klibc binaries
 ifdef CONFIG_KLIBC
 
 # .initramfs_data.cpio.gz.d is used to identify all files included



More information about the klibc mailing list