[klibc] [git patch] fstype support + minor stuff
maximilian attems
max at stro.at
Wed Aug 15 08:26:51 PDT 2007
hello hpa,
rebased my branch, please pull latest
git pull git://brane.itp.tuwien.ac.at/~mattems/klibc.git maks
for the following shortlog
maximilian attems (6):
fstype: add squashfs v3 support
reiser4_fs.h: add attribute packed to reiser4_master_sb
fstype: add ext4 support
.gitignore: add subdir specific entries
usr/klibc/Kbuild: beautify klibc build
fstype: add gfs2 support
the diffstat is
.gitignore | 2
usr/dash/.gitignore | 17 ++++++
usr/gzip/.gitignore | 3 +
usr/kinit/.gitignore | 3 +
usr/kinit/fstype/ext3_fs.h | 4 +
usr/kinit/fstype/fstype.c | 51 ++++++++++++++++++
usr/kinit/fstype/gfs2_fs.h | 56 ++++++++++++++++++++
usr/kinit/fstype/reiser4_fs.h | 2
usr/kinit/fstype/squashfs_fs.h | 41 ++++++++++++++
usr/klibc/.gitignore | 9 +++
usr/klibc/Kbuild | 109 ++++++++++++++++++++-------------------
usr/klibc/socketcalls/.gitignore | 3 +
usr/klibc/syscalls/.gitignore | 6 ++
13 files changed, 254 insertions(+), 52 deletions(-)
leaves currently only ocfs2 on my fstype todo list.
--
maks
commit 8094659e23e6c25293868b58c485b7b21cf314a1
Author: maximilian attems <max at stro.at>
Date: Wed Aug 15 13:28:32 2007 +0200
fstype: add gfs2 support
./gfs2_mkfs -t mycluster:mygfs -p lock_dlm -j 2 /dev/mapper/nancy_vg1-gfs2
./usr/kinit/fstype/static/fstype /dev/mapper/nancy_vg1-gfs2
FSTYPE=gfs2
FSSIZE=0
set the fssize to zero for now.
Signed-off-by: maximilian attems <max at stro.at>
diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index 3465676..197a259 100644
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -31,6 +31,7 @@
#include "lvm2_sb.h"
#include "iso9660_sb.h"
#include "squashfs_fs.h"
+#include "gfs2_fs.h"
/*
* Slightly cleaned up version of jfs_superblock to
@@ -297,6 +298,20 @@ static int squashfs_image(const void *buf, unsigned long long *blocks)
return 0;
}
+static int gfs2_image(const void *buf, unsigned long long *bytes)
+{
+ const struct gfs2_sb *sb =
+ (const struct gfs2_sb *)buf;
+
+ if (__be32_to_cpu(sb->sb_header.mh_magic) == GFS2_MAGIC
+ && (__be32_to_cpu(sb->sb_fs_format) == GFS2_FORMAT_FS
+ || __be32_to_cpu(sb->sb_fs_format) == GFS2_FORMAT_MULTI)) {
+ *bytes = 0; /* cpu_to_be32(sb->sb_bsize) * ?; */
+ return 1;
+ }
+ return 0;
+}
+
struct imagetype {
off_t block;
const char name[12];
@@ -328,6 +343,7 @@ static struct imagetype images[] = {
{8, "reiserfs", reiserfs_image},
{64, "reiserfs", reiserfs_image},
{64, "reiser4", reiser4_image},
+ {64, "gfs2", gfs2_image},
{32, "jfs", jfs_image},
{32, "iso9660", iso_image},
{0, "luks", luks_image},
diff --git a/usr/kinit/fstype/gfs2_fs.h b/usr/kinit/fstype/gfs2_fs.h
new file mode 100644
index 0000000..028e0c9
--- /dev/null
+++ b/usr/kinit/fstype/gfs2_fs.h
@@ -0,0 +1,56 @@
+#ifndef __GFS2_FS_H
+#define __GFS2_FS_H
+
+#define GFS2_MAGIC 0x01161970
+#define GFS2_FORMAT_FS 1801
+#define GFS2_FORMAT_MULTI 1900
+
+
+/*
+ * An on-disk inode number
+ */
+struct gfs2_inum {
+ __be64 no_formal_ino;
+ __be64 no_addr;
+};
+
+/*
+ * Generic metadata head structure
+ * Every inplace buffer logged in the journal must start with this.
+ */
+struct gfs2_meta_header {
+ uint32_t mh_magic;
+ uint32_t mh_type;
+ uint64_t __pad0; /* Was generation number in gfs1 */
+ uint32_t mh_format;
+ uint32_t __pad1; /* Was incarnation number in gfs1 */
+};
+
+/* Requirement: GFS2_LOCKNAME_LEN % 8 == 0
+ * Includes: the fencing zero at the end */
+#define GFS2_LOCKNAME_LEN 64
+
+/*
+ * super-block structure
+ */
+struct gfs2_sb {
+ struct gfs2_meta_header sb_header;
+
+ uint32_t sb_fs_format;
+ uint32_t sb_multihost_format;
+ uint32_t __pad0; /* Was superblock flags in gfs1 */
+
+ uint32_t sb_bsize;
+ uint32_t sb_bsize_shift;
+ uint32_t __pad1; /* Was journal segment size in gfs1 */
+
+ struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */
+ struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */
+ struct gfs2_inum sb_root_dir;
+
+ char sb_lockproto[GFS2_LOCKNAME_LEN];
+ char sb_locktable[GFS2_LOCKNAME_LEN];
+ /* In gfs1, quota and license dinodes followed */
+} __attribute__ ((__packed__));
+
+#endif /* __GFS2_FS_H */
commit 98154fb9583ad099f4b1f82e717478001e2e90b1
Author: maximilian attems <max at stro.at>
Date: Wed Aug 15 11:18:18 2007 +0200
usr/klibc/Kbuild: beautify klibc build
alphanumerically sort the klib-y entries.
should make it easier to add specific functions
in specific trees without conflicting against each other.
checked before and after patch with:
max at nancy:~/src/klibc$ find usr/klibc/ -name *.o | wc -l
375
max at nancy:~/src/klibc$ find usr/klibc/ -name *.o | wc -l
375
Signed-off-by: maximilian attems <max at stro.at>
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index ad72116..512f841 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -5,57 +5,64 @@
# Tell that we are building klibc
export klibc-build := y
-klib-y := vsnprintf.o snprintf.o vsprintf.o sprintf.o \
- asprintf.o vasprintf.o \
- vsscanf.o sscanf.o ctypes.o \
- strntoumax.o strntoimax.o \
- atoi.o atol.o atoll.o \
- strtol.o strtoll.o strtoul.o strtoull.o \
- strtoimax.o strtoumax.o \
- globals.o exit.o atexit.o onexit.o \
- execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o \
- fork.o vfork.o wait.o wait3.o waitpid.o system.o \
- setpgrp.o getpgrp.o daemon.o \
- printf.o vprintf.o fprintf.o vfprintf.o perror.o \
- statfs.o fstatfs.o umount.o \
- creat.o open.o openat.o open_cloexec.o \
- fopen.o fread.o fread2.o fgetc.o fgets.o \
- fwrite.o fwrite2.o fputc.o fputs.o puts.o putchar.o \
- sleep.o usleep.o strtotimespec.o strtotimeval.o \
- raise.o abort.o assert.o alarm.o pause.o \
- __signal.o sysv_signal.o bsd_signal.o siglist.o sigabbrev.o \
- siglongjmp.o \
- sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
- pselect.o ppoll.o \
- brk.o sbrk.o malloc.o realloc.o calloc.o \
- mmap.o shm_open.o shm_unlink.o \
- memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
- memmove.o memchr.o memrchr.o \
- strcasecmp.o strncasecmp.o strndup.o strerror.o strsignal.o \
- strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o strnlen.o \
- strncat.o strlcpy.o strlcat.o \
- strstr.o strncmp.o strncpy.o strrchr.o \
- strxspn.o strspn.o strcspn.o strpbrk.o strsep.o strtok.o \
- fnmatch.o \
- gethostname.o getdomainname.o getcwd.o \
- seteuid.o setegid.o \
- getenv.o setenv.o putenv.o __put_env.o unsetenv.o \
- clearenv.o nullenv.o \
- getopt.o getopt_long.o readdir.o remove.o \
- syslog.o closelog.o pty.o getpt.o isatty.o reboot.o \
- time.o utime.o llseek.o nice.o getpriority.o \
- qsort.o bsearch.o \
- lrand48.o jrand48.o mrand48.o nrand48.o srand48.o seed48.o \
- inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \
- inet/inet_ntop.o inet/inet_pton.o inet/bindresvport.o \
- send.o recv.o \
- ctype/isalnum.o ctype/isalpha.o ctype/isascii.o \
- ctype/isblank.o ctype/iscntrl.o ctype/isdigit.o \
- ctype/isgraph.o ctype/islower.o ctype/isprint.o \
- ctype/ispunct.o ctype/isspace.o ctype/isupper.o \
- ctype/isxdigit.o ctype/tolower.o ctype/toupper.o \
- userdb/getgrgid.o userdb/getgrnam.o userdb/getpwnam.o \
- userdb/getpwuid.o userdb/root_group.o userdb/root_user.o
+klib-y := abort.o alarm.o asprintf.o assert.o \
+ atexit.o atoi.o atoll.o atol.o brk.o \
+ bsd_signal.o bsearch.o calloc.o clearenv.o \
+ closelog.o creat.o ctype/isalnum.o \
+ ctype/isalpha.o ctype/isascii.o \
+ ctype/isblank.o ctype/iscntrl.o \
+ ctype/isdigit.o ctype/isgraph.o \
+ ctype/islower.o ctype/isprint.o \
+ ctype/ispunct.o ctype/isspace.o \
+ ctype/isupper.o ctype/isxdigit.o \
+ ctypes.o ctype/tolower.o ctype/toupper.o \
+ daemon.o execle.o execl.o execlpe.o \
+ execlp.o execv.o execvpe.o execvp.o \
+ exit.o fgetc.o fgets.o fnmatch.o fopen.o \
+ fork.o fprintf.o fputc.o fputs.o \
+ fread2.o fread.o fstatfs.o fwrite2.o \
+ fwrite.o getcwd.o getdomainname.o \
+ getenv.o gethostname.o getopt_long.o \
+ getopt.o getpgrp.o getpriority.o getpt.o \
+ globals.o inet/bindresvport.o \
+ inet/inet_addr.o inet/inet_aton.o \
+ inet/inet_ntoa.o inet/inet_ntop.o \
+ inet/inet_pton.o isatty.o jrand48.o \
+ llseek.o lrand48.o malloc.o memccpy.o \
+ memchr.o memcmp.o memcpy.o memmem.o \
+ memmove.o memrchr.o memset.o memswap.o \
+ mmap.o mrand48.o nice.o nrand48.o \
+ nullenv.o onexit.o openat.o \
+ open_cloexec.o open.o pause.o perror.o \
+ ppoll.o printf.o pselect.o \
+ pty.o putchar.o __put_env.o putenv.o \
+ puts.o qsort.o raise.o readdir.o \
+ realloc.o reboot.o recv.o remove.o \
+ sbrk.o seed48.o send.o setegid.o \
+ setenv.o seteuid.o setpgrp.o shm_open.o \
+ shm_unlink.o sigabbrev.o sigaction.o \
+ siglist.o siglongjmp.o __signal.o \
+ sigpending.o sigprocmask.o sigsuspend.o \
+ sleep.o snprintf.o sprintf.o srand48.o \
+ sscanf.o statfs.o strcasecmp.o strcat.o \
+ strchr.o strcmp.o strcpy.o strcspn.o \
+ strdup.o strerror.o strlcat.o strlcpy.o \
+ strlen.o strncasecmp.o strncat.o \
+ strncmp.o strncpy.o strndup.o strnlen.o \
+ strntoimax.o strntoumax.o strpbrk.o \
+ strrchr.o strsep.o strsignal.o strspn.o \
+ strstr.o strtoimax.o strtok.o strtoll.o \
+ strtol.o strtotimespec.o strtotimeval.o \
+ strtoull.o strtoul.o strtoumax.o \
+ strxspn.o syslog.o system.o \
+ sysv_signal.o time.o umount.o unsetenv.o \
+ userdb/getgrgid.o userdb/getgrnam.o \
+ userdb/getpwnam.o userdb/getpwuid.o \
+ userdb/root_group.o userdb/root_user.o \
+ usleep.o utime.o vasprintf.o vfork.o \
+ vfprintf.o vprintf.o vsnprintf.o \
+ vsprintf.o vsscanf.o wait3.o wait.o \
+ waitpid.o
klib-$(CONFIG_KLIBC_ERRLIST) += errlist.o
commit d8db398b3f0b893522bf12605e3095789eede748
Author: maximilian attems <max at stro.at>
Date: Wed Aug 15 10:58:13 2007 +0200
.gitignore: add subdir specific entries
ignore
* toplevel: generated *.g and .*.cmd files
* .S autognerated files in klibc/{socketcalls,syscalls}/ + targets
* dash: generates a bunch of specific .c and .h files + targets
* klibc targets
* gzip targets
* kinit targets
* klibc: errlist.c, sha1hash
git status after a build is now down to < 25 lines. :)
Signed-off-by: maximilian attems <max at stro.at>
diff --git a/.gitignore b/.gitignore
index 1ab997c..d67ae65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,5 @@
#
*.o
*.o.cmd
+.*.cmd
+*.g
diff --git a/usr/dash/.gitignore b/usr/dash/.gitignore
new file mode 100644
index 0000000..bf6dab5
--- /dev/null
+++ b/usr/dash/.gitignore
@@ -0,0 +1,17 @@
+.builtins.def.d
+arith.c
+arith.h
+builtins.c
+builtins.def
+builtins.h
+init.c
+mkinit
+mknodes
+mksyntax
+nodes.c
+nodes.h
+sh
+sh.shared
+syntax.c
+syntax.h
+token.h
diff --git a/usr/gzip/.gitignore b/usr/gzip/.gitignore
new file mode 100644
index 0000000..b665e3f
--- /dev/null
+++ b/usr/gzip/.gitignore
@@ -0,0 +1,3 @@
+gunzip
+gzip
+zcat
diff --git a/usr/kinit/.gitignore b/usr/kinit/.gitignore
new file mode 100644
index 0000000..f5a4f24
--- /dev/null
+++ b/usr/kinit/.gitignore
@@ -0,0 +1,3 @@
+lib.a
+kinit
+kinit.shared
diff --git a/usr/klibc/.gitignore b/usr/klibc/.gitignore
new file mode 100644
index 0000000..7cb400a
--- /dev/null
+++ b/usr/klibc/.gitignore
@@ -0,0 +1,9 @@
+errlist.c
+.interp.o.d
+klibc*.so
+klib.list
+.klib.list.cmd
+libc.a
+libc.so
+libc.so.hash
+sha1hash
diff --git a/usr/klibc/socketcalls/.gitignore b/usr/klibc/socketcalls/.gitignore
new file mode 100644
index 0000000..60e5b1d
--- /dev/null
+++ b/usr/klibc/socketcalls/.gitignore
@@ -0,0 +1,3 @@
+*.S
+SOCKETCALLS.i
+socketcalls.mk
diff --git a/usr/klibc/syscalls/.gitignore b/usr/klibc/syscalls/.gitignore
new file mode 100644
index 0000000..d255e6e
--- /dev/null
+++ b/usr/klibc/syscalls/.gitignore
@@ -0,0 +1,6 @@
+*.S
+SYSCALLS.i
+syscalls.mk
+syscalls.nrs
+typesize.bin
+typesize.c
commit cfbff10509b1ee6964339684e739d6f086e44b5e
Author: maximilian attems <max at stro.at>
Date: Sat Aug 11 12:34:01 2007 +0200
fstype: add ext4 support
ext3_fs.h: add the new flags.
one still need some oot e2fsprogs, but ext4dev is in linus
./misc/mke2fs -j /dev/mapper/nancy_vg1-ext4
mount /dev/mapper/nancy_vg1-ext4 /mnt -t ext4dev -o extents
touch /mnt/oooo
./src/klibc/usr/kinit/fstype/static/fstype /dev/mapper/nancy_vg1-ext4
FSTYPE=ext4dev
FSSIZE=314572800
will probably once get renamed to ext4, but for now module is ext4dev
egrep ext /proc/filesystems
ext3
ext4dev
Signed-off-by: maximilian attems <max at stro.at>
diff --git a/usr/kinit/fstype/ext3_fs.h b/usr/kinit/fstype/ext3_fs.h
index e3deb72..12d64fe 100644
--- a/usr/kinit/fstype/ext3_fs.h
+++ b/usr/kinit/fstype/ext3_fs.h
@@ -7,6 +7,10 @@
#define EXT3_SUPER_MAGIC 0xEF53
#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
+#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
+#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040
+#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
+#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
/*
* Structure of the super block
diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index 015b7a0..3465676 100644
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -107,6 +107,25 @@ static int minix_image(const void *buf, unsigned long long *bytes)
return 0;
}
+static int ext4_image(const void *buf, unsigned long long *bytes)
+{
+ const struct ext3_super_block *sb =
+ (const struct ext3_super_block *)buf;
+
+ if (sb->s_magic == __cpu_to_le16(EXT2_SUPER_MAGIC)
+ && (sb->s_feature_incompat
+ & __cpu_to_le32(EXT3_FEATURE_INCOMPAT_EXTENTS)
+ || sb->s_feature_incompat
+ & __cpu_to_le32(EXT4_FEATURE_INCOMPAT_64BIT)
+ || sb->s_feature_incompat
+ & __cpu_to_le32(EXT4_FEATURE_INCOMPAT_MMP))) {
+ *bytes = (unsigned long long)__le32_to_cpu(sb->s_blocks_count)
+ << (10 + __le32_to_cpu(sb->s_log_block_size));
+ return 1;
+ }
+ return 0;
+}
+
static int ext3_image(const void *buf, unsigned long long *bytes)
{
const struct ext3_super_block *sb =
@@ -302,6 +321,7 @@ static struct imagetype images[] = {
{0, "romfs", romfs_image},
{0, "xfs", xfs_image},
{0, "squashfs", squashfs_image},
+ {1, "ext4dev", ext4_image},
{1, "ext3", ext3_image},
{1, "ext2", ext2_image},
{1, "minix", minix_image},
commit bdd1ca2344edd06c873980c7023b8be006abd4f0
Author: maximilian attems <max at stro.at>
Date: Sat Aug 11 11:25:15 2007 +0200
reiser4_fs.h: add attribute packed to reiser4_master_sb
forgot to add it while working on the reiser4_fs.h cleanup
Signed-off-by: maximilian attems <max at stro.at>
diff --git a/usr/kinit/fstype/reiser4_fs.h b/usr/kinit/fstype/reiser4_fs.h
index caca897..fb2fa12 100644
--- a/usr/kinit/fstype/reiser4_fs.h
+++ b/usr/kinit/fstype/reiser4_fs.h
@@ -24,7 +24,7 @@ struct reiser4_master_sb {
/* Filesystem label in use. */
char ms_label[SS_MAGIC_SIZE];
-};
+} __attribute__ ((packed));
#define REISER4_SUPER_MAGIC_STRING "ReIsEr4"
commit 4040381e3ef98c6fd5dedf26ebfcb4db79a74263
Author: maximilian attems <max at stro.at>
Date: Sat Aug 11 11:17:11 2007 +0200
fstype: add squashfs v3 support
squashfs although not in mainline is a widely used ro fs.
mksquashfs /tmp bla > /dev/null
./usr/kinit/fstype/static/fstype ~/foo1
FSTYPE=squashfs
FSSIZE=1951042
cleaned up version of an ubuntu patch against 1.1.15 klibc.
Signed-off-by: maximilian attems <max at stro.at>
diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index 52354f0..015b7a0 100644
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -30,6 +30,7 @@
#include "luks_fs.h"
#include "lvm2_sb.h"
#include "iso9660_sb.h"
+#include "squashfs_fs.h"
/*
* Slightly cleaned up version of jfs_superblock to
@@ -264,6 +265,19 @@ static int iso_image(const void *buf, unsigned long long *blocks)
return 0;
}
+static int squashfs_image(const void *buf, unsigned long long *blocks)
+{
+ const struct squashfs_super_block *sb =
+ (const struct squashfs_super_block *)buf;
+
+ if (sb->s_magic == SQUASHFS_MAGIC
+ || sb->s_magic == SQUASHFS_MAGIC_SWAP) {
+ *blocks = (unsigned long long) sb->bytes_used;
+ return 1;
+ }
+ return 0;
+}
+
struct imagetype {
off_t block;
const char name[12];
@@ -287,6 +301,7 @@ static struct imagetype images[] = {
{0, "cramfs", cramfs_image},
{0, "romfs", romfs_image},
{0, "xfs", xfs_image},
+ {0, "squashfs", squashfs_image},
{1, "ext3", ext3_image},
{1, "ext2", ext2_image},
{1, "minix", minix_image},
diff --git a/usr/kinit/fstype/squashfs_fs.h b/usr/kinit/fstype/squashfs_fs.h
new file mode 100644
index 0000000..017b8a5
--- /dev/null
+++ b/usr/kinit/fstype/squashfs_fs.h
@@ -0,0 +1,41 @@
+#ifndef __SQUASHFS_FS_H
+#define __SQUASHFS_FS_H
+
+/*
+ * Squashfs
+ */
+
+#define SQUASHFS_MAGIC 0x73717368
+#define SQUASHFS_MAGIC_SWAP 0x68737173
+
+/* definitions for structures on disk */
+struct squashfs_super_block {
+ unsigned int s_magic;
+ unsigned int inodes;
+ unsigned int bytes_used_2;
+ unsigned int uid_start_2;
+ unsigned int guid_start_2;
+ unsigned int inode_table_start_2;
+ unsigned int directory_table_start_2;
+ unsigned int s_major:16;
+ unsigned int s_minor:16;
+ unsigned int block_size_1:16;
+ unsigned int block_log:16;
+ unsigned int flags:8;
+ unsigned int no_uids:8;
+ unsigned int no_guids:8;
+ unsigned int mkfs_time /* time of filesystem creation */;
+ long long root_inode;
+ unsigned int block_size;
+ unsigned int fragments;
+ unsigned int fragment_table_start_2;
+ long long bytes_used;
+ long long uid_start;
+ long long guid_start;
+ long long inode_table_start;
+ long long directory_table_start;
+ long long fragment_table_start;
+ long long lookup_table_start;
+} __attribute__ ((packed));
+
+#endif /* __SQUASHFS_FS_H */
More information about the klibc
mailing list