On Mon, 13 Aug 2007, maximilian attems wrote:
> please pull the latest
> git pull git://brane.itp.tuwien.ac.at/~mattems/klibc.git maks
>
see belows diff:
diff --git a/.gitignore b/.gitignore
index 1ab997c..83f2431 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@
#
*.o
*.o.cmd
+.*.cmd
diff --git a/usr/include/stdio.h b/usr/include/stdio.h
index 1462f5b..4cc3406 100644
--- a/usr/include/stdio.h
+++ b/usr/include/stdio.h
@@ -107,6 +107,8 @@ __extern int snprintf(char *, size_t n, const char *, ...);
__extern int vsnprintf(char *, size_t n, const char *, va_list);
__extern int asprintf(char **, const char *, ...);
__extern int vasprintf(char **, const char *, va_list);
+__extern int vdprintf(int, const char *, va_list);
+__extern int dprintf(int, const char *, ...);
/* No buffering, so no flushing needed */
extern __inline__ int fflush(FILE * __f)
diff --git a/usr/include/string.h b/usr/include/string.h
index 1a6072c..7fd8b49 100644
--- a/usr/include/string.h
+++ b/usr/include/string.h
@@ -43,5 +43,6 @@ __extern char *strsep(char **, const char *);
__extern size_t strspn(const char *, const char *);
__extern char *strstr(const char *, const char *);
__extern char *strtok(char *, const char *);
+__extern void bzero(void *, size_t);
#endif /* _STRING_H */
diff --git a/usr/include/strings.h b/usr/include/strings.h
new file mode 100644
index 0000000..d4ab74a
--- /dev/null
+++ b/usr/include/strings.h
@@ -0,0 +1,10 @@
+#ifndef _STRINGS_H
+#define _STRINGS_H
+
+#if !defined _STRING_H
+
+/* XXX: add actual content */
+
+#endif
+
+#endif /* _STRINGS_H */
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 52354f0..3465676 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
@@ -106,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 @@ -264,6 +284,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 +320,8 @@ static struct imagetype images[] = {
{0, "cramfs", cramfs_image},
{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},
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"
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 */
diff --git a/usr/klibc/.gitignore b/usr/klibc/.gitignore
new file mode 100644
index 0000000..7888c27
--- /dev/null
+++ b/usr/klibc/.gitignore
@@ -0,0 +1,7 @@
+.interp.o.d
+klibc*.so
+klib.list
+.klib.list.cmd
+libc.a
+libc.so
+libc.so.hash
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index ad72116..5c2a12e 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -55,7 +55,8 @@ klib-y := vsnprintf.o snprintf.o vsprintf.o sprintf.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
+ userdb/getpwuid.o userdb/root_group.o userdb/root_user.o \
+ vdprintf.o dprintf.o bzero.o
klib-$(CONFIG_KLIBC_ERRLIST) += errlist.o
diff --git a/usr/klibc/bzero.c b/usr/klibc/bzero.c
new file mode 100644
index 0000000..a388e1d
--- /dev/null
+++ b/usr/klibc/bzero.c
@@ -0,0 +1,7 @@
+#include <string.h>
+#include <stdint.h>
+
+void bzero(void *dst, size_t n)
+{
+ memset(dst, 0, n);
+}
diff --git a/usr/klibc/dprintf.c b/usr/klibc/dprintf.c
new file mode 100644
index 0000000..f5b3473
--- /dev/null
+++ b/usr/klibc/dprintf.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdarg.h>
+
+#define BUFFER_SIZE 16384
+
+int dprintf(int fd, const char *format, ...)
+{
+ va_list ap;
+ int rv;
+
+ va_start(ap, format);
+ rv = vdprintf(fd, format, ap);
+ va_end(ap);
+ return rv;
+}
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
diff --git a/usr/klibc/vdprintf.c b/usr/klibc/vdprintf.c
new file mode 100644
index 0000000..8a9f252
--- /dev/null
+++ b/usr/klibc/vdprintf.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
+
+#define BUFFER_SIZE 32768
+
+int vdprintf(int fd, const char *format, va_list ap)
+{
+ int rv;
+ char buffer[BUFFER_SIZE];
+
+ rv = vsnprintf(buffer, BUFFER_SIZE, format, ap);
+
+ if (rv < 0)
+ return rv;
+
+ if (rv > BUFFER_SIZE - 1)
+ rv = BUFFER_SIZE - 1;
+
+ return write(fd, buffer, rv);
+}