OpenRAYS

RSS feed PHPWind BLOG
Latest 20 blogs of whole blog
已更新: 1 年 10 週 前

linux下base64加密代码实例 linux下base64加密代码实例

2007, 九月 18 - 21:49
今天用到一个base64加密发现不错,特地列出备忘 #include <iostream> #include <cstdlib> #include "base64.h" using namespace std; int main ( int argc, char *argv[] ) {   cout << "你好,base64加密实现" << endl;   char buf[32]={"alarm"};     char newbuf[128]={0};   base64pwd ( buf,newbuf );   printf ( "buf=%s newbuf=%s\\n",buf,newbuf );   memset ( buf,0,sizeof ( buf ) );   decodepwd ( newbuf,buf );   printf ( "decodepwd buf=%s\\n",buf );   return EXIT_SUCCESS; } -------------------- 另外发现foxmail在linux下用wine方式运行的也很好,值得信赖 foxmail最新版本能够添加过滤起防垃圾邮件超级好,推荐

如何获得BioInfoServOS的软件特性?

2007, 九月 14 - 05:33
有人问,能不能在xubuntu 6.06版本或其延伸版本获得BioInfoServOS软件特性? 现在可以肯定告诉大家,完全没有问题,请[url=http://www.bioinfoserv.org/BioLinux/modules/wordpress/?p=102]查看其具体解决办法[/url] 这个方案已经经过测试,大家放心使用。 值得注意的是,这个方案目前只适合xubuntu 6.06为基础的版本,至于是否能安装到其他ubuntu版本,这不做保证。同时,这与通过BioInfoServOS Live DVD安装获得软件特性没有本质差别,即使的差别,就是改变了软件安装的路径和系统菜单类别的细微变化。

linux练习c源代码(毫秒级计时)

2007, 九月 12 - 19:45
#ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdio.h> #include <stdlib.h> #include <sys/time.h> int main(int argc, char *argv[]) { printf("Hello, world!\\n"); struct timeval tvafter,tvpre; struct timezone tz; int sum = 0;       int i=0; gettimeofday (&tvpre , &tz); for(i = 0; i < 100000000; i++) {      sum += i; }       gettimeofday (&tvafter , &tz); printf("sum=%d 花费时间:%d\\n",sum, (tvafter.tv_sec-tvpre.tv_sec)*1000+(tvafter.tv_usec-tvpre.tv_usec)/1000); return EXIT_SUCCESS; }

发布MIPS Linux 异常中断代码分析文档

2007, 九月 11 - 03:06
以龙芯2E(福珑mini PC平台)为例,详细分析了MIPS Linux 下的异常处理、中断处理、系统调用。 这里下载之: [url]http://people.openrays.org/~comcat/mydoc/mips.linux.inter.pdf[/url]

测试局域网已经使用的ip和mac(linux c 源码)

2007, 九月 7 - 21:55
/*************************************************************************** *   Copyright (C) 2007 by qzc   * *   [email]qzc1998@126.com[/email]   * *                                                 * *   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.         * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdio.h> #include <sys/time.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <netdb.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/ioctl.h> #include <netinet/if_ether.h> #include <netinet/in.h> #include <arpa/inet.h> #include <net/if.h> /* 得到本机的mac地址和ip地址 */ int GetLocalMac ( const char *device,char *mac,char *ip ) {      int sockfd;      struct ifreq req;      struct sockaddr_in * sin;      if ( ( sockfd = socket ( PF_INET,SOCK_DGRAM,0 ) ) ==-1 )      {            fprintf ( stderr,"Sock Error:%s\\n\\a",strerror ( errno ) );            return ( -1 );      }      memset ( &req,0,sizeof ( req ) );      strcpy ( req.ifr_name,device );      if ( ioctl ( sockfd,SIOCGIFHWADDR, ( char * ) &req ) ==-1 )      {            fprintf ( stderr,"ioctl SIOCGIFHWADDR:%s\\n\\a",strerror ( errno ) );            close ( sockfd );            return ( -1 );      }      memcpy ( mac,req.ifr_hwaddr.sa_data,6 );      req.ifr_addr.sa_family = PF_INET;      if ( ioctl ( sockfd,SIOCGIFADDR, ( char * ) &req ) ==-1 )      {            fprintf ( stderr,"ioctl SIOCGIFADDR:%s\\n\\a",strerror ( errno ) );            close ( sockfd );            return ( -1 );      }      sin = ( struct sockaddr_in * ) &req.ifr_addr;      memcpy ( ip, ( char * ) &sin->sin_addr,4 );      return ( 0 ); } char *mac_ntoa ( const unsigned char *mac ) {      /* Linux 下有 ether_ntoa(),不过我们重新写一个也很简单 */      static char buffer[18];      memset ( buffer,0,sizeof ( buffer ) );      sprintf ( buffer,"%02X:%02X:%02X:%02X:%02X:%02X",             mac[0],mac[1],mac[2],mac[3],mac[4],mac[5] );      return ( buffer ); } /* 根据 RFC 0826 修改*/ typedef struct _Ether_pkg Ether_pkg; struct _Ether_pkg {      /* 前面是ethernet头 */      unsigned char ether_dhost[6]; /* 目地硬件地址 */      unsigned char ether_shost[6]; /* 源硬件地址 */      unsigned short int ether_type; /* 网络类型 */      /* 下面是arp协议 */      unsigned short int ar_hrd; /* 硬件地址格式 */      unsigned short int ar_pro; /* 协议地址格式 */      unsigned char ar_hln; /* 硬件地址长度(字节) */      unsigned char ar_pln; /* 协议地址长度(字节) */      unsigned short int ar_op; /* 操作代码 */      unsigned char arp_sha[6]; /* 源硬件地址 */      unsigned char arp_spa[4]; /* 源协议地址 */      unsigned char arp_tha[6]; /* 目地硬件地址 */      unsigned char arp_tpa[4]; /* 目地协议地址 */ }; void parse_ether_package ( const Ether_pkg *pkg ) {      printf ( "源   IP=[%s] MAC=[%s]\\n",inet_ntoa ( * ( struct in_addr * ) pkg->arp_spa ),mac_ntoa ( pkg->arp_sha ) );      printf ( "目地 IP=[%s] MAC=[%s]\\n",inet_ntoa ( * ( struct in_addr * ) pkg->arp_tpa ),mac_ntoa ( pkg->arp_tha ) ); } int sendpkg ( char * mac,char * broad_mac,char * ip,char * dest ) {      Ether_pkg pkg;      struct hostent *host =NULL;      struct sockaddr sa;      int sockfd,len;      char buffer[255];      memset ( ( char * ) &pkg,'\\0',sizeof ( pkg ) );      /* 填充ethernet包文 */      memcpy ( ( char * ) pkg.ether_shost, ( char * ) mac,6 );      memcpy ( ( char * ) pkg.ether_dhost, ( char * ) broad_mac,6 );      pkg.ether_type = htons ( ETHERTYPE_ARP );      /* 下面填充arp包文 */      pkg.ar_hrd = htons ( ARPHRD_ETHER );      pkg.ar_pro = htons ( ETHERTYPE_IP );      pkg.ar_hln = 6;      pkg.ar_pln = 4;      pkg.ar_op = htons ( ARPOP_REQUEST );      memcpy ( ( char * ) pkg.arp_sha, ( char * ) mac,6 );      memcpy ( ( char * ) pkg.arp_spa, ( char * ) ip,4 );      memcpy ( ( char * ) pkg.arp_tha, ( char * ) broad_mac,6 );      //printf ( "Resolve [%s],Please Waiting...",dest );      fflush ( stdout );      memset ( ip,0,sizeof ( ip ) );      if ( inet_aton ( dest, ( struct in_addr * ) ip ) ==0 )      {            if ( ( host = gethostbyname ( dest ) ) ==NULL )            {                  fprintf ( stderr,"Fail! %s\\n\\a",hstrerror ( h_errno ) );                  return ( -1 );            }            memcpy ( ( char * ) ip,host->h_addr,4 );      }      //printf ( " Done!\\n" );      memcpy ( ( char * ) pkg.arp_tpa, ( char * ) ip,4 );      /* 实际应该使用PF_PACKET */      if ( ( sockfd = socket ( PF_INET,SOCK_PACKET,htons ( ETH_P_ALL ) ) ) ==-1 )      {            fprintf ( stderr,"Socket Error:%s\\n\\a",strerror ( errno ) );            return ( 0 );      }      memset ( &sa,'\\0',sizeof ( sa ) );      strcpy ( sa.sa_data,"eth0" );      len = sendto ( sockfd,&pkg,sizeof ( pkg ),0,&sa,sizeof ( sa ) );      if ( len != sizeof ( pkg ) )      {            fprintf ( stderr,"Sendto Error:%s\\n\\a",strerror ( errno ) );            return ( 0 );      }      Ether_pkg *parse;      parse = ( Ether_pkg * ) buffer;      fd_set readfds;      struct timeval tv;      tv.tv_sec = 0;      tv.tv_usec = 500000; //500毫秒      FD_ZERO ( &readfds );      FD_SET ( sockfd, &readfds );      len = select ( sockfd+1, &readfds, 0, 0, &tv );      if ( len>-1 )      {            if ( FD_ISSET ( sockfd,&readfds ) )            {                  memset ( buffer,0,sizeof ( buffer ) );                  len=recvfrom ( sockfd,buffer,sizeof ( buffer ),0,NULL,&len );                  if ( ( ntohs ( parse->ether_type ) ==ETHERTYPE_ARP ) &&                       ( ntohs ( parse->ar_op ) == ARPOP_REPLY ) )                  {                        parse_ether_package ( parse );                                          }            }      }      return 1; } int main ( int argc,char **argv ) {      struct timeval tvafter,tvpre;      struct timezone tz;      gettimeofday ( &tvpre , &tz );      unsigned char mac[7];      unsigned char ip[5];      char dest[16]={0};      unsigned char broad_mac[7]={0xff,0xff,0xff,0xff,0xff,0xff,0x00};      memset ( mac,0,sizeof ( mac ) );      memset ( ip,0,sizeof ( ip ) );      if ( GetLocalMac ( "eth0",mac,ip ) ==-1 )            return ( -1 );      printf ( "本地 Mac=[%s] Ip=[%s]\\n", mac_ntoa ( mac ),inet_ntoa ( * ( struct in_addr * ) ip ) );      //if ( argc==1 ) return ( -1 );      sprintf ( dest,"192.168.1.%d",199 );      uint32_t dip= inet_addr("192.168.1.161");      sendpkg ( mac,broad_mac,(char * )&dip,dest );      //int i=0;      //for(i=1;i<256;i++){      //sprintf ( dest,"192.168.1.%d",i );      //sendpkg ( mac,broad_mac,ip,dest );      //}      gettimeofday ( &tvafter , &tz );      printf ( "\\n程序执行完毕:%d毫秒\\n", ( tvafter.tv_sec-tvpre.tv_sec ) *1000+ ( tvafter.tv_usec-tvpre.tv_usec ) /1000 );      return 0; }

FULONG MINI-PC Architecture

2007, 九月 5 - 00:47
see figure: [p_w_upload=102]

休闲时间不学习,要学就学易飞扬

2007, 八月 27 - 21:28
linux下面ef文件编译的快捷通道 易语言飞扬版本现在已经有1.1.0测试版,在linux也可以中英文混合代码编程,用kwrite写好代码,使用易语言的ec编译文件,敲入一串编译命令,就可编译出可执行文件。但是我懒得敲这么一长串字符,就在这里做了一个快捷通道,右键点击易飞扬源代码文件(后缀名ef),选择打开方式-->编译ef文件,就可以编译出文件。 使用方法:在everest linux下解包,用虚拟终端输入命令./install,环境就好了 下载: [url]http://www.linux-ren.org/modules/softstorage/show.php?content=165[/url]

Linus Torvalds talks future of Linux

2007, 八月 27 - 21:22
Linus Torvalds talks future of Linux ([url]http://apcstart.com/7012/linus_torvalds_talks_about[/url])


Linus Torvalds, creator of the Linux kernel, has, along with others like Richard Stallman, literally changed the world of software forever.

Linux-based distributions seem to pop up every day, while more and more devices now run Linux at their core, from mobile phones to inflight entertainment systems, to the world\'s mission critical server infrastructures.

The development of the kernel has changed, and Linux is just getting better and better. However, with a community as large and fractured as the Linux community, it can sometimes be hard to get a big picture overview of where Linux is going: what\'s happening with kernel version 2.6? Will there be a version 3.0? What has Linus been up to lately? What does he get up to in his spare time?

I had the opportunity to chat with Linus Torvalds, in a number of email exchanges.

APC: Writing an operating system kernel is a hard job. Why did you write Linux in the first place?

LT: Kernels may be hard, but partly because of that they are also interesting. I\'ve always been more interested in "down to the hardware" details than in fluffy stuff like user interfaces etc, and an operating system kernel is about as down to the hardware as you can get without actually building it yourself (which I\'ve also done - I was at a CPU company for seven years, after all). So I\'m not into soldering irons etc, but I very much enjoy working at a low level, and thinking about how my software actually interacts with the CPU and other parts of the system. Besides, I really didn\'t realize how hard it would be. I really never expected to be still working on it 15+ years later ;)

 

APC: What\'s the Linux Foundation?

LT: Heh. I just work here, you should ask some of the people who are actually involved in all the other things that LF does. It\'s basically the combination of OSDL ("Open Source Development Labs") and FSG ("Free Standards Group"), and is a vendor-neutral place for different organizations to discuss the issues they have, and trying to help Linux along. Part of what LF does is pay me to maintain the kernel.

APC: What are you doing with the kernel now? Are you working on it full time? What parts of it do you work on the most?

LT: I very much work on it full time, but I no longer really work on any particular "part"of it - I end up spending almost all my time on not writing kernel code myself, but on working with the flow of code and merging it all.

In fact, the biggest amount of actual source code I\'ve written in the last two years is not in the kernel itself, but in the tool I use to just track the kernel development (called "git" - a source control management system).

So I still get to write code (and I send out suggested patches quite often - but usually they are along the lines of "so here\'s how we could handle this issue..." in order to prod others to actually do the final patch and testing). But what I do a lot more is go through other peoples changes and say "yes" or "no".

APC: The 2.6 series kernel has been around for a long time. Why?

LT: We used to have these big and painful development releases that took several years, and it worked reasonably well and people got very used to it ("2.<even> is stable, 2.<odd> is development"), but it had serious downsides too.

In particular, the release cycles were so long that all the commercial vendors effectively had to back-port a fair amount of new code from the development kernels, and so development code ended up in the stable releases. Also, conversely, the vendors fixed problems in the stable versions, and sometimes the fixes were missed or weren\'t easy to then forward-port to the development series, because the two were just very far apart.

Basically, a multi-year development cycle simply doesn\'t work. It was reasonable and required for a while (we did some pretty radical changes there too), but with 2.6, the base kernel is in good shape, and we\'ve improved our development process enough that we just don\'t have any pressing reason to go back to that kind of "everything changes" model.

So instead of having two or three years between stable releases, we now have two or three months. Which means that the vendor kernels are much closer to the development kernels, and avoids a lot of the problems we used to have. Everybody is happier.

So we\'ll probably stay with that model unless something really radical happens, and that means that we\'ll keep with the "2.6.x" codebase, and just incrementally improve on it.

Of course, if we had a marketing department that had a strong say, they\'d make us call it some sexy name ("Panther" or "Vista" or whatever), but as it is, the technical people are in charge of version names, and the sexy naming is up to the distribution makers that can call their offerings whatever they want ("Fedora" or "Feisty Fawn").


APC: When do you expect to see a kernel version 3.0? What will be the major changes or differences from the 2.6 series?

LT: We really don\'t expect to need to go to a 3.0.x version at all: we\'ve been very good at introducing even pretty big new features without impacting the code-base in a disruptive manner, and without breaking any old functionality.

That, together with the aforementioned lack of a marketing department that says "You have to increase the version number to show how good you are!" just means that we tend to just improve everything we can, but you\'re not likely to see a big "Get the new-and-improved version 3!" campaign.

APC: There doesn\'t seem to be a Linus kernel anymore and an experimental (e.g. Alan Cox kernel, etc) anymore. Is this true? If so, is it because you have the 2.6 series pretty much exactly where you want it?

LT: Well, part of it may be that we\'ve gotten better at handling the code flow issues, and so maybe there\'s less reason for various experimental kernels. That said, there\'s still the -mm tree (Andrew Morton\'s kernel) where a lot of new code goes first. It\'s maybe less about "experimental" than about "a first testing ground before merging into Linus\' tree", but that\'s not so different from what -ac (Alan Cox\'s tree) was about.

And there are still a lot of specialized trees for specific things. In fact, it\'s one of the things I wanted git to make easier to do, and if you want to follow network driver development before it gets merged into my tree, there are trees for that, and for sound drivers etc etc.

But I do think that part of it is that over the years we\'ve found what works, and that the current development model is reasonably good.

That said, I\'m sure we\'ll eventually hit some issue that gets peoples blood boiling, and we\'ll have a tree for some changes that I don\'t think are appropriate and am not willing to merge, and that\'s as it should be: unlike a lot of other open source projects, I\'ve always encouraged people to try their hand at forking off a kernel project of their own to scratch their own itch.

So I don\'t think such project forks are bad at all, it\'s how a lot of development is done. Obviously, most development is about "micro-forks" and people don\'t even think of them as real forks at all, but I actually think it\'s good to encourage experimentation - and by keeping it friendly, if some experimental kernel shows that it was actually the right direction, we don\'t end up having psychological road-blocks to switching over or to merging the code...

May the best code win.

APC: Do you think Linux has had an impact on computing in the past decade? If so, what stands out the most?

LT: I think Linux has affected the OS landscape a lot, but even more than that, I think Linux was instrumental in making the whole issue of Open Source move into the mainstream software development consciousness.

There had certainly been Open Source projects before Linux, but Linux was big and successful, and actually changed how people viewed them. Part of that was that Linux took a lot more pragmatic approach to what used to be called "Free Software" (and is still called that by some), and moved it from being a fringe and sometimes pretty extreme ideology to be something that was just "technically better".

And I\'ll certainly take some of the credit for that personally. I dislike the frothing-at-the-mouth ideology (to me, ideology should be something personal, not something you push on other people) and I think it\'s much more interesting to see how Open Source actually generates a better process for doing complex technology, than push the "freedom" angle and push an ideology.

And I think that pragmatic approach was what made Linux and Open Source also much more palatable to many more people, and helped make it mainstream.

APC: For those eager to make their first contribution to the kernel and have it accepted, what would your recommendations be? (Any areas that need help more than others, any good books for kernel hackers; however you\'d like to interpret this question).

LT: It\'s hard to give advice, because it\'s different for different people. The big thing is to not think too big - you don\'t start out by rewriting some subsystem. Start out with some small annoyance, and see if you can fix it. And do something you\'re really interested in - kernel programming is easily complex enough that if you\'re not really interested, you\'ll lose your motivation before you really get anywhere.

Note from James: I recommend you first read "Linux Kernel Development" 2nd Edition by Robert Love, published by Novell Press, ISBN 0672327201. Written by a professional Linux developer and "insider," it focuses on the 2.6 series kernels. This book gives you the essential "big picture" before plunging you into mind-boggling details.

APC: Out of curiosity, do you have anything to say to hardware manufacturers who refuse to release datasheets or specifications about the functioning of their hardware so it could operate with the Linux kernel?

LT: Is "I hope you all die a painful death" too strong?

The good news is that a lot of hw manufacturers are actually doing the right thing. Intel in particular has improved wrt open source a lot, and for that reason I tend to suggest that when buying a machine, just make sure that you buy one with Intel graphics and wireless. That takes care of the two biggest annoyances right there.

But Intel certainly isn\'t the only one, and we\'re doing fairly well in general - with just a few dark spots.

APC: You\'ve made an enormous contribution to community service and to the lives of countless people with Linux. People in third-world countries are donating old or second hand machines, and Linux distributions are free of charge and come with sometimes tens of thousands of free programs. Is there anything else about Linux you are really proud of?

LT: Actually, I\'m not all that proud of the "community service" and "third-world countries are using Linux". Simply because it wasn\'t really what I was aiming for. So that feels like a great bonus, but it\'s not something I see myself patting myself on the back for. The credit for that goes to a lot of other people.

So the thing I tend to be personally proud over is just the fact that I\'ve had the tenacity to "just do it" for over fifteen years, and that Linux has fostered a culture of good open source technology. I\'m proud of a lot of the technology too, of course.

APC: You said you were proud of the technology. What do you mean by this - something like better memory management algorithms than those in commercial UnixTM kernels, better flow of control in a complex process like a kernel?

LT: I think we have tons of areas where we\'re just better than anybody else. We handle portability better, we handle the development process better, and yes, we also end up having better memory management and a better filesystem layer than anybody else.

So there\'s tons of things on the technical side that I\'m really proud of how we handle. And hey, I\'m obviously biased, and some people will disagree on any particular feature, but that\'s what makes things interesting.

APC: Before you wrote the kernel, you wrote a clone of Pacman. Do you play games at all and if you do, which ones?

LT: I don\'t games that much, I don\'t tend to find it interesting enough. And when I do play, I tend to play things that are more kids or teenager games: more of a "platformer" kind of thing. I played the original Prince of Persia a long time ago before I started Linux, and for that reason I tried out the modern versions, and liked those too ("Sands of Time" in particular, the later ones were a bit too serious).

APC: Would you write another game if you had the time? If yes, what would it be? Do you have a favourite type of game, such as adventure?

LT: I really only wrote some (fairly bad) games because I was interested in the programming, not so much the playing. I found it more interesting to just do flicker-free graphics at high performance than the actual game-play.

So no, I\'d probably never do a game again. Especially in these times, when games are a lot more about the content, and less about the things I used to worry about.

APC: What do you like to do in your spare time? Do you have any particular hobbies or interests outside of computing?

LT: I spend a lot of time at the computer. But I\'m writing this one-handed, because our puppy is sitting in my lap right now. And when not at the computer or with the family, I tend to read a lot.

APC: What books do you like reading, and what have you read over the past few months?

LT: I read mostly just random pocket-books - horror, sci-fi, fantasy, thrillers, you name it. I tend to not really remember the books, it\'s not like I read them because they leave a lasting impression...

The more serious stuff I read tends to be biology and especially genetics. Richard Dawkins was a big hero of mine even before he became an internet cult figure - I really enjoyed his The Selfish Gene (and I find his books on evolution more interesting than "The God Delusion", even if his atheist worldview is perhaps what he\'s now most famous for - probably because I just find genetics more interesting than religion ;)

APC: You like to use your computer, as you said. Aside from writing kernel code, what do you like to do on your computer?

LT: These days, most of the time I write less kernel code than I write code for git, and in fact for the last year, even that has no longer been a full time job. What I really end up doing most of the time is just communicating. Reading emails, forwarding them, writing replies...

And reading other peoples patches (and bug-reports - most of them never get elevated to "let\'s bring Linus into this", but it happens often enough that I end up being personally involved enough with some regression most days..)

And that really does fill my computer time. I waste time browsing the web when I\'m bored, of course, and I have my classic rock going on random selection in the back-ground, but what I do most of the time is literally revolving around email and the kernel.

APC: Do you use a specific distribution of Linux at home or work?

LT: A "specific" one? No. I have changed distributions over the years, and it tends to really end up depending on various random circumstances, like just when I switch machines around and what happens to be convenient.

So right now I happen to run Fedora on my machines, which largely came about from me running on POWER for a few years, and Fedora supported it pretty well (and since I actually don\'t care that deeply about the distribution, I tend to prefer running the same thing on everything, just to keep any distro issues away).

Before Fedora had PowerPC support, I ran YDL for a while, and before that I had SuSE. Funnily enough, the only distributions I tend to refuse to touch are the "technical" ones, so I\'ve never run Debian, because as far as I\'m concerned, the whole and only point of a distribution is to make it easy to install (so that I can then get to the part I care about, namely the kernel), so Debian or one of the "compile everything by hand" ones simply weren\'t interesting to me.

APC: What software do you use everyday? Your browser, desktop (if any), email client and so on?

LT: Well, ignoring the actual development stuff (make, compiler, editor etc), it ends up being mostly just xterms and "alpine" (the newer version of the venerable old "pine" email reader. Strictly text-based, thank you very much).

And yes, a browser is mostly open in the background. There\'s a few technical discussion forums I\'m active on when I have nothing better to do (or when I do have better things to do but get frustrated with them ;) , and then the normal "random" sites (boing boing etc).

APC: You\'ve worked on Linux for 15+ years. Do you think you\'ll ever stop working on it? If you did, what do you think you\'d do?

LT: "Ever" is a long, long time. I didn\'t expect it to end up being 15+ years when I started, and I still don\'t really have any plan on what I\'ll do in the future. But one reason I\'ve done it for 15+ years is that I like concentrating on something, and don\'t like flittering from one project to another. And I simply like doing Linux.

So no, I\'m not planning on ever stopping working on it, but maybe some day somebody better simply comes along, and I certainly hope I\'ll just have the good grace to realize when I\'m simply not needed any more and not adding anything to it.

APC: You\'ve been to Australia, and rumour has it that you were bitten by a penguin. Is that true? How did you find Australia, how many times have you been there, any favourite town or city? Was there any kind of activity like bush-walking and things like that which you really took to in Australia?

LT: I\'ve been to Australia several times, these days mostly for Linux.Conf.Au. But my first trip - and the one when I was bitten by a ferocious fairy penguin: you really should keep those things locked up! - was in 93 or so, talking about Linux for the Australian Unix Users Group.

And I\'d never go bush walking. Not that I mind the idea of poisonous animals (or the drop-bears), but simply because I\'m just not into that whole outdoor thing. I tend to go to zoos, and I love walking around the strange creatures you have down there, but let\'s face it - one of the biggest draws is that it\'s warm and sunny there when it\'s nasty and horrible in the northern hemisphere. I\'m from Finland, so "warm and sunny" means more to me than it may do to some other people.

One of these days I hope to find myself on the Great Barrier Reef and do scuba diving (which I love), but for some reason I\'ve always ended up in other parts.

APC. Thank you Linus. Linuxus Victa! (Heh!)

Recommended reading for how Linus\' terminal emulator ended up a kernel in glorious technical detail: Just For Fun: The Story of an Accidental Revolutionary , by Linus Torvalds with David Diamond. TEXERE Publishing Ltd. ISBN 1587990806.This particular chapter also pretty much details how to write a kernel and how he did it. The book also contains a lot of extra interesting information on Linus and his background.

APC Interviewer, James Buchanan, is an Australian programmer, writer and cartoonist.


flex接收参数的困惑解答

2007, 八月 14 - 22:53
在html页面的object增加 <param name="flashVars" value="val1=9&val2=8&val3=7&val4=6&val5=5&val6=4&val7=3" /> 或者在 <embed 增加 flashVars="val1=9&val2=8&val3=7&val4=6&val5=5&val6=4&val7=3" 但如果是flexbuilder调试,需要修改 javascript的 AC_FL_RunContent "flashvars",'historyUrl=history.htm%3F&lconid=' + lc_id + '' 这一行 mxml页面脚本可这样使用 private var val1: String = "0"; public function funInit():void//       {                        val1=root.loaderInfo.parameters["val1"].toString(); } 有一条千万注意 刚开始我把funInit放在application的creationComplete执行,总是报错 后来几次折腾才明白应该放在applicationComplete

字体更换后的系统变慢解决方法

2007, 八月 10 - 00:43
今日使用了RAYS 2.0 RC1 版本,很清新,很喜欢。 但是自己不知怎么想的,想使用雅黑的字体。于是自己瞎搞了一会儿,结果系统无比的变慢。 使用这个重新刷新字体, [code]sudo fc-cache -v -f[/code] 结果出错,依旧很慢。 [code]sudo find /usr/share/fonts /usr/local/share/fonts /var/lib/defoma/fontconfig.d -type d -print0 | xargs --null touch[/code] 这句话,可以解决这个问题。 然后运行 [code]sudo fc-cache -v -f[/code] 搞定

RAYS 2.0 RC1 将于8月8日发布

2007, 八月 3 - 20:09
最近一直在测试系统,确保系统的稳定性,因此,baihong rc1的发布略微推迟了一周左右。 下周二是8月8日,数字比较吉利,就暂定该日发布rc1了。

常熟和无锡热死了,据说南京正在暴雨?

2007, 七月 26 - 00:09
今天来又到了无锡和常熟来了。特别是常熟龙芯基地,这已经是本月第二次来了,不巧的是,正入中伏,常熟和无锡两个地方都暴晒的不得了,巧的是躲过了南京的暴雨。

java连接sqlserver(jdbc2005)

2007, 七月 25 - 18:22
注意,jdbc2000的有bug,不能执行含有sum()之类的聚合函数的sql语句 链接的语句也不一样了,下面是示例代码 public int linkserver(){     int k=0;     try {         //Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");//2000         Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");//2005               //String url="jdbc:microsoft:sqlserver://192.168.1.204:1433;DatabaseName=simdb236x";         String url="jdbc:sqlserver://192.168.1.204:1433;DatabaseName=simdb236x";//2005             String uid="sa";         String password="spider";         try {           // conn=DriverManager.getConnection(url,uid,password);//2000           conn=DriverManager.getConnection(url+";user="+uid+";password="+password);//2005           stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);           rs=stmt.executeQuery("select sum(charge) as sumc from CDR20070602");           if(rs!=null) {             rs.last();             if(rs.getRow()>0){                 rs.first();                 logger.debug( "charge=" +rs.getString("sumc") ) ;                 //k=Integer.parseInt();             }           }         } catch (SQLException ex) {           ex.printStackTrace();           k=1;         }     } catch (ClassNotFoundException ex) {         ex.printStackTrace();         k=2;     }     return k;   } ----------------- 顺便记2条小事; 有一个jsp页面,我在onload页面让某个text取得焦点,这个页面还有下拉框,在firefox我改变下拉框选择项时总是失败,因为页面好像刷新焦点回到text了,ie浏览器就没问题,没办法只好在javascript里加个变量,设置焦点同时改变变量,解决问题 某天不知怎么机器重启要检查d盘,停在0%处半天没反应,win98的dos启动scandisk扫了一下,还是不行,最后只好用重装系统(xp)的磁盘检查解决了问题

开始制作BioInfoServOS的英文站点

2007, 七月 24 - 08:50
以前一直都计划制作一个英文站点,以英文发布BioInfoServOS的信息。终于今天开工了,风格采用imago03,并修改确定下来,感觉还不错。有兴趣的,请大家前去浏览,顺便帮我指出其中可能的英文错误和不地道的英文表达。 [url]http://www.bioinfoserv.org/en[/url] 当然这个英文站点,在原来的站点首页有相应的连接。这样以来,尽量将两个不同语言的站点专门化,尽量避免中文和英语表达语言的混用。

RISC 下的非对齐访问问题

2007, 七月 24 - 01:43
1. 问题 RISC 下使用访存指令读取或写入数据单元时,目标地址必须是所访问之数据单元字节数的整数倍,这个叫做地址对齐。 比如在 MIPS 平台上,lh 读取一个半字时,存储器的地址必须是 2 的整数倍; lw 读取一个字时,存储器的地址必须是 4的整数倍; sd 写入一个双字时,存储器的地址必须是 8 的整数倍。倘若访存时,目标地址不对齐,则会引起异常,典型的是系统提示“总线错误”后,直接杀死进程。 看一个测试程序(龙芯2E平台): #include <stdio.h> #include <sys/sysmips.h> unsigned short data[] = {   0x1, 0x2, 0x3, 0x4,   0x55aa, 0x66bb, 0x77cc, 0x0000, }; inline void unaligned_access(unsigned short * const row) {   asm volatile     (         ".set mips3\\n\\t"         ".set noreorder\\n\\t"         //"lwr $10, 1(%1)\\n\\t"         //"lwl $11, 4(%1)\\n\\t"         //"or $10, $11\\n\\t"         "ld $10, 2(%1)\\n\\t"     /* %1 is double word aligned, %1+2 is double word unaligned */         "sd $10, %0\\n\\t"         ".set reorder\\n\\t"         ".set mips0\\n\\t"         : "=m"(*(row))         : "r"(row+4)         : "$8", "$9", "$10"     ); } int main() {   printf("---------------------------------------------------------\\n");   printf(" Testing Godson2 unaligned access Instruction \\n");   printf("---------------------------------------------------------\\n\\n"); // sysmips(MIPS_FIXADE, 0);   unaligned_access(data);   printf("result is: 0x%04x %04x %04x %04x\\n", data[3], data[2], data[1], data[0]); } 程序运行后系统提示“非法指令”后退出。 CISC 下(如x86)访存时,如果目标地址不对齐,CPU 不会陷入异常,因为其内部有处理非对齐访问的微程序。 2. 解决 高级语言中一般不会遇到这种问题,编译器常常会处理好数据类型的对齐。但万一遇到、抑或在汇编里遇到,避不开怎么办? 可以使用 MIPS 的指令集里提供的 lwr/lwl, swr/srl, ldr/ldl, sdr/sdl 指令对。关于他们的原理可以用下图来简单的示意一下(以ldr/ldl 为例,其他类似): 上图解释的是小端模式下的情况,大端模式的情况则相反首先 ldl t0, 0(t1),然后再 ldr t0, 7(t1)。 可以看到无论大端模式还是小端模式,非对齐访问的解决都是将原来的一条指令(对齐访问)完成的事分两步完成,即首先取始地址 addr 到下一个对齐地址处的部分数据,置入寄存器右部(小端),(大端置入左部(高位)),然后取从该对齐地址到 addr + len - 1 处的部分数据(len 为数据单元长度,半字为2, 双字为8),置入寄存器左部(小端)。 如小端机器上,始地址为 t1 = 0x1022,则: ldr t0, 0(t1) 取 0x1022~0x1027 到 t0 的右部 ldl   t0, 7(t1) 取 0x1028~0x1029 到 t0 的左部

要去龙芯产业化基地参观喽

2007, 七月 22 - 02:51
下周一晚上的火车,去梦兰集团龙芯产业化基地参观3天,兴奋啊。 或许是离计算所近的缘故吧,胡老师关于龙芯的讲座我可是都没落下。真不知道自己为啥这么关注国产CPU,难道跟华镭也有些关系?或许我的一片“诚心”感动了上苍吧,竟然给了我一个机会去龙芯产业化基地参观,和其他9名来自中科院不同院所的同学一起,这该是怎样的一段旅程啊。 只可惜从来没用过龙芯电脑,更没用过龙芯版的华镭系统。但是不管怎么说,这次可以里里外外看个够了,呵呵。

16KB页,32bit 地址的划分有些问题

2007, 七月 21 - 00:40
32 bit kernel, 16KB 页大小,龙芯2E平台 tlb_refill_handler为: lui       k1, %hi(pgd_current) mfc0   k0, C0_BADVADDR lw       k1, %lo(pgd_current)(k1) srl     k0, k0, PGDIR_SHIFT sll       k0, k0, PGD_T_LOG2 addu   k1, k1, k0 mfc0   k0, C0_CONTEXT lw       k1, 0(k1) srl     k0, k0, 3 andi     k0, k0, (PTRS_PER_PTE/2-1) << (PTE_T_LOG2 + 1) addu   k1, k1, k0 lw       k0, 0(k1) lw       k1, sizeof(pte_t)(k1) srl     k0, k0, 6 mtc0   k0, C0_ENTRYLO0 srl     k1, k1, 6 mtc0   k1, C0_ENTRYLO1 tlbwr eret 相应的,直接从正在运行的 kernel 里获取的 tlb_refill_handler 为:     0:   52801b3c   lui k1,0x8052     4:   00401a40   mfc0   k0,$8       /* 从 BadVaddr 获取转换失败的 VA */     8:   18007b8f   lw k1,24(k1)       /* 读取 PGD 所在基地址 */     c:   82d51a00   srl k0,k0,0x16     /* VA 右移22位 */     10:   80d01a00   sll k0,k0,0x2     14:   21d87a03   addu   k1,k1,k0     18:   00201a40   mfc0   k0,$4       /* 读取 Context 值 */     1c:   00007b8f   lw k1,0(k1)     20:   c2d01a00   srl k0,k0,0x3             24:   f83f5a33   andi   k0,k0,0x3ff8     28:   21d87a03   addu   k1,k1,k0     2c:   00007a8f   lw k0,0(k1)     30:   04007b8f   lw k1,4(k1)     34:   82d11a00   srl k0,k0,0x6     38:   00109a40   mtc0   k0,$2     3c:   82d91b00   srl k1,k1,0x6     40:   00189b40   mtc0   k1,$3     44:   06000042   tlbwr     48:   18000042   eret Context 之格式为: 63                       23 22           4 3     0 |                           |     BadVPN2   |   0   | 22~4 共 19 位对应导致 TLB miss 之虚地址的31~13(VA[31:13]),因此如下指令     20:   c2d01a00   srl k0,k0,0x3             24:   f83f5a33   andi   k0,k0,0x3ff8     /* 获取 VA[25:15] 共11位,低3位为0 */ 的意图旨在获取 VA[25:15],并以 2^3=8 字节为单位索引PageTable,实际的索引范围为 2^12 = 4K ,这个与每页容纳的项数相一致(16K/4=4k)。实质上使用 VA[25:14]索引 PageTable,因每次取一对,故而VA[14] 不用。 VA[13:0] 页内位移,没有问题。 但使用 VA[31:22] 索引 PGD 就让人困惑了。32bit kernel 中定义 PGDIR_SHIFT 始终为 22 ,不管页大小为何,这个在4KB页大小下,是正好的,但在16KB下,由于使用 VA[25:15] 索引PageTable,因此用于索引 PGD 的域与索引 PT 的域重叠了4位(25~22)! 如果有2个虚址,VA1[22] = 1,VA2[23] = 1 ,当 TLB miss 时,当前内核的 tlb_miss_handler 是向2个不同的 PGD 入口找寻 PTE 的,尽管按照地址划分他们应该在同一个 PGD 入口才是。 关于地址的划分,应该从低位往高位切分才是,即:首先切取PAGE_SIZE所需位,然后根据PAGE_SIZE,确定索引 PT 的位数。如4KB,则为4K/4=1K, 10 位,16KB则为12 位,64KB 则为14位。 余下的高位作为索引PGD 的位数才是。因此应该是 6 | 12 | 14 才对。 --------------------------------- 32 bit 模式下, PGD 索引位与PT 索引位部分重叠并不会导致灾难性的后果,只是会造成核心分配给PT的页过多,浪费空间。 测了一下,改动后的 kernel,启动后 nr_page_table_pages 为 63 左右,而原有kernel 在101左右,多分配了 (101-63)*16KB 作为 PageTable。 另外我写了一个测试程序,使用mmap 映射一个40MB左右的文件在地址 0x2ac94000 附近,然后随机访问该文件中的数据 1亿次,新旧对比,原 kernel 要多分配 13*16KB 作为 PageTable(cat /proc/vmstat)。

修正和更新BioInfoServ软件包

2007, 七月 19 - 09:22
目前已经采用 bioinfoserv-base-directories_1.0-20_i386.deb来替代bioinfoserv- desktopmenu_1.0.1.1_i386.deb所具有的功能。同时修正各个软件在synaptic中的类别显示,统一采用 BioInfoServ类别。 新增加几个软件包: 序列组装:bioinfoserv-lucy_1.19p-3_i386.deb, 系统发育:bioinfoserv-phylip_3.65-2_i386.deb, hiweedlayer兼容层:bioinfoserv-hiweedlayer_0.0.6-x86_i386.deb, 个人财务管理:bioinfoserv-gnucash-common_1.8.12-6_i386.deb,bioinfoserv-gnucash_1.8.12-6_i386.deb usb磁盘加载和数据拷贝工具:bioinfoserv-usblink-mountapplication_1.0.0-1.deb live DVD/CD重装工具:bioinfoserv1.01-LiveCD-DVD-reconstructor_2.6.0_i386.deb XML编辑工具:bioinfoserv1.01-xmlcopyeditor_1.0.7.6_i386.deb 永中office办公软件2007:bioinfoserv-eioffice2007_4.1.1812.101ZH_i386.deb 日历进程安排工具:bioinfoserv-rainlendar2_2007.07.14.2.0_i386.deb 屏幕标尺工具:BioinfoServDeb/bioinfoserv1.01-gruler_0.6_i386.deb 桌面搜索工具:bioinfoserv1.01-catfish_0.3a-0_i386.deb 桌面硬件信息浏览工具:bioinfoserv1.01-hardinfo_0.4.2-0_i386.deb PDF编辑工具:bioinfoserv1.01-pdfedit_0.2.5-0_i386.deb 压缩工具:bioinfoserv-PeaZip_2007.07.14.1.6.0_i386.deb

一些生物软件包说明

2007, 七月 17 - 07:01
[b]1. [/b]bioinfoserv-desktopmenu_1.0.1.1_i386.deb 这是针对BioInfoServOS的系统菜单修订文件,安装它可以将您的系统程序菜单添加生物软件方面的类别,同时,为了让系统程序菜单在显示上又条理,还对其中的一些涉及到的其他软件类别进行归类和编修。总之,是为了美化的作用。这个包适合于xfce4桌面。 [b]2.[/b]bioinfoserv-themes_2007-13-07_1.3_i386.deb 这个文件针对系统的图标、风格,以及启动动画,登录界面进行美化。适合于GNOME/xfce4/KDE桌面,不过由于制作上的不全面性,仅仅对xfce4桌面支持要全面些。 [b]3.[/b]bioinfoserv-base-directories_1.0-20_i386.deb 这是本系统生物信息软件的基本目录设定与配置文件,它默认将随后安装的生物软件全部安装到/usr/local/bioinf下,以利于管理和查看。而且它也是安装其他一些生物软件所依赖性的软件包。 [b]4.[/b]bioinfoserv-emboss_3.0.0-5_i386.deb 这是一个综合性开放源代码的生物信息分析软件包,可以进行核酸、蛋白质序列的各种分析,而且其接口开放,任何人都可以基于它进行开发,打破了向商业软件发展的模式。极力推荐使用这个软件包。 [b]5.[/b]bioinfoserv-ape_1.2-3-2_i386.deb 这是系统发育学和进化研究工具包,基于R语言编写。 APE (Analyses of Phylogenetics and Evolution) is a package written in R. APE aims to be both a computing tool to analyse phylogenetic and evolutionary data, and an environment to develop and implement new analytical methods. [b]6.[/b]bioinfoserv-proteindesktop_1.0_i386.deb 这是一个开源的基因设计软件,可以高表达可能设计重组DNA分子. IBG GeneDesigner is an open-source product available for free download. It is still in development, but it can be used to design a nucleotide sequence for a particular protein (amino acid sequence) such that it will be optimized for the highest possible expression when used as a recombinant DNA fragment in a particular organism. [url]http://gridweb.cti.depaul.edu/twiki/bin/view/IBG/IBGSoft[/url] [b]7.[/b]MassSorter 这个软件包可以管理和分析蛋白质质谱仪实验数据。 administrating and analyzing data on proteins mass spectrometry experiments [b]8.[/b]bioinfoserv-taxinspector_2007.07.14.1.0.3b.deb NCBI数据库分类浏览器。 TaxInspector is a NCBI Taxonomy browser。 [b]9.[/b]bioinfoserv-sa_2007.07.14_1.6.0_i386.deb 这个软件可以进行ORF寻找,引物设计,酶切图谱分析以及序列操作等工作。 The purpose of Sequence Analysis is to find out orf, design primer,enzymes digest,sequence manapunation etc. [b]10.[/b]bioinfoserv-melecularbentch_2007-07-14_1.3_i386.deb 这是一个JAVA web传输的多语言、多编码的分子平台系统,可以进行化学动力学,点子结构图谱,分子三维构建分析等,支持8中文件格式,如PDB,CML,xyz,PNG,JPG,GIF,TXT,MWS等的打开,其运行需要事先在home/$username/Application Data/Molecular Workbench/cache有相应的文件目录缓冲。 [b]11.[/b]bioinfoserv-arb_2007.7.11_i386.deb 这个软件的目的是处理各种序列数据库(导入、导出、格式化等)和数据分析,在数据库处理上,功能强大。 The ARB software is a graphically oriented package comprising various tools for sequence database handling and data analysis. [b]12.[/b]bioinfoserv-act_5.0-1_i386.deb 这是sanger中心开发的DNA基于Artemis的序列比较分析查看软件。 ACT (Artemis Comparison Tool) is a DNA sequence comparison viewer based on Artemis. [b]13.[/b]bioinfoserv-artemis_8.0-1_i386.deb 这是一个基因组浏览和注释可视化工具,界面与上面的act几乎一样,只是主要功能不同。 Artemis is a free genome viewer and annotation tool that allows visualization of sequence features and the results of analyses within the context of the sequence, and its six-frame translation. Please see the file readme.bioinfoserv for suggestions about files to edit when running Artemis on BioInfoServ machines. [b]14.[/b]bioinfoserv-sight_2007.07.14_3.1.8_i386.deb 这是一个自动化基因组数据挖掘工具,目标是让使用者无需编程,也能完成复杂的数据挖掘工作。 automating genomic data-mining without programming skills. [b]15.[/b]bioinfoserv-agro_1.0.18_i386.deb 这是一个基于java的基因组浏览器,可以进行全基因组的手工注释和可视化处理。 The Argo Genome Browser is the Broad Institute's production tool for visualizing and manually annotating whole genomes. [b]16.[/b]bioinfoserv-interproscan_2007-07-14_1.01_i386.deb 这是一个很著名的蛋白质功能注释分析的软件包,它是由EBI 开发,集成蛋白质结构域和功能位点的数据库(如SWISS-PROT,TrEMBL.PROTSITE.PRINTS.PFAM.ProDom 等数据库提供的蛋白质序列中的各种,如结构域,motif等信息),是一个较为全面的蛋白质功能结构分析工具。这个deb包包含了基于本地命令行的软件,也提供可基于网络的jips图形界面。可参考的文献为[url]http://www.biomedcentral.com/1471-2105/7/462[/url],软件主页在[url]http://www.virology.ca/[/url]。这个软件还可以基于本地网络进行应用,Java GUI for InterProScan Local client(JIPS)就是基于本地web服务器,这个方式可以让那些具有强大局域网服务器的研究单位建立分析应用。当然,它的前提是,你必须建立web服务器,并配置好相应的服务器端。这个可以查看/usr/local/jips/client or server中的文件就可以知道了。如果要配置相应的web服务地址,那么打开/usr/local/bioinf/jips/client/jips.jnlp和/usr/local/bioinf/jips/server/servers/jips/jips_server.properties这两个文件进行修改配置。 [b]17.[/b]bioinfoserv-chinook_2007.07.14_1.02_i386.deb 这是一个基于p2p技术的生物信息节点计算平台,利用这个技术,可以把登录这个软件的所有计算机空闲能力集中起来进行生物学计算,这个思路应该说相当优秀。 chinook is a peer-to-peer (P2P) bioinformatics platform.参考站点:[url]http://smweb.bcgsc.bc.ca/chinook/index.html[/url] [b]18.[/b]bioinfoserv-apollo_2006-2.27-1.6.5_i386 这是一个开放性果蝇基因组计划的产物,主要是可以图形化浏览果蝇基因组注释结果。 Apollo is a collaborative open source project between the Berkeley Drosophila Genome Project, the Sanger Institute and the EBI. [b]18.[/b]bioinfoserv-jexproler_2007.07.14_2.7_i386 J-Express Pro是一个芯片分析软件,界面友好,目前这已经商业化。 J-Express Pro is a comprehensive portable software package for analysis and visualization of microarray data.                                                                                         [url]http://www.molmine.com/jexpress/[/url] 具体情况见:[url]www.bioinfoserv.org[/url]

BioInfoServ系统deb已经达到30个

2007, 七月 16 - 21:14
目前已经释放的BioInfoServ系统deb已经达到30个,其中生物软件20个(版本可以适用于debian3.0/Ubuntu6.06以上的系统),其他相关于系统和网络的软件10个(适合ubuntu 6.06)。 具体见[url]http://www.bioinfoserv.org/BioinfoServDeb[/url]