博文

目前显示的是 七月, 2011的博文

通过简单的例子,学习systemtap

看例子先!  怎样遍历数组: 1.  # 2.  # Print the system call count by process name in descending order. 3.  # 4. 5.  global syscalls 6. 7.  probe begin { 8.     print ("Collecting data... Type Ctrl-C to exit and display results\n") 9.  } 10. 11. probe syscall.* { 12.    syscalls[execname()]++ 13. } 14. 15. probe end { 16.    printf ("%-10s %-s\n", "#SysCalls", "Process Name") 17.    foreach (proc in syscalls-) 18.       printf("%-10d %-s\n", syscalls[proc], proc) 19. }   这中间,比较难理解的是第17行,那么它的解释如下: The variable proc is an index variable that iterates over the range of values possible for the array index of syscalls. Also note the en dash (-) after syscalls that denotes that the iteration runs in reverse order. This character ensures that the number of system calls made print in descending order. To print in ascending order, change the script tosyscalls+. --------------------------------------------------------------------  

外网主机ssh和vnc访问内网主机

之前,孤陋寡闻,以为外网访问内网纯属扯淡!早上开shlug的邮件列表,看到这个thread。实验了一下,夷~,竟然可以。太棒了! 外网通过ssh访问内网的方法: $ ssh -f -N -R 7070: 127.0.0.1:22  外网主机用户名@外网主机ip $ ssh 内网主机用户名@ 127.0.0.1  -p 7070 原理:将外网7070的端口映射到内网主机的22端口 外网通过VNC访问内网的方法: 同ssh访问的方法一样,我们还可以使用VNC服务: 在内网主机上安装好VNC,然后,开启一个session(默认的端口是从5900开始的) 在内网主机操作: $vnc4server :1 $vnc4passwd //设定VNC连接密码 $ssh -f -N -R 1234: 127.0.0.1:5901  外网主机用户名@外网主机ip 好,已经将5901绑定到外网主机的1234端口了。 然后,操作外网主机: 在外网主机菜单Applications->Internet->Remote Desktop Viewer 选择VNC协议,填入 127.0.0.1:1234 然后, 会要求输入密码,就是内网主机通过vnc4passwd设定的密码了。 OK啦~

__copy_user_zeroing

2.6内核和2.4相比,又加入了一个异常修复地址 #define __copy_user_zeroing(to,from,size)               \ do {                                   \    int __d0, __d1, __d2;                       \    __asm__ __volatile__(                       \        "   cmp $7,%0\n"                   \        "   jbe  1f \n"                   \        "   movl %1,%0\n"                   \        "   negl %0\n"                   \        "   andl $7,%0\n"                   \        "   subl %0,%3\n"                   \        "4:   rep; movsb\n"                   \        "   movl %3,%0\n"                   \        "   shrl $2,%0\n"                   \        "   andl $3,%3\n"                   \        "   .align 2,0x90\n"               \        "0:   rep; movsl\n"                   \        "   movl %3,%0\n"                   \        "1:   rep; movsb\n"                   \也是字节数   

看例子,学Systemtap

看例子先! 例子 : 怎样遍历数组: 1. # 2. # Print the system call count by process name in descending order. 3. # 4. 5. global syscalls 6. 7. probe begin { 8. print ("Collecting data... Type Ctrl-C to exit and display results\n") 9. } 10. 11. probe syscall.* { 12. syscalls[execname()]++ 13. } 14. 15. probe end { 16. printf ("%-10s %-s\n", "#SysCalls", "Process Name") 17. foreach (proc in syscalls-) 18. printf("%-10d %-s\n", syscalls[proc], proc) 19. } 这中间,比较难理解的是第17行,那么它的解释如下: The variable  proc  is an index variable that iterates over the range of values possible for the array index of  syscalls . Also note the en dash (-) after  syscalls  that denotes that the iteration runs in reverse order. This character ensures that the number of system calls made print in descending order. To print in ascending order, change the script to syscalls+ . ------------------------------ ------------------------------ -----