• VPS Ubuntu 10.10 config (2)

    (1) Java JDK5 Install:

    Append the following two lines into  app source list:   nano /etc/apt/sources.list

    deb http://cn.archive.ubuntu.com/ubuntu/ jaunty  multiverse
    deb http://cn.archive.ubuntu.com/ubuntu/  jaunty-updates  multiverse

    sudo apt-get update

     sudo apt-get install sun-java5-jdk

     

    (2) Java JDK6 Install:

     Append the following  line into  app source list:   sudo nano /etc/apt/sources.list

         deb http://archive.canonical.com/ubuntu maverick partner

     sudo apt-get update

     sudo apt-get install sun-java6-jdk

     

    (3) Check the current java version

      java  -version

     

    (4) Select Java version

     sudo update-java-alternatives -l

    sudo update-java-alternatives -s java-6-sun

     


  • VPS Ubuntu 10.10 config (1)

    1. 新增日常管理的用户:   myname

               adduser  myname

    2. 将用户加入sudo组:

          gpasswd -a myname sudo

    3.  启用sudo功能:   visudo在/etc/sudoers文件里root那行后面添加入新加的管理用户:

          root ALL=(ALL) ALL
         myname ALL=(ALL) ALL

    4.  重新以 myname 账户登入, 并测试 sudo 功能

             sudo myname

    5. 禁用root账户

             sudo passwd -l root

    6.  修改ubuntu的软件更新源:  

            sudo namo /etc/apt/sources.list

              deb     http://us.archive.ubuntu.com/ubuntu maverick main restricted universe multiverse
              deb     http://us.archive.ubuntu.com/ubuntu maverick-security main restricted universe multiverse
              deb     http://us.archive.ubuntu.com/ubuntu maverick-updates main restricted universe multiverse
              deb     http://us.archive.ubuntu.com/ubuntu maverick-proposed main restricted universe multiverse
              deb     http://us.archive.ubuntu.com/ubuntu maverick-backports main restricted universe multiverse
              deb-src http://us.archive.ubuntu.com/ubuntu maverick main restricted universe multiverse
              deb-src http://us.archive.ubuntu.com/ubuntu maverick-security main restricted universe multiverse
              deb-src http://us.archive.ubuntu.com/ubuntu maverick-updates main restricted universe multiverse
              deb-src http://us.archive.ubuntu.com/ubuntu maverick-proposed main restricted universe multiverse
              deb-src http://us.archive.ubuntu.com/ubuntu maverick-backports main restricted universe multiverse

    7.  更新系统:

                sudo apt-get update

                sudo apt-get upgrade

    8.  安装需要软件:

            sudo apt-get install language-pack-en language-pack-zh

           sudo apt-get install bash-completion

           sudo apt-get install vim ctags vim-doc vim-scripts

           sudo apt-get install screen byobu

          #安装压缩解压缩软件

           sudo apt-get install bzip2 unzip unrar p7zip

           #安装基本的语言环境和开发包

           sudo apt-get install perl python python-dev ruby ruby-dev sqlite sqlite3 openssl 

           #安装编译环境和开发包

           sudo apt-get install gcc g++ make autoconf automake patch gdb libtool cpp build-essential libc6-dev libncurses-dev expat

          #安装第三方类库的开发包

          sudo apt-get install libbz2-dev libexpat1-dev libssl-dev libdb-dev libgmp3-dev   liblzo2-dev

     

         #sudo apt-get install libcurl-dev
         #sudo apt-get install libcurl4-gnutls-dev

         #sudo apt-get install libpng12-dev
         #sudo apt-get install libxml2-dev
         #sudo apt-get install libjpeg-dev
         #sudo apt-get install libtiff-dev libfreetype6-dev libxslt1-dev
         #sudo apt-get install libssh-dev libssh2-1-dev
         #sudo apt-get install libpcre3-dev libpcre++-dev libssl-dev libgmp3-dev
         #sudo apt-get install libmhash-dev libmcrypt-dev libltdl7-dev mcrypt libiconv-hook-dev libsqlite-dev

     

         sudo apt-get install git-core subversion mercurial

     

     

     

     

  • 重归游牧生活

    原来还是准备重新租用 Burst Net 的VPS,  无奈讨厌的欠帐问题,使重新注册的VPS迟迟不能开通.

    决定换一家, 几经考虑,租用了 YardVpS 的 Xen /Tree1:

    https://www.yardvps.com/

    Dedicated RAM:   512 MB
    SWAP:                      1 GB
    CPU Cores:                   1
    Disk Space:            15 GB
    RAID10 w/ BBU:         Yes
    Setup Fee:               FREE
    Bandwidth:         1500 GB
    IPV4:                             1
    Native IPv6:       Enabled
    SolusVM:                  Yes
    Guard Dog:              Yes
    PPTP:                       Yes
    Price:                     7.95$
     
  • GoogleIO 2011

    有机会再次来到三藩市,参加Google IO 2011

    San FranCisico Airport

    旧金山机场

     

     

     

     

     

    第4大街

    4th Street

     

     

    moscone

    MOSCONE CENTER

     

     

     

    moscone

    MOSCONE CENTER

     

     

    T Shirt

    T-Shirt

     

    Badge

    Badge

     

     

    pass

    My Pass

     

     

  • NFC-SD 4/28成都展示

    首届中国移动电子商务年会, 2011年4月28日在成都举行。
    银联发布了基于SD 卡的NFC 移动支付解决方案。 TCL 和 HTC 的NFC SD 原理样机在会上经行了展示

     

    首届移动电子商务年会

     

    会议议程

     

    娇子中心

     

    TCL NF SD

     

     

    会议

     

    TCL NFC SD 手机

     

     

     

     

     

     

     

     

     

     

  • Enumerating ethernet adaptor starting from eth1 in Ubuntu 10.04

    Modify two files in /lib/udev:

    rule_generator_functions:

              local_basename=${links%%[ 0-9]*}  ==>

                   local_basename=${links%%[ 1-9]*}

    write_net_rules:

               basename=${INTERFACE%%[0-9]*} ==>

                   basename=${INTERFACE%%[1-9]*}

  • Override the GNU C library — painlessly

    http://www.ibm.com/developerworks/linux/library/l-glibc.html?t=gr,lnxw16=GNU

     

    Summary:  A great way to debug glibc functions is to override the function of interest with your own version. This can be done without having root permissions and without recompiling the libc source. Imagine the pure thrill of writing your own version of open()!

    What do you do if you don’t have the source for your application and it’s failing because a GNU Library for C (glibc) function is returning something bad to the application? Because glibc is open-source, you can of course get the source code, make your changes, rebuild, and install. This is not for the faint of heart, however, because although the API is well documented, the internal organization of the GNU C library is not. Finding the correct function prototypes is only the first of many challenges. It’s a big package as well, so the first time you compile, it will take some time (glibc 2.2.2 has 8,552 files and 1,775,440 lines of code, including comments).

    A better way

    Better than rebuilding glibc is selectively overriding a function. Many of the modern Unixes support the concept of preloading user defined libraries. These libraries can be either complete replacements (that is, a private version of glibc) or subsets — even a single function. You can use a private version of glibc by setting the LD_LIBRARY_PATH to include your private version of the library first. You can use a subset of library routines that you write by using the LD_PRELOAD environmental value. Both LD_LIBRARY_PATH and LD_PRELOAD are controlled by the dynamic ELF linker/loader. It uses a first match to satisfy any symbol name. By preloading your version of a library or function you short circuit the normal path, allowing you to override it.

    Here’s an example makefile that overrides the glibc function setresgid():

    Makefile to override setresgid()

     #
    # Makefile
    #

    all: libs setresgid-tester

    #
    # Make a shared Library
    #
    libs: libfuncs.c
    gcc -shared -Wl,-soname,libfuncs.so.1 -o libfuncs.so.1.0 libfuncs.c
    ln -s libfuncs.so.1.0 libfuncs.so.1
    ln -s libfuncs.so.1 libfuncs.so

    #
    # Here is a program that calls setresgid() for testing
    #
    setresgid-tester: setresgid-tester.c
    gcc -o setresgid-tester setresgid-tester.c

     

    The file libfuncs.c contains my private version of setresgid(). Be careful to implement it to support the same number of arguments and in other ways act the same as the original setresgid(), although my version lies to the application and always returns 0.

    The second file of interest is setresgid-tester.c. It tries out the new function by calling setresgid().

    This is the source code for the dynamic library:

    Replacement library

     /*
    Put all the functions you want to override here
    */
    #include <sys/types.h>
    #include <unistd.h>
    #include <errno.h>

    int errno;

    int
    setresgid(rgid, egid, sgid)
    gid_t rgid,egid,sgid;
    {
    errno=1;
    printf("It me the shim, Hi there!n");
    return(0);

    }

     

    You’ll also need a simple way to test your private version of setresgid(). You can use strace or ltrace to watch the process run. This is the source for a trivial test example:

    Trivial test example

     /* 
    setresgid() system/library call tester
    */
    #include
    #include
    main(){
    setresgid(0,0,0);
    }

     

    Now compile the library, set the LD_PRELOAD shell variable and run the test application. You may also need to set your LD_LIBRARY_PATH.

    Running test application

    export LD_PRELOAD=libfuncs.so
    export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
    ./setresgid-tester
    It's me the shim, Hi there!

     

    You can also confirm that your private library is being used by using ldd to list the dynamically linked libraries:

    Confirming use of private library

    [jay@prion ld_preload]$ ldd setresgid-tester
    libfuncs.so => libfuncs.so (0x40018000)
    libc.so.6 => /lib/libc.so.6 (0x40022000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

     


    Conclusion

    Writing private versions of GNU C library functions is a great way to debug systems problems or make quick fixes. Using the LD_PRELOAD shell variable, you can selectively override system C library functions with your own private versions. This technique works for both Linux and Solaris environments.

     

    About the author

     

  • Change vlan device name

    Modification:
            Function:  register_vlan_device()
            Location:  net/8021q/vlan.c
     
    static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
    {
                       ……
                       switch (vn->name_type) {
                       ……
                       case VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD:
    //
    snprintf(name, IFNAMSIZ, "%s.%i", real_dev->name, vlan_id);
    snprintf(name, IFNAMSIZ, "%s%i", "eth", vlan_id);
                                          break;
                       case VLAN_NAME_TYPE_PLUS_VID:
                                          /* Put our vlan.VID in the name.
                                           * Name will look like:    vlan0005
                                           */
                       default:
                                          snprintf(name, IFNAMSIZ, "vlan%.4i", vlan_id);
                       }
                       ……
    }
  • VirtualBox access physical disk partition

    List DISK partitions:

    VBoxManage.exe internalcommands listpartitions -rawdisk \.PhysicalDrive0
    VBoxManage.exe internalcommands listpartitions -rawdisk \.PhysicalDrive1
    VBoxManage.exe internalcommands listpartitions -rawdisk \.PhysicalDrive2

     

    Create raw VMDK:

    VBoxManage internalcommands createrawvmdk -filename K:vdiskwhole.vmdk -rawdisk \.PhysicalDrive1 -partitions 1,2,3,4
    VBoxManage internalcommands createrawvmdk -filename K:vdiskpart1.vmdk -rawdisk \.PhysicalDrive1 -partitions 1
    VBoxManage internalcommands createrawvmdk -filename K:vdiskpart2.vmdk -rawdisk \.PhysicalDrive1 -partitions 2
    VBoxManage internalcommands createrawvmdk -filename K:vdiskpart3.vmdk -rawdisk \.PhysicalDrive1 -partitions 3
    VBoxManage internalcommands createrawvmdk -filename K:vdiskpart4.vmdk -rawdisk \.PhysicalDrive1 -partitions 4

     

    Manage ram VMDK in Graphics VirtualBox Manager as usual.

     

  • Reserve eth0 slot in Linux Kernel

    Modification:
       Function:      __dev_alloc_name
       Location:      net/core/dev.c
     
    static int __dev_alloc_name(...)
    {
    ……
    for_each_netdev(net, d) {
    ……
    }
    /* Add two lines */ 
    if (!strncmp(name,"eth",3))                    
      set_bit(0, inuse);
    …… 
    }