hello hpa, please pull latest git pull git://git.debian.org/~maks/klibc.git maks forgot to ask to keep git port open for our boxes at university, thus moved my tree over too the alioth box. for the changes maximilian attems (4): [klibc] klibc/socketcalls/.gitignore addition [klibc] elf.h add support for st_info field [klibc] remove local insmod.c copy [klibc] ipconfig fix DHCPREQUEST per RFC 2131 the diffstat is usr/include/sys/elf32.h | 4 + usr/include/sys/elf64.h | 4 + usr/include/sys/elfcommon.h | 10 +++ usr/kinit/ipconfig/dhcp_proto.c | 2 +- usr/klibc/socketcalls/.gitignore | 1 + usr/utils/Kbuild | 4 +- usr/utils/insmod.c | 140 -------------------------------------- 7 files changed, 21 insertions(+), 144 deletions(-) commit 83cd38f8cc2a04ef6d4ce96de719c993edd7fbfb Author: maximilian attems <max at stro.at> Date: Mon Dec 10 15:52:49 2007 +0100 [klibc] ipconfig fix DHCPREQUEST per RFC 2131 Ken Simon found that Cisco would drop non frc 2131 ipconfig DHCPREQUEST packet. see for all glorious details http://marc.info/?l=linux-kernel&m=119697064911348&w=2 also reported on http://bugs.debian.org/432977 Cc: Christian Kern <kernch at in.tum.de> Cc: Ken Simon <ninkendo at gmail.com> Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/kinit/ipconfig/dhcp_proto.c b/usr/kinit/ipconfig/dhcp_proto.c index a1090f3..8ff1d58 100644 --- a/usr/kinit/ipconfig/dhcp_proto.c +++ b/usr/kinit/ipconfig/dhcp_proto.c @@ -161,7 +161,7 @@ static int dhcp_send(struct netdev *dev, struct iovec *vec) bootp.hlen = dev->hwlen; bootp.xid = dev->bootp.xid; bootp.ciaddr = dev->ip_addr; - bootp.giaddr = dev->bootp.gateway; + bootp.giaddr = INADDR_ANY; bootp.secs = htons(time(NULL) - dev->open_time); memcpy(bootp.chaddr, dev->hwaddr, 16); commit fbf8aa559d25685eea12248c76bcc983c68306b2 Author: maximilian attems <max at stro.at> Date: Sat Sep 22 23:06:05 2007 +0200 [klibc] remove local insmod.c copy we want to compile latest module-init-tools against klibc. insmod is not used by kinit. Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/utils/Kbuild b/usr/utils/Kbuild index 09157a8..5b6dc28 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 dmesg +progs += uname halt kill readlink cpio sync dmesg static-y := $(addprefix static/, $(progs)) shared-y := $(addprefix shared/, $(progs)) @@ -42,8 +42,6 @@ static/minips-y := minips.o shared/minips-y := minips.o static/cat-y := cat.o shared/cat-y := cat.o -static/insmod-y := insmod.o -shared/insmod-y := insmod.o static/uname-y := uname.o shared/uname-y := uname.o static/halt-y := halt.o diff --git a/usr/utils/insmod.c b/usr/utils/insmod.c deleted file mode 100644 index 47b5880..0000000 --- a/usr/utils/insmod.c +++ /dev/null @@ -1,140 +0,0 @@ -/* insmod.c: insert a module into the kernel. - Copyright (C) 2001 Rusty Russell. - Copyright (C) 2002 Rusty Russell, IBM Corporation. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/mman.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <errno.h> - -#define streq(a,b) (strcmp((a),(b)) == 0) - -/* This really needs to be in a header file... */ -extern long init_module(void *, unsigned long, const char *); - -static void print_usage(const char *progname) -{ - fprintf(stderr, "Usage: %s filename [args]\n", progname); - exit(1); -} - -/* We use error numbers in a loose translation... */ -static const char *moderror(int err) -{ - switch (err) { - case ENOEXEC: - return "Invalid module format"; - case ENOENT: - return "Unknown symbol in module"; - case ESRCH: - return "Module has wrong symbol version"; - case EINVAL: - return "Invalid parameters"; - default: - return strerror(err); - } -} - -static void *grab_file(const char *filename, unsigned long *size) -{ - unsigned int max = 16384; - int ret, fd; - void *buffer = malloc(max); - - if (streq(filename, "-")) - fd = dup(STDIN_FILENO); - else - fd = open(filename, O_RDONLY, 0); - - if (fd < 0) - return NULL; - - *size = 0; - while ((ret = read(fd, buffer + *size, max - *size)) > 0) { - *size += ret; - if (*size == max) - buffer = realloc(buffer, max *= 2); - } - if (ret < 0) { - free(buffer); - buffer = NULL; - } - close(fd); - return buffer; -} - -int main(int argc, char *argv[]) -{ - int i; - long int ret; - unsigned long len; - void *file; - char *filename, *options = strdup(""); - char *progname = argv[0]; - - if (argv[1] && (streq(argv[1], "--version") || streq(argv[1], "-V"))) { - puts("klibc insmod"); - exit(0); - } - - /* Ignore old options, for backwards compat. */ - while (argv[1] && (streq(argv[1], "-p") - || streq(argv[1], "-s") - || streq(argv[1], "-f"))) { - argv++; - argc--; - } - - filename = argv[1]; - if (!filename) - print_usage(progname); - - /* Rest is options */ - for (i = 2; i < argc; i++) { - options = realloc(options, - strlen(options) + 2 + strlen(argv[i]) + 2); - /* Spaces handled by "" pairs, but no way of escaping - quotes */ - if (strchr(argv[i], ' ')) - strcat(options, "\""); - strcat(options, argv[i]); - if (strchr(argv[i], ' ')) - strcat(options, "\""); - strcat(options, " "); - } - - file = grab_file(filename, &len); - if (!file) { - fprintf(stderr, "insmod: can't read '%s': %s\n", - filename, strerror(errno)); - exit(1); - } - - ret = init_module(file, len, options); - if (ret != 0) { - fprintf(stderr, "insmod: error inserting '%s': %li %s\n", - filename, ret, moderror(errno)); - exit(1); - } - exit(0); -} commit 3b52c5b3b2ee035c4d72fc5d8fbe436115d3e3e6 Author: maximilian attems <max at stro.at> Date: Sat Sep 22 22:58:25 2007 +0200 [klibc] elf.h add support for st_info field module-init-tools uses STB_WEAK and accesses it. Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/include/sys/elf32.h b/usr/include/sys/elf32.h index e4df8ce..6da2ddb 100644 --- a/usr/include/sys/elf32.h +++ b/usr/include/sys/elf32.h @@ -110,4 +110,8 @@ typedef struct elf32_note { Elf32_Word n_type; /* Content type */ } Elf32_Nhdr; +/* How to extract and insert information held in the st_info field. */ +#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) +#define ELF32_ST_TYPE(val) ((val) & 0xf) + #endif /* _SYS_ELF32_H */ diff --git a/usr/include/sys/elf64.h b/usr/include/sys/elf64.h index 0b486ac..877b7cd 100644 --- a/usr/include/sys/elf64.h +++ b/usr/include/sys/elf64.h @@ -110,4 +110,8 @@ typedef struct elf64_note { Elf64_Word n_type; /* Content type */ } Elf64_Nhdr; +/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ +#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) +#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) + #endif /* _SYS_ELF64_H */ diff --git a/usr/include/sys/elfcommon.h b/usr/include/sys/elfcommon.h index 0d81db5..ad5e459 100644 --- a/usr/include/sys/elfcommon.h +++ b/usr/include/sys/elfcommon.h @@ -184,4 +184,14 @@ #define ELFOSABI_NONE 0 #define ELFOSABI_LINUX 3 +/* Legal values for ST_BIND subfield of st_info (symbol binding). */ +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* Weak symbol */ +#define STB_NUM 3 /* Number of defined types. */ +#define STB_LOOS 10 /* Start of OS-specific */ +#define STB_HIOS 12 /* End of OS-specific */ +#define STB_LOPROC 13 /* Start of processor-specific */ +#define STB_HIPROC 15 /* End of processor-specific */ + #endif /* _SYS_ELFCOMMON_H */ commit 8c4bf5fd4c5e0bd85d1d29f489bdb980edf1a489 Author: maximilian attems <max at stro.at> Date: Fri Sep 21 19:47:31 2007 +0200 [klibc] klibc/socketcalls/.gitignore addition on !i386 socketcalls generates .c files Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/klibc/socketcalls/.gitignore b/usr/klibc/socketcalls/.gitignore index 60e5b1d..67da0d1 100644 --- a/usr/klibc/socketcalls/.gitignore +++ b/usr/klibc/socketcalls/.gitignore @@ -1,3 +1,4 @@ *.S +*.c SOCKETCALLS.i socketcalls.mk -- maks
maximilian attems
2007-Dec-11 11:30 UTC
[klibc] [git patch] m-i-t support, ipconfig + fstype fix
hello hpa, fstype squashfs-lzma support patch just landed in my inbox, so added to the current patch queue. thanks to the elf fixes one can compile module-init-tools with klibc and thus i consider the old local insmod copy as no longer relevant and nuked it. have to resend the one klibc insmod patch that didn't land yet in m-i-t upstream. please pull latest git pull git://git.debian.org/~maks/klibc.git maks (my tree mved from university to debian due to blocked port) for the changes: Kel Modderman (1): [klibc] fstype add squashfs-lzma magic maximilian attems (4): [klibc] klibc/socketcalls/.gitignore addition [klibc] elf.h add support for st_info field [klibc] remove local insmod.c copy [klibc] ipconfig fix DHCPREQUEST per RFC 2131 and the diffstat: usr/include/sys/elf32.h | 4 + usr/include/sys/elf64.h | 4 + usr/include/sys/elfcommon.h | 10 +++ usr/kinit/fstype/fstype.c | 4 +- usr/kinit/fstype/squashfs_fs.h | 7 ++ usr/kinit/ipconfig/dhcp_proto.c | 2 +- usr/klibc/socketcalls/.gitignore | 1 + usr/utils/Kbuild | 4 +- usr/utils/insmod.c | 140 -------------------------------------- 9 files changed, 31 insertions(+), 145 deletions(-) thanks -- maks commit c6928e4ecc9306eebdf680e89e2c1caa438646b1 Author: Kel Modderman <kel at otaku42.de> Date: Tue Dec 11 19:41:29 2007 +1000 [klibc] fstype add squashfs-lzma magic Add squashfs-lzma support to fstype. Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c index 2f219e6..ea7171b 100644 --- a/usr/kinit/fstype/fstype.c +++ b/usr/kinit/fstype/fstype.c @@ -292,7 +292,9 @@ static int squashfs_image(const void *buf, unsigned long long *blocks) (const struct squashfs_super_block *)buf; if (sb->s_magic == SQUASHFS_MAGIC - || sb->s_magic == SQUASHFS_MAGIC_SWAP) { + || sb->s_magic == SQUASHFS_MAGIC_SWAP + || sb->s_magic == SQUASHFS_MAGIC_LZMA + || sb->s_magic == SQUASHFS_MAGIC_LZMA_SWAP) { *blocks = (unsigned long long) sb->bytes_used; return 1; } diff --git a/usr/kinit/fstype/squashfs_fs.h b/usr/kinit/fstype/squashfs_fs.h index 017b8a5..c18365d 100644 --- a/usr/kinit/fstype/squashfs_fs.h +++ b/usr/kinit/fstype/squashfs_fs.h @@ -8,6 +8,13 @@ #define SQUASHFS_MAGIC 0x73717368 #define SQUASHFS_MAGIC_SWAP 0x68737173 +/* + * Squashfs + LZMA + */ + +#define SQUASHFS_MAGIC_LZMA 0x71736873 +#define SQUASHFS_MAGIC_LZMA_SWAP 0x73687371 + /* definitions for structures on disk */ struct squashfs_super_block { unsigned int s_magic; commit 83cd38f8cc2a04ef6d4ce96de719c993edd7fbfb Author: maximilian attems <max at stro.at> Date: Mon Dec 10 15:52:49 2007 +0100 [klibc] ipconfig fix DHCPREQUEST per RFC 2131 Ken Simon found that Cisco would drop non frc 2131 ipconfig DHCPREQUEST packet. see for all glorious details http://marc.info/?l=linux-kernel&m=119697064911348&w=2 also reported on http://bugs.debian.org/432977 Cc: Christian Kern <kernch at in.tum.de> Cc: Ken Simon <ninkendo at gmail.com> Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/kinit/ipconfig/dhcp_proto.c b/usr/kinit/ipconfig/dhcp_proto.c index a1090f3..8ff1d58 100644 --- a/usr/kinit/ipconfig/dhcp_proto.c +++ b/usr/kinit/ipconfig/dhcp_proto.c @@ -161,7 +161,7 @@ static int dhcp_send(struct netdev *dev, struct iovec *vec) bootp.hlen = dev->hwlen; bootp.xid = dev->bootp.xid; bootp.ciaddr = dev->ip_addr; - bootp.giaddr = dev->bootp.gateway; + bootp.giaddr = INADDR_ANY; bootp.secs = htons(time(NULL) - dev->open_time); memcpy(bootp.chaddr, dev->hwaddr, 16); commit fbf8aa559d25685eea12248c76bcc983c68306b2 Author: maximilian attems <max at stro.at> Date: Sat Sep 22 23:06:05 2007 +0200 [klibc] remove local insmod.c copy we want to compile latest module-init-tools against klibc. insmod is not used by kinit. Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/utils/Kbuild b/usr/utils/Kbuild index 09157a8..5b6dc28 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 dmesg +progs += uname halt kill readlink cpio sync dmesg static-y := $(addprefix static/, $(progs)) shared-y := $(addprefix shared/, $(progs)) @@ -42,8 +42,6 @@ static/minips-y := minips.o shared/minips-y := minips.o static/cat-y := cat.o shared/cat-y := cat.o -static/insmod-y := insmod.o -shared/insmod-y := insmod.o static/uname-y := uname.o shared/uname-y := uname.o static/halt-y := halt.o diff --git a/usr/utils/insmod.c b/usr/utils/insmod.c deleted file mode 100644 index 47b5880..0000000 --- a/usr/utils/insmod.c +++ /dev/null @@ -1,140 +0,0 @@ -/* insmod.c: insert a module into the kernel. - Copyright (C) 2001 Rusty Russell. - Copyright (C) 2002 Rusty Russell, IBM Corporation. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/mman.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <errno.h> - -#define streq(a,b) (strcmp((a),(b)) == 0) - -/* This really needs to be in a header file... */ -extern long init_module(void *, unsigned long, const char *); - -static void print_usage(const char *progname) -{ - fprintf(stderr, "Usage: %s filename [args]\n", progname); - exit(1); -} - -/* We use error numbers in a loose translation... */ -static const char *moderror(int err) -{ - switch (err) { - case ENOEXEC: - return "Invalid module format"; - case ENOENT: - return "Unknown symbol in module"; - case ESRCH: - return "Module has wrong symbol version"; - case EINVAL: - return "Invalid parameters"; - default: - return strerror(err); - } -} - -static void *grab_file(const char *filename, unsigned long *size) -{ - unsigned int max = 16384; - int ret, fd; - void *buffer = malloc(max); - - if (streq(filename, "-")) - fd = dup(STDIN_FILENO); - else - fd = open(filename, O_RDONLY, 0); - - if (fd < 0) - return NULL; - - *size = 0; - while ((ret = read(fd, buffer + *size, max - *size)) > 0) { - *size += ret; - if (*size == max) - buffer = realloc(buffer, max *= 2); - } - if (ret < 0) { - free(buffer); - buffer = NULL; - } - close(fd); - return buffer; -} - -int main(int argc, char *argv[]) -{ - int i; - long int ret; - unsigned long len; - void *file; - char *filename, *options = strdup(""); - char *progname = argv[0]; - - if (argv[1] && (streq(argv[1], "--version") || streq(argv[1], "-V"))) { - puts("klibc insmod"); - exit(0); - } - - /* Ignore old options, for backwards compat. */ - while (argv[1] && (streq(argv[1], "-p") - || streq(argv[1], "-s") - || streq(argv[1], "-f"))) { - argv++; - argc--; - } - - filename = argv[1]; - if (!filename) - print_usage(progname); - - /* Rest is options */ - for (i = 2; i < argc; i++) { - options = realloc(options, - strlen(options) + 2 + strlen(argv[i]) + 2); - /* Spaces handled by "" pairs, but no way of escaping - quotes */ - if (strchr(argv[i], ' ')) - strcat(options, "\""); - strcat(options, argv[i]); - if (strchr(argv[i], ' ')) - strcat(options, "\""); - strcat(options, " "); - } - - file = grab_file(filename, &len); - if (!file) { - fprintf(stderr, "insmod: can't read '%s': %s\n", - filename, strerror(errno)); - exit(1); - } - - ret = init_module(file, len, options); - if (ret != 0) { - fprintf(stderr, "insmod: error inserting '%s': %li %s\n", - filename, ret, moderror(errno)); - exit(1); - } - exit(0); -} commit 3b52c5b3b2ee035c4d72fc5d8fbe436115d3e3e6 Author: maximilian attems <max at stro.at> Date: Sat Sep 22 22:58:25 2007 +0200 [klibc] elf.h add support for st_info field module-init-tools uses STB_WEAK and accesses it. Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/include/sys/elf32.h b/usr/include/sys/elf32.h index e4df8ce..6da2ddb 100644 --- a/usr/include/sys/elf32.h +++ b/usr/include/sys/elf32.h @@ -110,4 +110,8 @@ typedef struct elf32_note { Elf32_Word n_type; /* Content type */ } Elf32_Nhdr; +/* How to extract and insert information held in the st_info field. */ +#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) +#define ELF32_ST_TYPE(val) ((val) & 0xf) + #endif /* _SYS_ELF32_H */ diff --git a/usr/include/sys/elf64.h b/usr/include/sys/elf64.h index 0b486ac..877b7cd 100644 --- a/usr/include/sys/elf64.h +++ b/usr/include/sys/elf64.h @@ -110,4 +110,8 @@ typedef struct elf64_note { Elf64_Word n_type; /* Content type */ } Elf64_Nhdr; +/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ +#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) +#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) + #endif /* _SYS_ELF64_H */ diff --git a/usr/include/sys/elfcommon.h b/usr/include/sys/elfcommon.h index 0d81db5..ad5e459 100644 --- a/usr/include/sys/elfcommon.h +++ b/usr/include/sys/elfcommon.h @@ -184,4 +184,14 @@ #define ELFOSABI_NONE 0 #define ELFOSABI_LINUX 3 +/* Legal values for ST_BIND subfield of st_info (symbol binding). */ +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* Weak symbol */ +#define STB_NUM 3 /* Number of defined types. */ +#define STB_LOOS 10 /* Start of OS-specific */ +#define STB_HIOS 12 /* End of OS-specific */ +#define STB_LOPROC 13 /* Start of processor-specific */ +#define STB_HIPROC 15 /* End of processor-specific */ + #endif /* _SYS_ELFCOMMON_H */ commit 8c4bf5fd4c5e0bd85d1d29f489bdb980edf1a489 Author: maximilian attems <max at stro.at> Date: Fri Sep 21 19:47:31 2007 +0200 [klibc] klibc/socketcalls/.gitignore addition on !i386 socketcalls generates .c files Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/klibc/socketcalls/.gitignore b/usr/klibc/socketcalls/.gitignore index 60e5b1d..67da0d1 100644 --- a/usr/klibc/socketcalls/.gitignore +++ b/usr/klibc/socketcalls/.gitignore @@ -1,3 +1,4 @@ *.S +*.c SOCKETCALLS.i socketcalls.mk