maximilian attems
2010-Apr-25 22:54 UTC
[klibc] [git pull] small fixes, sh4, getruage() README's
hello hpa, current patch queue for review, please pull: git pull git://git.debian.org/users/maks/klibc.git maks Aurelien Jarno (1): [klibc] sh4: syscalls fixes Benjamin Cama (1): [klibc] fstype: btrfs size endianness fix Thorsten Glaser (1): [klibc] add getrusage() maximilian attems (3): [klibc] resume: silence warning on resume try [klibc] bootp_packet.h minor stylistic fix [klibc] fstype: list the includes in alphabetic order git diff -M --stat --summary master...maks usr/include/sys/resource.h | 2 ++ usr/kinit/fstype/fstype.c | 18 +++++++++--------- usr/kinit/ipconfig/bootp_packet.h | 2 +- usr/kinit/resume/resumelib.c | 2 +- usr/klibc/SYSCALLS.def | 3 ++- usr/klibc/arch/sh/Kbuild | 2 +- usr/klibc/arch/sh/pipe.S | 35 +++++++++++++++++++++++++++++++++++ usr/klibc/arch/sh/syscall.S | 14 +++++++------- 8 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 usr/klibc/arch/sh/pipe.S thanks -- maks commit a1ffdac59c837f18a35dc9d3f3a0f4f738cb61e8 Author: Benjamin Cama <benoar at free.fr> Date: Sun Apr 25 22:39:05 2010 +0200 [klibc] fstype: btrfs size endianness fix Tested OK on both little endian (amd64) and big endian (powerpc). Signed-off-by: Benjamin Cama <benoar at free.fr> Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c index d57b937..451d60c 100644 --- a/usr/kinit/fstype/fstype.c +++ b/usr/kinit/fstype/fstype.c @@ -460,7 +460,7 @@ static int btrfs_image(const void *buf, unsigned long long *bytes) (const struct btrfs_super_block *)buf; if (!memcmp(sb->magic, BTRFS_MAGIC, BTRFS_MAGIC_L)) { - *bytes = sb->total_bytes; + *bytes = (unsigned long long)__le64_to_cpu(sb->total_bytes); return 1; } return 0; commit 30c21662ec3c036aa551dd75375a4d8d7e008ad6 Author: Aurelien Jarno <aurel32 at debian.org> Date: Fri Apr 16 18:17:58 2010 +0200 [klibc] sh4: syscalls fixes Using the patch from bug #574834 klibc now builds, but does not work. It assumes that the kernel returns the result of the syscalls in register r3, while it behaves like a normal call, with the results in register r0. Also the pipe syscall needs a special handling as on some other architectures, the structure passed in argument is not filled, instead the two fd are returned in r0 and r1. The patch below fixes the problem. It has been tested by creating an initrd with initramfs and booting the system with it. Closes: #578076 Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def index e395119..437dfa7 100644 --- a/usr/klibc/SYSCALLS.def +++ b/usr/klibc/SYSCALLS.def @@ -115,7 +115,7 @@ int fchmod(int, mode_t); int mkdir(const char *, mode_t); <?> int mkdirat(int, const char *, const char *, mode_t); int rmdir(const char *); -<!alpha,ia64,mips,mips64,sparc,sparc64> int pipe(int *); +<!alpha,ia64,mips,mips64,sh,sparc,sparc64> int pipe(int *); mode_t umask(mode_t); int chroot(const char *); int symlink(const char *, const char *); diff --git a/usr/klibc/arch/sh/Kbuild b/usr/klibc/arch/sh/Kbuild index ab7ad5a..29b606a 100644 --- a/usr/klibc/arch/sh/Kbuild +++ b/usr/klibc/arch/sh/Kbuild @@ -2,7 +2,7 @@ # klibc files for sh # -klib-y := setjmp.o syscall.o +klib-y := pipe.o setjmp.o syscall.o always := crt0.o targets := crt0.o diff --git a/usr/klibc/arch/sh/pipe.S b/usr/klibc/arch/sh/pipe.S new file mode 100644 index 0000000..01b055b --- /dev/null +++ b/usr/klibc/arch/sh/pipe.S @@ -0,0 +1,35 @@ +/* + * arch/sh/pipe.S + * + * The pipe system call is special on sh: it returns + * the two file descriptors in r0 and r1. + */ + +#include <asm/unistd.h> + + .section ".text.syscall","ax" + .align 2 + .globl pipe + .type pipe, at function +pipe: + mov #__NR_pipe, r3 + trapa #0x10 + mov.l 1f,r2 + cmp/hs r0,r2 + bt/s 3f + neg r0,r2 + mov.l 2f,r3 + mov.l r2, at r3 + rts + mov #-1,r0 +3: + mov.l r0, @r4 + mov.l r1, @(4, r4) + rts + mov #0,r0 + + .align 2 +1: .long -4096 /* Errno limit */ +2: .long errno + + .size pipe,.-pipe diff --git a/usr/klibc/arch/sh/syscall.S b/usr/klibc/arch/sh/syscall.S index f5f85cc..77245b7 100644 --- a/usr/klibc/arch/sh/syscall.S +++ b/usr/klibc/arch/sh/syscall.S @@ -5,7 +5,7 @@ * r4..r7 contain arguments 0-3 per the standard calling convention, * and arguments 4-5 are passed in r0 and r1. * - * The return value is in r3 rather than standard r0. + * The return value is in r0. */ .section ".text.syscall","ax" @@ -16,17 +16,17 @@ __syscall_common: mov.l @(0,sp),r0 mov.l @(4,sp),r1 trapa #0x15 - mov.l 1f,r0 - cmp/hs r0,r3 + mov.l 1f,r1 + cmp/hs r0,r1 bt/s 3f - neg r3,r4 - mov.l 2f,r5 - mov.l r4, at r5 + neg r0,r1 + mov.l 2f,r2 + mov.l r1, at r2 rts mov #-1,r0 3: rts - mov r3,r0 + nop .align 2 1: .long -4096 /* Errno limit */ commit e99c86408fa88b7a8740ea02a8157f71a14ec2ba Author: maximilian attems <max at stro.at> Date: Sat Apr 10 16:24:52 2010 +0200 [klibc] fstype: list the includes in alphabetic order currently there is no order. Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c index 6aa82fc..d57b937 100644 --- a/usr/kinit/fstype/fstype.c +++ b/usr/kinit/fstype/fstype.c @@ -23,20 +23,20 @@ #define cpu_to_be32(x) __cpu_to_be32(x) /* Needed by romfs_fs.h */ -#include "romfs_fs.h" +#include "btrfs.h" #include "cramfs_fs.h" -#include "minix_fs.h" #include "ext2_fs.h" #include "ext3_fs.h" -#include "xfs_sb.h" +#include "gfs2_fs.h" +#include "iso9660_sb.h" #include "luks_fs.h" #include "lvm2_sb.h" -#include "iso9660_sb.h" -#include "squashfs_fs.h" -#include "gfs2_fs.h" -#include "ocfs2_fs.h" +#include "minix_fs.h" #include "nilfs_fs.h" -#include "btrfs.h" +#include "ocfs2_fs.h" +#include "romfs_fs.h" +#include "squashfs_fs.h" +#include "xfs_sb.h" /* * Slightly cleaned up version of jfs_superblock to commit 5d3b7024db283d2518eb60718768b05638de3698 Author: maximilian attems <max at stro.at> Date: Sat Apr 10 16:22:55 2010 +0200 [klibc] bootp_packet.h minor stylistic fix Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/kinit/ipconfig/bootp_packet.h b/usr/kinit/ipconfig/bootp_packet.h index 3525ec3..6016e5f 100644 --- a/usr/kinit/ipconfig/bootp_packet.h +++ b/usr/kinit/ipconfig/bootp_packet.h @@ -28,4 +28,4 @@ struct bootp_hdr { /* 312 bytes of extensions */ }; -#endif +#endif /* BOOTP_PACKET_H */ commit 7416d9a51082b9ecd322d71bd2f96597195e141a Author: maximilian attems <max at stro.at> Date: Mon Apr 5 04:18:09 2010 +0200 [klibc] resume: silence warning on resume try We most propably didn't hibernate in the first place. s/fprintf/dprintf/ Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/kinit/resume/resumelib.c b/usr/kinit/resume/resumelib.c index 5233e7e..4a615f0 100644 --- a/usr/kinit/resume/resumelib.c +++ b/usr/kinit/resume/resumelib.c @@ -77,7 +77,7 @@ int resume(const char *resume_file, unsigned long long resume_offset) failure: if (powerfd >= 0) close(powerfd); - fprintf(stderr, "kinit: No resume image, doing normal boot...\n"); + dprintf(stderr, "kinit: No resume image, doing normal boot...\n"); return -1; fail_r: commit 8d38b56e6f2c9dac342df3de919775cc38eba603 Author: Thorsten Glaser <tg at mirbsd.de> Date: Sat Mar 13 19:36:33 2010 +0100 [klibc] add getrusage() we define rusage, but had no way to see this stats. allows to compile mksh against klibc. Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/include/sys/resource.h b/usr/include/sys/resource.h index 41cefb4..5d8bd52 100644 --- a/usr/include/sys/resource.h +++ b/usr/include/sys/resource.h @@ -12,4 +12,6 @@ __extern int getpriority(int, int); __extern int setpriority(int, int, int); +__extern int getrusage(int, struct rusage *); + #endif /* _SYS_RESOURCE_H */ diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def index f81452c..e395119 100644 --- a/usr/klibc/SYSCALLS.def +++ b/usr/klibc/SYSCALLS.def @@ -47,6 +47,7 @@ int execve(const char *, char * const *, char * const *); <alpha,ia64> int getpriority(int, int); <!alpha,ia64> int getpriority::__getpriority(int, int); int setpriority(int, int, int); +int getrusage(int, struct rusage *); int sched_setscheduler(pid_t, int, const struct sched_param *); int sched_yield(); <i386> int prctl at varadic(int, unsigned long, unsigned long, unsigned long, unsigned long);
Thorsten Glaser
2010-Apr-26 11:51 UTC
[klibc] [git pull] small fixes, sh4, getruage() README's
maximilian attems dixit:> allows to compile mksh against klibc.I do not think so:>+__extern int getrusage(int, struct rusage *);This will conflict with the one from the Linux kernel headers, which is STILL defined (at least on my system): /usr/lib/klibc/include/linux/resource.h:int getrusage(struct task_struct *p, int who, struct rusage *ru); There?s also mkstemp() (or tempnam, which is used as fallback but deprecated) still missing, IIRC. //mirabilos -- FWIW, I'm quite impressed with mksh interactively. I thought it was much *much* more bare bones. But it turns out it beats the living hell out of ksh93 in that respect. I'd even consider it for my daily use if I hadn't wasted half my life on my zsh setup. :-) -- Frank Terbeck in #!/bin/mksh
Hi again, I?ve attached a git patch series against maks? repository (the 8d38b56e6f2c9dac342df3de919775cc38eba603 commit is a requirement as well) to allow mksh to build against klibc. There?s still one issue open with regards to signal handling, which I mailed in private to maks in the hope of getting an idea what went wrong (regression between 1.5.15-1 in Debian, with the exact same four patches (above mentioned commit plus the three attached) applied, and 1.5.18-1 in Debian with the four patches applied). Oh well, at least, with this patch series, it compiles? of course, if you favour a different mkstemp() implementation or would rather like the less preferable tempnam(), feel free to do so. The stdio.h diff is required, though. bye, //mirabilos -- FWIW, I'm quite impressed with mksh interactively. I thought it was much *much* more bare bones. But it turns out it beats the living hell out of ksh93 in that respect. I'd even consider it for my daily use if I hadn't wasted half my life on my zsh setup. :-) -- Frank Terbeck in #!/bin/mksh -------------- next part --------------