[uml-devel] Re: [uml-user] 2.6.13 / cannot set up LDT for thread-local storage
On 9/13/05, Blaisorblade [EMAIL PROTECTED] wrote: (cut) What should I try? Do I need a patch? mv /lib/tls /lib/tls.away, after loop-mounting the filesystem on the host , or booting with init=/bin/bash (not sure the second will work). I did some tests. I just found out that In Debian the best solution is to run: # echo LD_ASSUME_KERNEL=2.4.1 etc/environment in the chroot. (See http://people.redhat.com/drepper/assumekernel.html) I found something in this thread: http://lists.debian.org/debian-user/2005/01/msg04226.html --- --- Todd A. Jacobs [EMAIL PROTECTED] wrote: On Fri, Jan 28, 2005 at 10:43:44PM -0500, [EMAIL PROTECTED] wrote: Is the file /etc/environment _documented_ *anywhere*??? It's a highly non-standard, non-portable file that is source by PAM (and possibly other applications) on a Debian system. That is as maybe, but /etc/environment is the only shell-agnostic file there is, and where it can be used, it certainly serves a good purpose. --- I did 2 equivalent tests 1) patching init/main.c to add the variable to the environment 2) using a wrapper to /sbin/init but it seems the environment is just discarded before running what is in inittab (I'm not sure, I should read the sources later). sysvinit should have a way to add a variable to the environment. Can it be done in intitab? With : cd /etc grep /etc/environment * -RH 2/dev/null Among others, I found pam.d/login # This module parses /etc/environment (the standard for setting # environ vars) and also allows you to use an extended config - Do they mean standard in Debian? BTW, - when is NPTL (not) supported in UML? I'm sending for your consideration a small patch for the FAQ (that may need some update. I'll do it as I learn more about this issue). Thanks, Nelson.- -- Homepage : http://geocities.com/arhuaco The first principle is that you must not fool yourself and you are the easiest person to fool. -- Richard Feynman. 538a539,589 a name=kernel Panic, cannot set up thread-local storage/table width=100% bgcolor=#e0e0e0 tr td b font color=blackkernel Panic, cannot set up thread-local storage/font /b /td /tr /table blockquote Your UML kernel doesn't support Native Posix Thread Library and the binaries you're running are being dynamically linked to the NTPL libraries. brbr You can boot moving the NTPL libraries away. ul li font color=black# mount root_fs mnt-uml/ -o loop/font li font color=black# mv mnt-uml/lib/tls mnt-uml/lib/tls.away/font li font color=black# umount mnt-uml/font /ul If you're running Debian, you can get away with: prefont color=black # mount root_fs mnt-uml/ -o loop # echo LD_ASSUME_KERNEL=2.4.1 /mnt-uml/etc/environment # umount mnt-uml/ /font/pre It seems that using /etc/environment is Debian specific, as a href=http://lists.debian.org/debian-user/2005/01/msg04226.html;discussed here/a. The LD_ASSUME_KERNEL=2.4.1 environment variable precludes the dynamic linker from using the NTPL libraries, as explained a href=http://people.redhat.com/drepper/assumekernel.html;here/a. If you decide to move away /lib/tls/ and you're running Debian, you might prefer to use dpkg-divert. prefont color=black # export LD_ASSUME_KERNEL=2.4.1 # mount root_fs mnt-uml/ -o loop # chroot mnt-uml # mkdir /lib/tls.off # cd /lib/tls # pwd # for f in *; do dpkg-divert --divert --local --rename --divert /lib/tls.off/$f --add /lib/tls/$f; done # exit # umount mnt-uml /font/pre /blockquote
[uml-devel] Re: [uml-user] 2.6.13 / cannot set up LDT for thread-local storage
On 9/16/05, Nelson Castillo [EMAIL PROTECTED] wrote: On 9/13/05, Blaisorblade [EMAIL PROTECTED] wrote: sysvinit should have a way to add a variable to the environment. Can it be done in intitab? I just fixed the patch for the FAQ. It's much simpler (and correct, I hope) now. - I tried with the patched init/main.c and: inittab: 1:2345:respawn:/usr/bin/env LD_ASSUME_KERNEL=2.4.1 /sbin/getty 38400 tty1 (w/o the LD_ASSUME_KERNEL=2.4.1 the entry in /etc/environment). And it dies just after I log in, but I don't get a panic, just another password prompt. So I guess it's bash who is not taking the environment that /sbin/init sets... And that's why things work when I set the variable in /etc/environment (and also send a modified environment to /sbin/init with LD_ASSUME_KERNEL=2.4.1. You must do both, I said that setting /etc/environment was enough in my previous email and I was quite wrong. Sorry). Regards. -- Homepage : http://geocities.com/arhuaco The first principle is that you must not fool yourself and you are the easiest person to fool. -- Richard Feynman. 538a539,574 a name=kernel Panic, cannot set up thread-local storage/table width=100% bgcolor=#e0e0e0 tr td b font color=blackkernel Panic, cannot set up thread-local storage/font /b /td /tr /table blockquote Your UML kernel doesn't support Native Posix Thread Library and the binaries you're running are being dynamically linked to the NTPL libraries. brbr You can boot moving the NTPL libraries away. ul li font color=black# mount root_fs mnt-uml/ -o loop/font li font color=black# mv mnt-uml/lib/tls mnt-uml/lib/tls.away/font li font color=black# umount mnt-uml/font /ul If you're running Debian, you might prefer to use dpkg-divert. prefont color=black # export LD_ASSUME_KERNEL=2.4.1 # mount root_fs mnt-uml/ -o loop # chroot mnt-uml # mkdir /lib/tls.off # cd /lib/tls # pwd # for f in *; do dpkg-divert --divert --local --rename --divert /lib/tls.off/$f --add /lib/tls/$f; done # exit # umount mnt-uml /font/pre /blockquote
[uml-devel] Using __initcall from um/drivers/chan_kern.c / fun with keyboard
Hi, I'm sending a patch that allows me to query the number of keys pressed by the user (I'll copy [4]). Actually, I'm counting scancodes and some keys send more than one. It works well. -- # cat /proc/keystrokes 29 -- I read [1] and skimmed over [2] and I think I'm using the __init and __initcall macros well, but I get this error when I try to use them: CC arch/um/drivers/chan_kern.o arch/um/drivers/chan_kern.c:111: error: `proc_kst_init' undeclared here (not in a function) arch/um/drivers/chan_kern.c:98: warning: `proc_kts_init' defined but not used make[1]: *** [arch/um/drivers/chan_kern.o] Error 1 make: *** [arch/um/drivers] Error 2 98 : static int __init proc_kts_init(void) 99 : { 111 : __initcall(proc_kst_init); What should I do/try? Can I use these macros in um/drivers/chan_kern.c? Related questions: * Is there a better place to to this in UML? * What would be the right place to do in ix86 (or arch independant)? Blaisorblade told me to it in serio[3], but I don't know where I should put the hooks. I think I can also use drivers/char/keyboard.c [1]http://people.netfilter.org/~rusty/unreliable-guides/kernel-hacking/routines-init-again.html [2]http://geek.vtnet.ca/doc/initcall/review.html [3]http://marc.theaimsgroup.com/?l=user-mode-linux-userm=112827478307626w=2 [4]http://bodq.vstu.edu.ua/activity/data/k.html -- Homepage : http://geocities.com/arhuaco The first principle is that you must not fool yourself and you are the easiest person to fool. -- Richard Feynman. diff -u linux-2.6.13.2.orig/arch/um/drivers/chan_kern.c linux-2.6.13.2/arch/um/drivers/chan_kern.c --- linux-2.6.13.2.orig/arch/um/drivers/chan_kern.c 2005-09-16 20:02:12.0 -0500 +++ linux-2.6.13.2/arch/um/drivers/chan_kern.c 2005-10-03 00:22:14.0 -0500 @@ -19,6 +19,101 @@ #include line.h #include os.h +#define CONFIG_PROC_KSTROKES + +/* + * I'm trying to learn how to intercept keyboard keystrokes in + * Linux. I want to gather some statistics. + * + * For instance, a count of each pressed key (A-Z). I guess I will + * have to do ( counter % 100) on each counter for security reasons. + * + * Arhuaco. Oct 2 / 2005. + */ + +#ifdef CONFIG_PROC_KSTROKES + +#define KST_DEBUG 1 +#define KST_LOG_LEN 32 + +#include linux/seq_file.h +#include linux/proc_fs.h +#include linux/init.h + +/* + * Do we need this to use __init and __initcall? + * #include linux/module.h */ + +unsigned int kst_count = 0; + +#if KST_DEBUG +char kst_log[KST_LOG_LEN]; +int kst_actual = 0; +#endif + +static int proc_kst_show(struct seq_file *m, void *v) +{ + #if KST_DEBUG +int error = 0; +int i; + +error = + #endif + + seq_printf(m, %d\n, kst_count); + + #if KST_DEBUG + + for (i = 0; !error i KST_LOG_LEN; i++) + { +if (i) + error = seq_putc(m, ' '); + +if (!error) + error = seq_printf(m, %x, kst_log[i]); + } + + if (!error) +seq_printf(m, \nactual %d\n, kst_actual); + + #endif + + return 0; +} + +static int proc_kst_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_kst_show, NULL); +} + +static struct file_operations proc_kst_operations = { + .open = proc_kst_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + + +static int /*__init*/ proc_kts_init(void) +{ + struct proc_dir_entry *e; + + e = create_proc_entry(keystrokes, 0, NULL); + + if (e) +e-proc_fops = proc_kst_operations; + else +printk(KERN_ERR chan_kern.c : /proc/keystrokes creation failed \n); + + return 0; +} + +/* __initcall(proc_kst_init); == Make it work */ + +int kst_did_init = 0; + +#endif /* CONFIG_PROC_KSTROKES */ + #ifdef CONFIG_NOCONFIG_CHAN /* The printk's here are wrong because we are complaining that there is no @@ -113,6 +208,22 @@ return(0); else if(n == 0) return(-EIO); + +#ifdef CONFIG_PROC_KSTROKES + kst_count ++; + + if (!kst_did_init) /* TODO: use __initcall */ + { +proc_kts_init(); +kst_did_init = 1; + } + + #if KST_DEBUG +kst_log[kst_actual] = *c_out; +kst_actual = (kst_actual + 1) % KST_LOG_LEN; + #endif +#endif + return(n); } --- linux-2.6.13.2.orig/arch/um/drivers/chan_kern.c 2005-09-16 20:02:12.0 -0500 +++ linux-2.6.13.2/arch/um/drivers/chan_kern.c 2005-10-03 00:57:26.0 -0500 @@ -19,6 +19,99 @@ #include line.h #include os.h +#define CONFIG_PROC_KSTROKES + +/* + * I'm trying to learn how to intercept keyboard keystrokes in + * Linux. I want to gather some statistics. + * + * For instance, a count of each pressed key (A-Z). I guess I will + * have to do ( counter % 100) on each counter for security reasons. + * + * Arhuaco. Oct 2 / 2005. + */ + +#ifdef CONFIG_PROC_KSTROKES + +#define KST_DEBUG 1 +#define KST_LOG_LEN 32 + +#include linux/seq_file.h +#include linux/proc_fs.h +#include linux/init.h + +/* + * Do we need this to use __init and __initcall? + * #include linux/module.h */ +
Re: [uml-devel] Using __initcall from um/drivers/chan_kern.c / fun with keyboard
On 10/3/05, Blaisorblade [EMAIL PROTECTED] wrote: You have a trivial typo. Yup :( Thanks. -- Homepage : http://geocities.com/arhuaco The first principle is that you must not fool yourself and you are the easiest person to fool. -- Richard Feynman. --- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl ___ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel