<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7866664100757442128</id><updated>2011-11-24T21:08:14.623-08:00</updated><title type='text'>systemsresearch</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>41</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-7068135113969678376</id><published>2011-06-17T09:51:00.001-07:00</published><updated>2011-06-17T09:51:24.310-07:00</updated><title type='text'>GIT client installation pains :)</title><content type='html'>Install gcc&lt;br /&gt;&lt;br /&gt;yum install gcc&lt;br /&gt;Install zlib-devel package&lt;br /&gt;&lt;br /&gt;Noticed that zlib-devel was needed by the git install process when I first tried to run configure on the git distribution.&lt;br /&gt;&lt;br /&gt;yum install zlib-devel&lt;br /&gt;Install curl-devel&lt;br /&gt;&lt;br /&gt;Needed if you want to use http/https/webdav access to git repositories.&lt;br /&gt;&lt;br /&gt;yum install curl-devel&lt;br /&gt;Build Git from Source&lt;br /&gt;&lt;br /&gt;Once you have got your CentOS 5.2 system running, you can build git from the source tree.&lt;br /&gt;Download git&lt;br /&gt;&lt;br /&gt;wget http://kernel.org/pub/software/scm/git/git-1.6.0.4.tar.gz&lt;br /&gt;Unpack the Git source tree&lt;br /&gt;&lt;br /&gt;tar xvzf git-1.6.0.4.tar.gz&lt;br /&gt;Create a build target path&lt;br /&gt;&lt;br /&gt;You will need to have a build target directory path on your build machine that is the same as the path to your home directory on your target virtual host account. In this example we’re calling it&lt;br /&gt;/home/clientname.&lt;br /&gt;&lt;br /&gt;Replace clientname with the name of your home directory on hostgatore which is usually the same as your domainname.&lt;br /&gt;&lt;br /&gt;This is where the build/install process will end up “installing” the compiled and other run time files:&lt;br /&gt;&lt;br /&gt;mkdir /home/clientname&lt;br /&gt;Run Configure on source tree&lt;br /&gt;&lt;br /&gt;Change directory on the build machine to the top of the git source tree. (Where you unpacked the tar file git-1.6.0.4.tar.gz it does not have to be in /home/clientname)&lt;br /&gt;&lt;br /&gt;cd git-1.6.0.4&lt;br /&gt;&lt;br /&gt;Configure and set the prefix to the home directory that is your home directory on the target virtual host.&lt;br /&gt;&lt;br /&gt;./configure --prefix=/home/clientname/git_root&lt;br /&gt;&lt;br /&gt;Build the code and have it be installed in the directory that you defined in the –prefix line above&lt;br /&gt;make&lt;br /&gt;make install&lt;br /&gt;Assuming all goes well, it will build the code in the directory&lt;br /&gt;&lt;br /&gt;git-1.6.0.4&lt;br /&gt;&lt;br /&gt;and install everything in the directory&lt;br /&gt;&lt;br /&gt;/home/clientname/git_root&lt;br /&gt;&lt;br /&gt;It will automatically create the git_root directory but you have to have created /home/clientname&lt;br /&gt;Tar it up and scp it to target&lt;br /&gt;&lt;br /&gt;cd /home/clientname&lt;br /&gt;tar cvzf git_root.tgz git_root&lt;br /&gt;scp git_root.tgz userid@clienturl:&lt;br /&gt;&lt;br /&gt;Unpack it on target&lt;br /&gt;&lt;br /&gt;ssh userid@clienturl&lt;br /&gt;tar xvzf git_root.tgz&lt;br /&gt;&lt;br /&gt;Set up environment to use the newly installed git&lt;br /&gt;&lt;br /&gt;Add the path to the newly created bin to your path:&lt;br /&gt;&lt;br /&gt;Edit your startup file such as ~/.bash_profile and add:&lt;br /&gt;&lt;br /&gt;PATH=/home/clientname/git_root/bin:$PATH&lt;br /&gt;&lt;br /&gt;You have to log out and log back in or source .bash_profile to update the path. You can also type that line into your current session at the prompt and have it immediately active.&lt;br /&gt;Use Git as normal!&lt;br /&gt;&lt;br /&gt;I found that I can now use Git as normal except that with Hostgator they seemed to be blocking the git protocol or something. I could not say:&lt;br /&gt;&lt;br /&gt;git clone git://github.com/rberger/project.git&lt;br /&gt;&lt;br /&gt;But I could say:&lt;br /&gt;&lt;br /&gt;git clone git@github.com:rberger/project.git&lt;br /&gt;&lt;br /&gt;(assuming I had my ssh keys setup to access github as git)&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;git clone http://github.com/rberger/project.git&lt;br /&gt;&lt;br /&gt;Note that you do not say ./git. We are assuming that you added git to your path and you can just say git and it will find the executables via the $PATH&lt;br /&gt;&lt;br /&gt;If you didn’t want to change $PATH, you could  give a full path like:&lt;br /&gt;&lt;br /&gt;/home/clientname/git_root/bin/git clone git@github.com:rberger/project.git&lt;br /&gt;Save your CentOS 5.2 Amazon Image&lt;br /&gt;&lt;br /&gt;If you want to, you can save the CentOS 5.2 customized image you created on Amazon EC2.&lt;br /&gt;&lt;br /&gt;Ssh into the root account on your running CentOS amazon instance, copy your Amazon EC2 certificate and private key to the home directory of root on the running CentOS instance and run the following commands:&lt;br /&gt;Build the new AMI&lt;br /&gt;&lt;br /&gt;Replace cert-your_cert_sig.pem, your-private-key-sig and your-amazon-userid with the appropriate values for your EC2 certificate.&lt;br /&gt;&lt;br /&gt;ec2-bundle-vol -d /mnt --cert cert-your_cert_sig.pem --privatekey pk-your-private-key-sig.pem -u your-amazon-userid -s 3096&lt;br /&gt;&lt;br /&gt;The -s 3096 tells it to create an image that is 3GB big. You may have to make it bigger if the command fails. You can check that this is the problem by adding the –debug flag to the above command.&lt;br /&gt;Stash the image into your S3 account&lt;br /&gt;&lt;br /&gt;Use your own ws-access-key-id and aws-secret-access-key&lt;br /&gt;&lt;br /&gt;ec2-upload-bundle -b centos-5.2-git -m /mnt/image.manifest.xml -a aws-access-key-id -s aws-secret-access-key&lt;br /&gt;Git to your hearts content!&lt;br /&gt;&lt;br /&gt;Here is the gzipped tar file of git built to run on hostgator. I don’t know if it will work in any other directory than the one it was built for though.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-7068135113969678376?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/7068135113969678376/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=7068135113969678376' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/7068135113969678376'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/7068135113969678376'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2011/06/git-client-installation-pains.html' title='GIT client installation pains :)'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-49235552161019057</id><published>2010-03-29T06:07:00.001-07:00</published><updated>2010-03-29T06:08:16.056-07:00</updated><title type='text'>IPMI on Dell Poweredge running red hat</title><content type='html'>http://lonesysadmin.net/2007/06/21/how-to-configure-ipmi-on-a-dell-poweredge-running-red-hat-enterprise-linux/&lt;br /&gt;&lt;br /&gt;How to Configure IPMI on a Dell PowerEdge running Red Hat Enterprise Linux&lt;br /&gt;&lt;br /&gt;By Bob Plankers on Jun 21, 2007 in Featured, How To, System Administration&lt;br /&gt;&lt;br /&gt;This is intended to help fairly knowledgeable people get IPMI working on their hosts so they can issue remote commands to their hardware. I focus on Red Hat Enterprise Linux on a Dell, but it is likely to work on other hosts, distributions, and OSes, too. This works for me on Dell PowerEdge 1850, PowerEdge 2850, Dell PowerEdge 1950, and Dell PowerEdge 2950 hardware.&lt;br /&gt;&lt;br /&gt;Dell PowerEdge 1650, 2650, and 1750 servers have an older implementation of IPMI which will let you issue commands locally, but not to these models over the network.&lt;br /&gt;&lt;br /&gt;Before you begin:&lt;br /&gt;&lt;br /&gt;The Baseboard Management Controller (BMC) is the thing that implements IPMI. It piggybacks on the first built-in NIC so you have to have that attached to the network on the hosts you wish to manage. It uses its own IP address (so you need an extra one).&lt;br /&gt;&lt;br /&gt;If you are new to this get a server that is nearby to act as your test machine. Most of the IPMI commands that shut the host down also kill the BMC. If that happens you’ll need to go power the machine on manually. Until you figure out exactly what is okay and what isn’t you’ll be pushing the power button a lot.&lt;br /&gt;&lt;br /&gt;You will need a Linux host to send the IPMI commands from. Undoubtedly there are ways to send these commands from other operating systems, but as I am a Linux guy I’ll use that as my example. Feel free to post comments addressing other OSes.&lt;br /&gt;&lt;br /&gt;Getting the OS prepared:&lt;br /&gt;&lt;br /&gt;1) Install IPMItool and the startup scripts. On Red Hat Enterprise Linux install the OpenIPMI, OpenIPMI-tools, OpenIPMI-libs, and OpenIPMI-devel packages. That will get you everything you need. There are similar packages available for other distributions (SuSE, Ubuntu, CentOS, etc.). You’ll need IPMItool on any machine you want to configure, and any machine you want to send commands from.&lt;br /&gt;&lt;br /&gt;2) Enable the IPMI service:&lt;br /&gt;&lt;br /&gt;/sbin/chkconfig ipmi on&lt;br /&gt;&lt;br /&gt;3) Start the IPMI service, which will load the kernel modules for you:&lt;br /&gt;&lt;br /&gt;/sbin/service ipmi start&lt;br /&gt;&lt;br /&gt;Configure the BMC for Remote Usage:&lt;br /&gt;&lt;br /&gt;1) There are two ways to configure the BMC. You can configure it through the boot-time menu (Ctrl-E), where you can set the management password and IP address information. Or, you can configure it with ipmitool from the OS. Replace my sample IP address, gateway, and netmask with your own:&lt;br /&gt;&lt;br /&gt;/usr/bin/ipmitool -I open lan set 1 ipaddr 192.168.40.88&lt;br /&gt;/usr/bin/ipmitool -I open lan set 1 defgw ipaddr 192.168.40.1&lt;br /&gt;/usr/bin/ipmitool -I open lan set 1 netmask 255.255.255.0&lt;br /&gt;/usr/bin/ipmitool -I open lan set 1 access on&lt;br /&gt;&lt;br /&gt;2) Secure the BMC, so unauthorized people can’t power cycle your machines. To do this you want to change the default SNMP community, the “null” user password, and the root user password. First, set the SNMP community, either to a random string or something you know:&lt;br /&gt;&lt;br /&gt;/usr/bin/ipmitool -I open lan set 1 snmp YOURSNMPCOMMUNITY&lt;br /&gt;&lt;br /&gt;Then set the null user password to something random. Replace CRAPRANDOMSTRING with something random and secure:&lt;br /&gt;&lt;br /&gt;/usr/bin/ipmitool -I open lan set 1 password CRAPRANDOMSTRING&lt;br /&gt;&lt;br /&gt;Last, set the root user password to something you know:&lt;br /&gt;&lt;br /&gt;/usr/bin/ipmitool -I open user set password 2 REMEMBERTHIS&lt;br /&gt;&lt;br /&gt;Double-check your settings with:&lt;br /&gt;&lt;br /&gt;/usr/bin/ipmitool -I open lan print 1&lt;br /&gt;&lt;br /&gt;Trying it:&lt;br /&gt;&lt;br /&gt;1) You can set an environment variable, IPMI_PASSWORD, with the password you used above. That will save some typing:&lt;br /&gt;&lt;br /&gt;export IPMI_PASSWORD="REMEMBERTHIS"&lt;br /&gt;&lt;br /&gt;If you use this substitute the “-a” in the following commands with a “-E”.&lt;br /&gt;&lt;br /&gt;2) From another machine issue the following command, obviously replacing the IP with the target BMC’s IP:&lt;br /&gt;&lt;br /&gt;/usr/bin/ipmitool -I lan -U root -H 192.168.40.88 -a chassis power status&lt;br /&gt;&lt;br /&gt;You should get something like:&lt;br /&gt;&lt;br /&gt;Chassis Power is on&lt;br /&gt;&lt;br /&gt;If you get anything else, or nothing, double-check to make sure the BMC is set right, you entered the right password, and the IP it has is reachable from the machine you’re on. You can double-check your work via the Ctrl-E boot menu, too.&lt;br /&gt;&lt;br /&gt;Beyond that, get familiar with:&lt;br /&gt;&lt;br /&gt;/usr/bin/ipmitool -I lan -U root -H 192.168.40.88 -a chassis power off&lt;br /&gt;&lt;br /&gt;/usr/bin/ipmitool -I lan -U root -H 192.168.40.88 -a chassis power cycle&lt;br /&gt;&lt;br /&gt;/usr/bin/ipmitool -I lan -U root -H 192.168.40.88 -a sel list&lt;br /&gt;&lt;br /&gt;For me, a “chassis power off” command kills the box. “SEL” is the system event log.&lt;br /&gt;&lt;br /&gt;You can issue all of these commands locally, too:&lt;br /&gt;&lt;br /&gt;/usr/bin/ipmitool sel list&lt;br /&gt;&lt;br /&gt;Hopefully this helps a little. If you find any errors in this please leave me a comment or send me an email. Thanks!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-49235552161019057?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/49235552161019057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=49235552161019057' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/49235552161019057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/49235552161019057'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2010/03/ipmi-on-dell-poweredge-running-red-hat.html' title='IPMI on Dell Poweredge running red hat'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-1143734284491803301</id><published>2010-03-24T13:34:00.001-07:00</published><updated>2010-03-24T13:34:46.020-07:00</updated><title type='text'>permissions for rsa based authentication for ssh</title><content type='html'>make sure that the *right* permissions are set up&lt;br /&gt;&lt;br /&gt;drwx------ 2 virender virender 4096 May 7 04:51 .ssh&lt;br /&gt;-rw------- 1 virender virender 393 May 7 03:41 .ssh/authorized_keys&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-1143734284491803301?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/1143734284491803301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=1143734284491803301' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/1143734284491803301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/1143734284491803301'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2010/03/permissions-for-rsa-based.html' title='permissions for rsa based authentication for ssh'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-6858006132204113090</id><published>2010-02-02T07:09:00.001-08:00</published><updated>2010-02-02T07:10:19.714-08:00</updated><title type='text'>Booting Citrix Vdisk target both as a physical machine as well as via a XenServer VM</title><content type='html'>How to Create a Xen VM to Physical Common Image&lt;br /&gt;Document ID: CTX119877   /   Created On: Mar 27, 2009   /   Updated On: Aug 12, 2009&lt;br /&gt;Average Rating: 5 (1 ratings)&lt;br /&gt;View products this document applies to link to products this document applies to&lt;br /&gt;&lt;br /&gt;Summary&lt;br /&gt;&lt;br /&gt;This article describes how to create a vDisk that boots both a physical (bare metal) end point and a XenServer Virtual Machine (VM).&lt;br /&gt;&lt;br /&gt;Background&lt;br /&gt;&lt;br /&gt;The essential components to create a common image are:&lt;br /&gt;&lt;br /&gt;• A physical master target device&lt;br /&gt;&lt;br /&gt;• XenServer Tools installed&lt;br /&gt;&lt;br /&gt;• Provisioning Server target device installed&lt;br /&gt;&lt;br /&gt;Because the image can be booted within a virtual machine, updates, backups, and modifications are streamlined and simplified.&lt;br /&gt;&lt;br /&gt;Prerequisites&lt;br /&gt;&lt;br /&gt;• Installation and configuration of Provisioning Server, referred to as the Provisioning Server Streaming Server&lt;br /&gt;&lt;br /&gt;• Installation and configuration of XenServer on supported hardware&lt;br /&gt;&lt;br /&gt;• Proper XenServer Platinum Licensing&lt;br /&gt;&lt;br /&gt;• Creation and formatting of a Provisioning Server vDisk for the image-build process&lt;br /&gt;&lt;br /&gt;• Ensure Pre-boot Execution Environment (PXE) is supported on the local network&lt;br /&gt;&lt;br /&gt;• Ensure Dynamic Host Configuration Protocol (DHCP) is installed and configured on the local network&lt;br /&gt;&lt;br /&gt;• Creation of a master target device on physical hardware with supported Windows operating system, fully patched and configured&lt;br /&gt;&lt;br /&gt;• XenServer Tools installer&lt;br /&gt;&lt;br /&gt;• Provisioning Server target device&lt;br /&gt;&lt;br /&gt;Procedure&lt;br /&gt;&lt;br /&gt;The procedure below is divided into three sections. Use the appropriate sections for your environment.&lt;br /&gt;&lt;br /&gt;• Install a supported Windows operating system on a physical master target device with latest patches and device drivers.&lt;br /&gt;&lt;br /&gt;• If running Windows XP or Windows Server 2003, go to the Modify Boot.ini - Windows XP/2003 section.&lt;br /&gt;&lt;br /&gt;• If running Windows Vista or Windows Server 2008, go to the Modify…Boot Parameter Command - Windows Vista/2008 section.&lt;br /&gt;&lt;br /&gt;Modify Boot.ini – Windows XP/2003&lt;br /&gt;&lt;br /&gt;1. Log on to the master target device as a domain administrator, or a domain user (with local install privileges).&lt;br /&gt;&lt;br /&gt;2. Right click on My Computer and select Properties.&lt;br /&gt;The System Properties dialogue box appears.&lt;br /&gt;&lt;br /&gt;3. On the Advanced tab, under Startup and Recovery, click Settings.&lt;br /&gt;&lt;br /&gt;4. Under System startup, select Edit.&lt;br /&gt;This opens the Boot.ini file in Notepad.&lt;br /&gt;&lt;br /&gt;5. Append the switch /PV|=2000 to the end of the line that states the operating system in use.&lt;br /&gt;&lt;br /&gt;6. Click File, and then save the changes made to the boot.ini.&lt;br /&gt;&lt;br /&gt;7. Reboot the master target device.&lt;br /&gt;&lt;br /&gt;8. Go to the Install the XenServer Tools section below.&lt;br /&gt;&lt;br /&gt;Modify Boot Parameters – Windows Vista/2008&lt;br /&gt;&lt;br /&gt;1. Log on to the master target device as a domain administrator, or a domain user (with local install privileges).&lt;br /&gt;&lt;br /&gt;2. Open a command prompt.&lt;br /&gt;&lt;br /&gt;3. Run the following command:&lt;br /&gt;bcdedit /set loadoptions “PV|=2000”&lt;br /&gt;&lt;br /&gt;4. Reboot the master target device.&lt;br /&gt;&lt;br /&gt;Install the XenServer Tools&lt;br /&gt;&lt;br /&gt;1. Log on to the master target device as a domain administrator, or a domain user (with local install privileges).&lt;br /&gt;&lt;br /&gt;2. Install the windows-pvdrivers-xensetup.exe which can be found on the XenServer-4.1.0-install-cd.iso.&lt;br /&gt;&lt;br /&gt;3. The Citrix XenServer Windows Tools Setup warning appears. Click Yes to continue the installation.&lt;br /&gt;&lt;br /&gt;4. Follow the onscreen prompts and select the defaults. At the Choose Install Location dialogue box, click Install.&lt;br /&gt;&lt;br /&gt;5. When prompted by Windows Plug and Play dialogs, select the option to find drivers automatically. When prompted, select Yes for any unsigned driver dialog.&lt;br /&gt;&lt;br /&gt;6. When prompted, reboot the master target device.&lt;br /&gt;&lt;br /&gt;Install the Provisioning Server Target Device Software&lt;br /&gt;&lt;br /&gt;1. Log on to the master target device as a domain administrator, or a domain user (with local install privileges).&lt;br /&gt;&lt;br /&gt;2. Install the Provisioning Server target device software.&lt;br /&gt;&lt;br /&gt;3. Follow the onscreen prompts selecting all defaults.&lt;br /&gt;&lt;br /&gt;4. Exit the reboot prompt without rebooting and continue to Deleting the PVS entry in the Boot.ini.&lt;br /&gt;&lt;br /&gt;If running Windows XP or Windows Server 2003, go to the Modify Boot.ini - Windows XP/2003 section below.&lt;br /&gt;&lt;br /&gt;If running Windows Vista or Windows Server 2008, go to the Modify… Boot Parameter Command - Windows Vista/2008 section below.&lt;br /&gt;&lt;br /&gt;Modify (deleting PVS entry) in Boot.ini – Windows XP/2003&lt;br /&gt;&lt;br /&gt;1. Log on to the master target device as a domain administrator, or a domain user (with local install privileges).&lt;br /&gt;&lt;br /&gt;2. Right click on My Computer and select Properties.&lt;br /&gt;The System Properties dialogue box appears.&lt;br /&gt;&lt;br /&gt;3. On the Advanced tab, under Startup and Recovery, click Settings.&lt;br /&gt;&lt;br /&gt;4. Under System startup, select Edit.&lt;br /&gt;This opens the Boot.ini file in Notepad&lt;br /&gt;&lt;br /&gt;5. Remove the switch /PV|=2000 to the end of the line that states the operating system in use.&lt;br /&gt;&lt;br /&gt;6. Click File and then click Save to save the changes made to the boot.ini.&lt;br /&gt;&lt;br /&gt;7. Shut down the master target device.&lt;br /&gt;&lt;br /&gt;8. Go to the Image the Provisioning Server Master Target Device section below.&lt;br /&gt;&lt;br /&gt;Modify (Deleting Provisioning Server entry) using boot parameters command – Windows Vista/2008&lt;br /&gt;&lt;br /&gt;1. Log on to the master target device as a domain administrator, or a domain user (with local install privileges).&lt;br /&gt;&lt;br /&gt;2. Open a command prompt.&lt;br /&gt;&lt;br /&gt;3. Run the following command:&lt;br /&gt;bcdedit /deletevalue loadoptions&lt;br /&gt;&lt;br /&gt;4. Shut down the master target device.&lt;br /&gt;&lt;br /&gt;5. For the next steps, go to the Image the Provisioning Server Master Target Device section below.&lt;br /&gt;&lt;br /&gt;Image the Provisioning Server Master Target Device&lt;br /&gt;&lt;br /&gt;1. Boot the master target device, enter the BIOS configuration utility, and configure the boot order to PXE boot first. Save configuration settings and continue the boot process. When PXE booting a master target device for the first time, the Provisioning Server Streaming Service prompts for the following information:&lt;br /&gt;Client Name – Give the master target device a meaningful name&lt;br /&gt;Description – Give the master target device a meaningful description&lt;br /&gt;Select vDisk – Select the vDisk that was created and formatted for this installation&lt;br /&gt;Boot From – Select boot from hard drive&lt;br /&gt;&lt;br /&gt;2. When the master target device is successfully restarted, log on to the system as a domain administrator, or a domain user (with local install privileges).&lt;br /&gt;&lt;br /&gt;3. Click Start, then Programs, then Citrix Provisioning Server and select Provisioning Server Image Builder.&lt;br /&gt;&lt;br /&gt;4. Before building the image, click Optimize to optimize the device image.&lt;br /&gt;&lt;br /&gt;5. Click Browse to select the vDisk to build the image to and click Build to start the image build.&lt;br /&gt;&lt;br /&gt;6. Upon completion of the image build, shut down the master target device.&lt;br /&gt;&lt;br /&gt;Configuration Steps – vDisk Administration&lt;br /&gt;&lt;br /&gt;The following steps outline the details for setting the vDisk to Standard Image mode, which allows you to share the vDisk among multiple devices and virtual machines.&lt;br /&gt;&lt;br /&gt;      1. In the Provisioning Server console, highlight the vDisk icon in the object tree pane. Right click and select the Properties; the Disk Properties dialogue box opens. Click on the Disk Mode tab to access the Disk Access Mode properties. Using the drop down menu select Standard Image as the access mode. Once selected, click OK.&lt;br /&gt;&lt;br /&gt;      2. The master target device is currently set to boot from a hard drive. In the Provisioning Server Console, highlight the master target device icon in the object tree pane. Right click and select the Properties; the Client Properties dialogue box opens. In the Provisioning Server console, highlight the master target device icon in the object tree pane. Click on the Disk tab to access the client boot options. Using the drop down menu, select Virtual Disk first next to Boot Order. Once selected, click OK.&lt;br /&gt;&lt;br /&gt;You should now be able to boot the vDisk in Standard Image Mode to both the physical machine and a XenServer VM.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-6858006132204113090?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/6858006132204113090/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=6858006132204113090' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/6858006132204113090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/6858006132204113090'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2010/02/booting-citrix-vdisk-target-both-as.html' title='Booting Citrix Vdisk target both as a physical machine as well as via a XenServer VM'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-5233476518800348808</id><published>2010-01-21T06:29:00.001-08:00</published><updated>2010-01-21T06:29:56.102-08:00</updated><title type='text'>perl module installed check</title><content type='html'>Let's say that you want to know whether module Tie::Hash is installed. To find out, execute the following from the command line:&lt;br /&gt;&lt;br /&gt;perl -MTie::Hash -e 1&lt;br /&gt;&lt;br /&gt;If you don't get any output from the above command then the module is installed; if you get an error, it's not installed&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-5233476518800348808?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/5233476518800348808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=5233476518800348808' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/5233476518800348808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/5233476518800348808'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2010/01/perl-module-installed-check.html' title='perl module installed check'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-898359647133706231</id><published>2010-01-12T09:08:00.001-08:00</published><updated>2010-01-12T09:08:17.056-08:00</updated><title type='text'>RSA key generation for SSH linux</title><content type='html'>If your daily activity requires loging in a lot of Linux systems through SSH, you will be happy to know (if you don't already) that there's a way to allow secure, authenticated remote access, file transfer, and command execution without having to remember passwords for each individual host you connect.&lt;br /&gt;&lt;br /&gt;The $HOME/.ssh/authorized_keys file contains the RSA keys allowed for RSA authentication. Each line contains one key, which consists of the following fields: options, bits, exponent, modulus and comment. The first field is optional, bits, exponent and modulus fields give the RSA key and the last field isn't used at all in the authentication process, but it will be somewhat convenient to the user, for instance to know which key is for which machine.&lt;br /&gt;&lt;br /&gt;Before we start, make sure your computer has a ssh client installed and the remote Linux system has ssh installed and sshd running, with RSA authentication enabled (RSAAuthentication yes in /etc/ssh/sshd_config).&lt;br /&gt;&lt;br /&gt;First, you will need to generate the local RSA key:&lt;br /&gt;&lt;br /&gt;# ssh-keygen -t rsa&lt;br /&gt;&lt;br /&gt;Generating public/private rsa key pair.&lt;br /&gt;Enter file in which to save the key (/root/.ssh/id_rsa):&lt;br /&gt;(It's safe to press enter here, as the /root/.ssh is the default and recommended directory to hold the RSA file.)&lt;br /&gt;&lt;br /&gt;Enter passphrase (empty for no passphrase):&lt;br /&gt;Enter same passphrase again:&lt;br /&gt;(The password you enter here will need to be entered every time you use the RSA key but fortunately, you can set NO passphrase by pressing Enter. However, the upside is that you only have to remember this one passphrase for all the systems you access via RSA authentication and you can change the passhrase later with "ssh-keygen -p".)&lt;br /&gt;&lt;br /&gt;Your identification has been saved in /root/.ssh/id_rsa.&lt;br /&gt;Your public key has been saved in /root/.ssh/id_rsa.pub.&lt;br /&gt;&lt;br /&gt;Once the public key has been generated, it's time to upload it on any Linux systems you usually log into. It's recommended you use scp as the file transfer utility:&lt;br /&gt;&lt;br /&gt;# scp .ssh/id_rsa.pub username@hostname.com:~&lt;br /&gt;&lt;br /&gt;This command will copy the id_rsa.pub file in the $HOME directory. For instance, if you used root as the username, the file will be found in the /root directory and if you used a normal user, the file will be in the /home/that.user/ directory.&lt;br /&gt;&lt;br /&gt;Next, connect to the remote host through SSH, with the username you used in the step above. RSA authentication won't be available just yet, so you'll have to use the old method to login. Once you are connected, add the new hostkey to the file /root/.ssh/authorized_keys or /home/user/.ssh/authorized_keys. If the .ssh directory doesn't exist, create it.&lt;br /&gt;&lt;br /&gt;# cd $HOME&lt;br /&gt;# cat id_rsa.pub &gt;&gt; .ssh/authorized_keys&lt;br /&gt;&lt;br /&gt;The two right-angles will add the contents of id_rsa.pub file to the authorized_keys file, so in case the file already exists, you won't have to worry about the existing content being modified.&lt;br /&gt;&lt;br /&gt;You are all set. To test the RSA authentication, initiate a ssh connection from your PC to one of the Linux systems:&lt;br /&gt;&lt;br /&gt;# ssh username@remote.hostname.com&lt;br /&gt;&lt;br /&gt;If everything worked out well, you should be either asked for the passpharase (if you entered one), or get directly logged in. If you are prompted for the ssh password or get an error message, retry the above command using -v in order to turn verbose mode on and to be able to track down and correct the problem.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-898359647133706231?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/898359647133706231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=898359647133706231' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/898359647133706231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/898359647133706231'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2010/01/rsa-key-generation-for-ssh-linux.html' title='RSA key generation for SSH linux'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-7727386067279877523</id><published>2009-11-27T12:08:00.001-08:00</published><updated>2009-11-27T12:09:02.357-08:00</updated><title type='text'>scp</title><content type='html'>scp &lt;filetocopy&gt; user@host:&lt;dest dir&gt;&lt;br /&gt;&lt;br /&gt;i keep forgetting the syntax&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-7727386067279877523?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/7727386067279877523/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=7727386067279877523' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/7727386067279877523'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/7727386067279877523'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/11/scp.html' title='scp'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-7225193575463211682</id><published>2009-11-05T09:27:00.000-08:00</published><updated>2009-11-05T09:28:16.310-08:00</updated><title type='text'>Socket pooling</title><content type='html'>http://articles.techrepublic.com.com/5100-22_11-5756029.html&lt;br /&gt;&lt;br /&gt;(Listen up: This is material not included in our book. So if you have the book, print this out and stick it in the book! -Tom)&lt;br /&gt;&lt;br /&gt;Do you sometimes feel that ISA Server was designed to drive you crazy? If so, when were those times? I bet you felt like you were going nuts when you tried to do one of the following things:&lt;br /&gt;&lt;br /&gt;Publish an FTP Server running on the ISA Server itself &lt;br /&gt;Publish a Web Site running on the ISA Server itself &lt;br /&gt;Publish a NNTP server running on the ISA Server itself &lt;br /&gt;Publish a SMTP server running on the ISA Server itself &lt;br /&gt;Publish an Outlook Web Access site running on the ISA Server itself &lt;br /&gt; Configuring ISA Server 2000 : Building Firewalls for Windows 2000&lt;br /&gt;By Deb and Tom Shinder&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Amazon.com &lt;br /&gt;Notice something that all of these things have in common? That right! They all have the service in question running on the ISA Server itself. It makes you think they should have called it Server Punishing rather than Publishing.&lt;br /&gt;&lt;br /&gt;What is maddening about this situation is that the Help File says that it's no problem to publish services running on the ISA Server. Just make a couple of changes to the listening IP address for the particular service, then publish the service using that IP address. And away you go! The problem is that it doesn't work.&lt;br /&gt;&lt;br /&gt;The Misery of Socket Pooling&lt;br /&gt;&lt;br /&gt;All of these problems are related to a little known issue with IIS 5.0. The current version of IIS uses something called Socket Pooling which, if I understand the issue correctly, putatively improves performance. While it may improve performance, it completely whacks your ability to publish services on the ISA Server itself.&lt;br /&gt;&lt;br /&gt;What Socket Pooling does is allow a particular service to listen on all IP addresses on a particular computer. For example, if you have one internal IP address bound to the internal interface and two IP addresses bound to the external interface, then Socket Pooling will allow the service, such as the IIS 5.0 FTP Service, to listen on all three IP addresses.&lt;br /&gt;&lt;br /&gt;Let's take a closer look at this example.&lt;br /&gt;&lt;br /&gt;Open the Internet Information Services console from the Administrative Tools menu.&lt;br /&gt;&lt;br /&gt;Right click on the default FTP site and click Properties. &lt;br /&gt;In the Default FTP Site Properties dialog box you will see what appears below. Actually, you won't see what appears below until you click the down-arrow in the drop-down list box for TCP Port. Note that I have two IP addresses on this particular computer. I will select 192.168.1.186 with the intent of having the FTP service listen on that IP address only. After making the selection, click Apply and then OK. &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Open a command prompt window. at the command prompt type netstat -na. You'll see something like what appears below. Notice the top entry that says:&lt;br /&gt;&lt;br /&gt;TCP     0.0.0.0:21        0.0.0.0:0          LISTENING&lt;br /&gt;&lt;br /&gt;What this means is that port 21 is listening on all IP addresses, not just 192.168.1.186. This happens in spite of our configuring the IIS FTP service to use only 192.168.1.186 for the FTP service. This is the "benefit" of socket pooling. &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;What do you think will happen if I have packet filtering enabled and try to publish the FTP service on 192.168.1.186? It won't work! I could enable a packet filter to allow inbound TCP 21, but then we're not publishing the server. Is just listening on the interface that is directly connected to the Internet, and if I tried to put the server, the publishing rule would still not work. &lt;br /&gt;&lt;br /&gt;Fixing the Socket Pooling Problem &lt;br /&gt;In order to get the IIS W3SVC, FTPSVC and NNTPSVC to play nice with Web and Server Publishing Rules, we have to disable Socket Pooling. To do this, perform the following steps: &lt;br /&gt;&lt;br /&gt;Open a command prompt and navigate to the \Inetpub\Adminscripts\ folder &lt;br /&gt;Type net stop msftpsvc and press [ENTER] &lt;br /&gt;Type in the following command:&lt;br /&gt;&lt;br /&gt;cscript adsutil.vbs set msftpsvc/disablesocketpooling true&lt;br /&gt;&lt;br /&gt;and then press [ENTER]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You should see what appears below. &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;At the command prompt type net start msftpsvc and press [ENTER]. &lt;br /&gt;Now let's run netstat -na again. You should see what appears below. &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Notice that TCP port 21 is now listening on 192.168.1.186 and is no longer listening on 0.0.0.0. No more socket pooling for Port 21! Now you can publish the FTP service on the internal interface (almost, you actually have to make a registry change too). &lt;br /&gt;This same procedure will work for the WWW and NNTP services. Just replace msftpsvc with w3svc or nntpsvc. However, this procedure will not work with the SMTP service. &lt;br /&gt;&lt;br /&gt;How to Disable SMTP Service Socket Pooling &lt;br /&gt;To disable Socket Pooling for the SMTP service, you have to use a utility called Mdutil.exe. You can download this utility from the 'Tools' section of the 'Learning Zone'&lt;br /&gt;&lt;br /&gt;Put the Mdutil.exe executable in the \Inetpub\Adminscripts folder. &lt;br /&gt;Open a command prompt window and type the following command: &lt;br /&gt;mdutil set -path smtpsvc/1 -value 1 -dtype 1 -prop 1029 -attrib 1 &lt;br /&gt;&lt;br /&gt;Go to the Internet Information Services console, right click on the SMTP service, and click Properties. Change the listening address to the internal interface of the ISA Server. &lt;br /&gt;For more information on Socket Pooling and the SMTP service, check out: &lt;br /&gt;&lt;br /&gt;http://msdn.microsoft.com/library/psdk/iisref/apro9zon.htm &lt;br /&gt;&lt;br /&gt;Conclusion &lt;br /&gt;IIS 5.0 Socket Pooling has caused a great deal pain for budding ISA Server administrators. It would have been nice to have this issue mentioned in the Help File. But then if they did that, I wouldn't have had a good reason to write this article. &lt;br /&gt;&lt;br /&gt;After disabling Socket Pooling using the methods described, you will be able to publish services located on the ISA Server itself. Although it is always preferable to remove all unnecessary services on the ISA Server, sometimes you can't get around the problem because of financial limitations. In that case, you have to run extra services on the ISA Server. &lt;br /&gt;&lt;br /&gt;A special note for you Outlook Web Access admins. This solution will fix the problem you have had with publishing Outlook Web Access when it is located on the ISA Server itself. If you are trying to do this, I highly recommend that you read Martin Grasdal's article - "OWA and ISA Server" on this subject.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-7225193575463211682?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/7225193575463211682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=7225193575463211682' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/7225193575463211682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/7225193575463211682'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/11/socket-pooling.html' title='Socket pooling'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-2154230382514154980</id><published>2009-11-05T09:23:00.000-08:00</published><updated>2009-11-05T09:25:15.798-08:00</updated><title type='text'>DMZ</title><content type='html'>http://articles.techrepublic.com.com/5100-22_11-5756029.html&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The concept of the DMZ, like many other network security concepts, was borrowed from military terminology. Geopolitically, a demilitarized zone (DMZ) is an area that runs between two territories that are hostile to one another or two opposing forces' battle lines. The term was first widely used to refer to the strip of land that cuts across the Korean peninsula and separates the North from the South. In computer networking, the DMZ likewise provides a buffer zone that separates an internal network from the often hostile territory of the Internet. Sometimes it's called a "screened subnet" or a "perimeter network," but the purpose remains the same.&lt;br /&gt;&lt;br /&gt;In this article, we'll look at how the DMZ works and different security architectures for building DMZs. In the second article of this two-part article, we'll talk about what computers should (and shouldn't) be placed in the DMZ and how to monitor DMZ activity.&lt;br /&gt;&lt;br /&gt;How the DMZ Works&lt;br /&gt;Unlike the geopolitical DMZ, a DMZ network is not a no-man's land that belongs to nobody. When you create a DMZ for your organization, it belongs to you and is under your control. However, it is an isolated network that's separate from your corporate LAN (the "internal" network). The DMZ uses IP addresses belonging to a different network ID. &lt;br /&gt;&lt;br /&gt;If you think of the internal network as the "trusted" network and the external public network (the Internet) as the "untrusted" network, you can think of the DMZ as a "semi-trusted" area. It's not as secured as the LAN, but because it is behind a firewall, neither is it as non-secure as the Internet. You can also think of the DMZ as a "liaison network" that can communicate with both the Internet and the LAN while sitting between the two, as illustrated by Figure A.&lt;br /&gt;&lt;br /&gt;Figure A&lt;br /&gt;&lt;br /&gt;What does this accomplish? You can place computers that need to communicate directly with the Internet (public servers) in the DMZ instead of on your internal network. They will be protected by the outer firewall, although they are still at risk simply because they have direct contact with Internet computers. Because the DMZ is only "semi-secure," it's easier to hack a computer in the DMZ than on the internal network. The good news is that if a DMZ computer does get hacked, it doesn't compromise the security of the internal network, because it's on a completely separate, isolated network.&lt;br /&gt;&lt;br /&gt;Why put any computers in this riskier network? Let's take an example: in order to do its job (make your Web site available to members of the public), your Web server has to be accessible to the Internet. But having a server on your network that's accessible from the Internet puts the entire network at risk. There are three ways to reduce that risk: &lt;br /&gt;&lt;br /&gt;You could pay a hosting company to host your Web sites on their machines and network. However, this gives you less control over your Web servers. &lt;br /&gt;You could host the public servers on the firewall computer. However, best security practices say the firewall computer should be dedicated solely to act as a firewall (this reduces the chances of the firewall being compromised), and practically speaking, this would impair the firewall's performance. Besides, if you have a firewall appliance running a proprietary OS, you won't be able to install other services on it. &lt;br /&gt;The third solution is to put the public Web servers on a separate, isolated network: the DMZ.&lt;br /&gt;Creating a DMZ Infrastructure&lt;br /&gt;The DMZ is created by two basic components: IP addresses and firewalls. Remember that two important characteristics of the DMZ are:&lt;br /&gt;&lt;br /&gt;It has a different network ID from the internal network &lt;br /&gt;It is separated from both the Internet and the internal network by a firewall&lt;br /&gt;IP Addressing Scheme&lt;br /&gt;A DMZ can use either public or private IP addresses, depending on its architecture and firewall configuration. If you use public addresses, you'll usually need to subnet the IP address block that you have assigned to you by your ISP, so that you have two separate network IDs. One of the network IDs will be used for the external interface of your firewall and the other will be used for the DMZ network.&lt;br /&gt;&lt;br /&gt;When you subnet your IP address block, you must configure your router to know how to get to the DMZ subnet. &lt;br /&gt;&lt;br /&gt;You can create a DMZ within the same network ID that you use for your internal network, by using Virtual LAN (VLAN) tagging. This is a method of partitioning traffic that shares a common switch, by creating virtual local area networks as described in IEEE standard 802.1q. This specification creates a standard way of tagging Ethernet frames with information about VLAN membership. &lt;br /&gt;&lt;br /&gt;If you use private IP addresses for the DMZ, you'll need a Network Address Translation (NAT) device to translate the private addresses to a public address at the Internet edge. Some firewalls provide address translation.&lt;br /&gt;&lt;br /&gt;Whether to choose a NAT relationship or a routed relationship between the Internet and the DMZ depends on the applications you need to support, as some applications don't work well with NAT.&lt;br /&gt;&lt;br /&gt;DMZ Firewalls&lt;br /&gt;When we say that a firewall must separate the DMZ from both the internal LAN and the Internet, that doesn't necessarily mean you have to buy two firewalls. If you have a "three legged firewall" (one with at least three network interfaces), the same firewall can serve both functions. On the other hand, there are reasons you might want to use two separate firewalls (a front end and a back end firewall) to create the DMZ. &lt;br /&gt;&lt;br /&gt;Figure A above illustrates a DMZ that uses two firewalls, called a back to back DMZ. An advantage of this configuration is that you can put a fast packet filtering firewall/router at the front end (the Internet edge) to increase performance of your public servers, and place a slower application layer filtering (ALF) firewall at the back end (next to the corporate LAN) to provide more protection to the internal network without negatively impacting performance for your public servers. Each firewall in this configuration has two interfaces. The front end firewall has an external interface to the Internet and an internal interface to the DMZ, whereas the backend firewall has an external interface to the DMZ and an internal interface to the corporate LAN.&lt;br /&gt;&lt;br /&gt;When you use a single firewall to create a DMZ, it's called a trihomed DMZ. That's because the firewall computer or appliance has interfaces to three separate networks:&lt;br /&gt;&lt;br /&gt;The internal interface to the trusted network (the internal LAN) &lt;br /&gt;The external interface to the untrusted network (the public Internet) &lt;br /&gt;The interface to the semi-trusted network (the DMZ)&lt;br /&gt;The trihomed DMZ looks like Figure B.&lt;br /&gt;&lt;br /&gt;Figure B&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;A trihomed DMZ uses a "three legged" firewall to create separate networks &lt;br /&gt;&lt;br /&gt;Even if you use a single trihomed firewall to protect both the DMZ and the internal network, you should be able to configure separate rules for evaluating traffic depending on its origin and destination. That is, there should be separate rules for:&lt;br /&gt;&lt;br /&gt;Incoming traffic from the Internet to the DMZ &lt;br /&gt;Incoming traffic from the DMZ to the internal LAN &lt;br /&gt;Incoming traffic from the Internet to the internal network &lt;br /&gt;Outgoing traffic from the internal network to the DMZ &lt;br /&gt;Outgoing traffic from the internal network to the Internet &lt;br /&gt;Outgoing traffic from the DMZ to the Internet&lt;br /&gt;The DMZ actually reduces the complexity of filtering traffic, because you can have one rule for all the computers in the DMZ. If you were hosting the public servers on the internal network, you would need to configure different rules for each hosting server, and you would have to "publish" each server to allow it to be accessed from the Internet.&lt;br /&gt;&lt;br /&gt;You'll probably want to block traffic from the Internet to the internal computers. You should also restrict traffic from the DMZ to the internal network, as well as traffic from the Internet to the DMZ. Allow only the traffic that is necessary for your users to access the resources they need. This means using the "principle of least privilege" in that your default is to start by denying all traffic and then allowing protocols and opening ports on a "need to know" basis.&lt;br /&gt;&lt;br /&gt;Vendor Support for DMZs&lt;br /&gt;Major hardware and software vendors support the DMZ concept in their products. Cisco routers have multiple LAN ports, one of which is designated as a DMZ port, and the IOS operating system uses Port Address Translation (PAT) to allow traffic to be routed to multiple servers with a single IP address destination. As the name implies, it uses port numbers (such as 80 for the Web server and 25 for the mail server) to distinguish between the multiple servers. This allows you to have multiple public servers without paying for multiple public IP addresses.&lt;br /&gt;&lt;br /&gt;Many firewall appliances, such as the SonicWall, come with three Ethernet ports: a LAN port (to connect to the internal network), a WAN port (to connect to the Internet) and a DMZ port (to connect to the network housing your public servers).&lt;br /&gt;&lt;br /&gt;Microsoft's ISA Server 2004's multi-networking feature allows you to connect the ISA Server firewall to as many networks as you wish, limited only by the number of network interface cards you can install in the machine. No network is automatically "trusted" in the new ISA model, so you configure security according to the needs of the particular network.&lt;br /&gt;&lt;br /&gt;Common DMZ Security Architectures&lt;br /&gt;A DMZ is considered by many to be a "wide open" network, much like the geopolitical DMZ where you risk being shot anytime you set foot inside it. However, all DMZs are not created equal when it comes to the security architecture. Even when you place computers in the DMZ, there are still ways to protect them. The level of security within the DMZ also depends on the nature of the servers that are placed there. We can divide DMZs into two security categories:&lt;br /&gt;&lt;br /&gt;DMZs designed for unauthenticated or anonymous access &lt;br /&gt;DMZs designed for authenticated access&lt;br /&gt;If you have a Web server that you want everybody on the Internet to be able to access, (such as a Web presence advertising your company), you'll have to allow anonymous access. You can't easily provide authentication credentials to every stranger who happens upon your site. However, if your Internet-facing servers on the DMZ are used by partners, customers, or employees working off-site, you can require authentication to access them. This makes it more difficult for a hacker to gain access.&lt;br /&gt;&lt;br /&gt;The DMZ Honeynet&lt;br /&gt;There is a special use for the anonymous DMZ that's being more popular: creating a "honeynet." This is a network that consists of one or more "honeypot" computers that are designed to lure hackers --either so they can be caught or tracked, or to divert them from the network's real resources. Unlike with other DMZs, you actually want this network to be compromised. &lt;br /&gt;&lt;br /&gt;Often the computers on the honeynet are virtual machines that are all installed on a single physical machine, and intrusion detection systems and other monitoring systems are put in place to gather information about the hackers' techniques, tactics and identities.&lt;br /&gt;&lt;br /&gt;Host Security on the DMZ&lt;br /&gt;Because the DMZ is a less secure network than the internal network, host security is even more important for the computers that are "out there." The servers on your DMZ should be hardened as much as possible (while maintaining their accessibility to those who need to access them). This means: &lt;br /&gt;&lt;br /&gt;All unnecessary services should be disabled. &lt;br /&gt;Necessary services should be run with the lowest privileges possible. &lt;br /&gt;Strong passwords or passphrases should be used. &lt;br /&gt;Unnecessary user accounts should be deleted or disabled and default accounts should be disguised by renaming, changing the description, etc. &lt;br /&gt;Systems should have the latest security updates and patches applied. &lt;br /&gt;Security logging should be enabled (and you should check the logs frequently!)&lt;br /&gt;The Evolution of the DMZ&lt;br /&gt;The definition of "DMZ" is becoming broader, as more uses are found for these "semi-trusted" networks. Today's networks are complex, and security specialists are beginning to realize that the concept of the network "edge" or "perimeter" is outdated; an enterprise network has multiple perimeters. Thus, DMZs may be appropriate at places other than at the edge of the Internet, and large networks can benefit from having multiple DMZs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-2154230382514154980?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/2154230382514154980/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=2154230382514154980' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/2154230382514154980'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/2154230382514154980'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/11/dmz.html' title='DMZ'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-1199312428126927450</id><published>2009-11-04T06:51:00.000-08:00</published><updated>2009-11-04T06:52:17.464-08:00</updated><title type='text'>Active directory tutorial</title><content type='html'>http://www.learnthat.com/Software/learn/1295/Introduction-to-Active-Directory/page/1/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-1199312428126927450?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/1199312428126927450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=1199312428126927450' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/1199312428126927450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/1199312428126927450'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/11/active-directory-tutorial.html' title='Active directory tutorial'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-76348702743225452</id><published>2009-10-19T19:52:00.000-07:00</published><updated>2009-10-19T19:54:24.781-07:00</updated><title type='text'>SSL and its generation/installation</title><content type='html'>Zurück  &lt;br /&gt;How to create a self-signed SSL Certificate ...&lt;br /&gt;&lt;br /&gt;...  which can be used for testing purposes or internal usage&lt;br /&gt;&lt;br /&gt;Overview&lt;br /&gt;&lt;br /&gt;    The following is an extremely simplified view of how SSL is implemented and what part the certificate plays in the entire process.&lt;br /&gt;&lt;br /&gt;    Normal web traffic is sent unencrypted over the Internet. That is, anyone with access to the right tools can snoop all of that traffic. Obviously, this can lead to problems, especially where security and privacy is necessary, such as in credit card data and bank transactions. The Secure Socket Layer is used to encrypt the data stream between the web server and the web client (the browser).&lt;br /&gt;&lt;br /&gt;    SSL makes use of what is known as asymmetric cryptography, commonly referred to as public key cryptography (PKI). With public key cryptography, two keys are created, one public, one private. Anything encrypted with either key can only be decrypted with its corresponding key. Thus if a message or data stream were encrypted with the server's private key, it can be decrypted only using its corresponding public key, ensuring that the data only could have come from the server.&lt;br /&gt;&lt;br /&gt;    If SSL utilizes public key cryptography to encrypt the data stream traveling over the Internet, why is a certificate necessary? The technical answer to that question is that a certificate is not really necessary - the data is secure and cannot easily be decrypted by a third party. However, certificates do serve a crucial role in the communication process. The certificate, signed by a trusted Certificate Authority (CA), ensures that the certificate holder is really who he claims to be. Without a trusted signed certificate, your data may be encrypted, however, the party you are communicating with may not be whom you think. Without certificates, impersonation attacks would be much more common.&lt;br /&gt;&lt;br /&gt;Step 1: Generate a Private Key&lt;br /&gt;&lt;br /&gt;    The openssl toolkit is used to generate an RSA Private Key and CSR (Certificate Signing Request). It can also be used to generate self-signed certificates which can be used for testing purposes or internal usage.&lt;br /&gt;&lt;br /&gt;    The first step is to create your RSA Private Key. This key is a 1024 bit RSA key which is encrypted using Triple-DES and stored in a PEM format so that it is readable as ASCII text.&lt;br /&gt;&lt;br /&gt;    openssl genrsa -des3 -out server.key 1024&lt;br /&gt;&lt;br /&gt;    Generating RSA private key, 1024 bit long modulus&lt;br /&gt;    .........................................................++++++&lt;br /&gt;    ........++++++&lt;br /&gt;    e is 65537 (0x10001)&lt;br /&gt;    Enter PEM pass phrase:&lt;br /&gt;    Verifying password - Enter PEM pass phrase:&lt;br /&gt;&lt;br /&gt;Step 2: Generate a CSR (Certificate Signing Request)&lt;br /&gt;&lt;br /&gt;    Once the private key is generated a Certificate Signing Request can be generated. The CSR is then used in one of two ways. Ideally, the CSR will be sent to a Certificate Authority, such as Thawte or Verisign who will verify the identity of the requestor and issue a signed certificate. The second option is to self-sign the CSR, which will be demonstrated in the next section.&lt;br /&gt;&lt;br /&gt;    During the generation of the CSR, you will be prompted for several pieces of information. These are the X.509 attributes of the certificate. One of the prompts will be for "Common Name (e.g., YOUR name)". It is important that this field be filled in with the fully qualified domain name of the server to be protected by SSL. If the website to be protected will be https://public.akadia.com, then enter public.akadia.com at this prompt. The command to generate the CSR is as follows:&lt;br /&gt;&lt;br /&gt;    openssl req -new -key server.key -out server.csr&lt;br /&gt;&lt;br /&gt;    Country Name (2 letter code) [GB]:CH&lt;br /&gt;    State or Province Name (full name) [Berkshire]:Bern&lt;br /&gt;    Locality Name (eg, city) [Newbury]:Oberdiessbach&lt;br /&gt;    Organization Name (eg, company) [My Company Ltd]:Akadia AG&lt;br /&gt;    Organizational Unit Name (eg, section) []:Information Technology&lt;br /&gt;    Common Name (eg, your name or your server's hostname) []:public.akadia.com&lt;br /&gt;    Email Address []:martin dot zahn at akadia dot ch&lt;br /&gt;    Please enter the following 'extra' attributes&lt;br /&gt;    to be sent with your certificate request&lt;br /&gt;    A challenge password []:&lt;br /&gt;    An optional company name []:&lt;br /&gt;&lt;br /&gt;Step 3: Remove Passphrase from Key&lt;br /&gt;&lt;br /&gt;    One unfortunate side-effect of the pass-phrased private key is that Apache will ask for the pass-phrase each time the web server is started. Obviously this is not necessarily convenient as someone will not always be around to type in the pass-phrase, such as after a reboot or crash. mod_ssl includes the ability to use an external program in place of the built-in pass-phrase dialog, however, this is not necessarily the most secure option either. It is possible to remove the Triple-DES encryption from the key, thereby no longer needing to type in a pass-phrase. If the private key is no longer encrypted, it is critical that this file only be readable by the root user! If your system is ever compromised and a third party obtains your unencrypted private key, the corresponding certificate will need to be revoked. With that being said, use the following command to remove the pass-phrase from the key:&lt;br /&gt;&lt;br /&gt;    cp server.key server.key.org&lt;br /&gt;    openssl rsa -in server.key.org -out server.key&lt;br /&gt;&lt;br /&gt;    The newly created server.key file has no more passphrase in it.&lt;br /&gt;&lt;br /&gt;    -rw-r--r-- 1 root root 745 Jun 29 12:19 server.csr&lt;br /&gt;    -rw-r--r-- 1 root root 891 Jun 29 13:22 server.key&lt;br /&gt;    -rw-r--r-- 1 root root 963 Jun 29 13:22 server.key.org&lt;br /&gt;&lt;br /&gt;Step 4: Generating a Self-Signed Certificate&lt;br /&gt;&lt;br /&gt;    At this point you will need to generate a self-signed certificate because you either don't plan on having your certificate signed by a CA, or you wish to test your new SSL implementation while the CA is signing your certificate. This temporary certificate will generate an error in the client browser to the effect that the signing certificate authority is unknown and not trusted.&lt;br /&gt;&lt;br /&gt;    To generate a temporary certificate which is good for 365 days, issue the following command:&lt;br /&gt;&lt;br /&gt;    openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt&lt;br /&gt;    Signature ok&lt;br /&gt;    subject=/C=CH/ST=Bern/L=Oberdiessbach/O=Akadia AG/OU=Information&lt;br /&gt;    Technology/CN=public.akadia.com/Email=martin dot zahn at akadia dot ch&lt;br /&gt;    Getting Private key&lt;br /&gt;&lt;br /&gt;Step 5: Installing the Private Key and Certificate&lt;br /&gt;&lt;br /&gt;    When Apache with mod_ssl is installed, it creates several directories in the Apache config directory. The location of this directory will differ depending on how Apache was compiled.&lt;br /&gt;&lt;br /&gt;    cp server.crt /usr/local/apache/conf/ssl.crt&lt;br /&gt;    cp server.key /usr/local/apache/conf/ssl.key&lt;br /&gt;&lt;br /&gt;Step 6: Configuring SSL Enabled Virtual Hosts&lt;br /&gt;&lt;br /&gt;    SSLEngine on&lt;br /&gt;    SSLCertificateFile /usr/local/apache/conf/ssl.crt/server.crt&lt;br /&gt;    SSLCertificateKeyFile /usr/local/apache/conf/ssl.key/server.key&lt;br /&gt;    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown&lt;br /&gt;    CustomLog logs/ssl_request_log \&lt;br /&gt;       "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"&lt;br /&gt;&lt;br /&gt;Step 7: Restart Apache and Test&lt;br /&gt;&lt;br /&gt;    /etc/init.d/httpd stop&lt;br /&gt;    /etc/init.d/httpd stop&lt;br /&gt;&lt;br /&gt;    https://public.akadia.com&lt;br /&gt;http://tldp.org/HOWTO/SSL-Certificates-HOWTO/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-76348702743225452?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/76348702743225452/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=76348702743225452' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/76348702743225452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/76348702743225452'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/10/ssl-and-its-generationinstallation.html' title='SSL and its generation/installation'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-4184503038013017222</id><published>2009-10-14T16:43:00.000-07:00</published><updated>2009-10-14T16:44:07.664-07:00</updated><title type='text'>grub and bcd edit</title><content type='html'>Linux&lt;br /&gt;Added by Mahmoud Al-Qudsi, last edited by Mahmoud Al-Qudsi on Jan 25, 2009  (view change)&lt;br /&gt;Labels&lt;br /&gt; &lt;br /&gt;(None)&lt;br /&gt;Add Labels&lt;br /&gt; &lt;br /&gt;Wait Image &lt;br /&gt;Enter labels to add to this page:&lt;br /&gt;Looking for a label? Just start typing.&lt;br /&gt; &lt;br /&gt;Adding Linux to the Vista Bootloader&lt;br /&gt;&lt;br /&gt;One of the most features that EasyBCD brings to the table is full-blown support for Linux, BSD, Solaris, and more starting from version 1.5, putting it a league above the competition. Most importantly, EasyBCD offers several different ways to get these operating systems working with Vista, just in case one or more fail to work out the way you want them to.&lt;br /&gt;&lt;br /&gt;Chainloading is a dual-boot term that refers to one bootloader handing off the boot process to another. In this case, we configure the Vista bootloader to ask either Grub or Lilo (the most common Linux bootloaders) to complete the boot process for us - minimizing configuration requirements and ensuring maximum compatibility.&lt;br /&gt; Using a Specific Distro?&lt;br /&gt;&lt;br /&gt;We have distro-specific guides for Fedora and Ubuntu available!&lt;br /&gt;Vista before Linux&lt;br /&gt;&lt;br /&gt;EasyBCD makes installing Linux after you have Windows Vista up-and-running a breeze. These steps assume you have Windows Vista properly installed and booting, and are looking to install Linux on a second hard drive or partition. These steps also assume that you are using the default Windows Vista bootloader, and don't manually change the active partition around. If you had Linux installed before you installed Windows Vista, scroll down to the next section.&lt;br /&gt;&lt;br /&gt;   1. Put the Linux CD in the drive, and start the installation normally.&lt;br /&gt;   2. When prompted to set up the bootloader, make sure you specify to install LILO, GRUB, or whatever to the bootsector of the partition that Linux is being installed to and not the MBR of your hard drive.&lt;br /&gt;   3. Finish the Linux installation, take the CD out of the drive, and reboot.&lt;br /&gt;&lt;br /&gt;At this point, you'll go straight back to Windows Vista. Don't panic, everything is OK - you'll be in Linux soon enough!&lt;br /&gt;&lt;br /&gt;   1. Turn on EasyBCD, go to the "Add/Remove Entries" screen and pick Linux from the tabs at the top.&lt;br /&gt;   2. Pick the appropriate bootloader from the drop-down menu (either GRUB or LILO),&lt;br /&gt;   3. Give the entry a user-friendly name (and if you want to keep "NST Linux Loader" as the text, we won't say no!)&lt;br /&gt;   4. The hardest part of this mind-numbingly difficult exercise (/sarcasm) is choosing the correct hard drive and partition numbers that correspond to the partition you installed Linux (and most importantly, the bootloader) to.&lt;br /&gt;      In EasyBCD (and Windows in general), drive numbers start at 0, and partitions start at 1. So the second partition of the first drive would be 0, 2.&lt;br /&gt;   5. Press "Add Entry" and reboot.&lt;br /&gt;&lt;br /&gt;When the Vista bootloader asks you what OS you'd like to boot into, select Linux to continue the first-run configuration for your brand-spanking-new Linux install.&lt;br /&gt;&lt;br /&gt;It's that simple!&lt;br /&gt;Linux before Vista&lt;br /&gt;&lt;br /&gt;These steps assume you had a fully working Linux install before you installed Windows Vista. It also assumes that you've been using either GRUB or LILO to boot Linux in the past. If you used some other bootloader, please consult the appropriate documentation on their respective website(s).&lt;br /&gt;&lt;br /&gt;At this point, you have two options. The first option is more compatible &amp; more reliable, but it can be a hassle depending on just how much Linux experience you have. The second uses the all-new NeoGrub bootloader in conjunction with the Vista BCD to get Linux running - but it only works on a limited subset of setups. Skip down to the NeoGrub section for more info.&lt;br /&gt;Reinstall the Bootloader&lt;br /&gt; Useful Information&lt;br /&gt;We don't want to install the Linux bootloader back onto the MBR, because that'll just erase the Vista bootloader - leaving you with Linux and nothing else. So we install the bootloader onto a hidden sector called a "bootsector" and we tell Windows Vista where it's installed - then Windows Vista launches (chainloads) this sector on the disk, starting the Linux bootloader up for us.&lt;br /&gt;&lt;br /&gt;At this point, we need to install GRUB to the bootsector of our system. You have two ways to proceed: the first is to boot into Linux via a Live CD or a recovery disk. The second (easier) method is to use Super Grub Disk to reinstall GRUB.&lt;br /&gt;Booting into Linux&lt;br /&gt;&lt;br /&gt;Reinstalling GRUB in a correct requires that you run the GRUB program from within Linux. If you can boot into your Linux installation or you have a working Live CD, you may do so now. Once the desktop loads, open a console window (like a dos prompt in Windows).&lt;br /&gt;&lt;br /&gt;Once the console is open, run the following command:&lt;br /&gt;&lt;br /&gt;su -&lt;br /&gt;bash&lt;br /&gt;grub&lt;br /&gt;&lt;br /&gt;You should now be in a GRUB shell - basically an OS within an OS. If you're using Ubuntu or other distributions that work in a similar fashion, use this instead:&lt;br /&gt;&lt;br /&gt;sudo bash&lt;br /&gt;grub&lt;br /&gt;&lt;br /&gt;At this point, skip this next section and move on to "Installing GRUB"&lt;br /&gt;Booting into Super Grub Disk&lt;br /&gt;&lt;br /&gt;If you don't have a Live CD or you're not comfortable with Linux - no problem.&lt;br /&gt;&lt;br /&gt;"Super Grub Disk" is a really nifty utility for recovering your GRUB bootloader from a bootable floppy, CD, DVD, or even USB Stick. NeoSmart Technologies has provided a mirror of Super Grub Disk for your convenience - it's only 400kb. Extract the archive to your desktop, and burn the ISO to a blank CD with your favorite application. If you so choose, you can elect to install it to a floppy or USB stick instead by following these instructions.&lt;br /&gt;&lt;br /&gt;Once you have SGD installed to a CD, reboot your PC and boot from the CD. Choose "English" from the Language selection screen, then once SGD has loaded, press a key to continue. At the SGD menu, press the letter 'c' to enter a GRUB prompt.&lt;br /&gt;&lt;br /&gt;At this point, a GRUB shell will open, and you can proceed to the next step.&lt;br /&gt;Installing GRUB&lt;br /&gt;&lt;br /&gt;Now that you're within the GRUB program (by means of a Live CD or SGD), continue with the following:&lt;br /&gt;&lt;br /&gt;find /boot/grub/stage1&lt;br /&gt;&lt;br /&gt;It'll return a (hdx,y) value you can use to setup GRUB. (If it doesn't, you may need to play around with the path to stage1 which changes from distro to distro, but most likely this is what you're looking for.)&lt;br /&gt;&lt;br /&gt;In Linux, both drive and partition numbers start from zero. For example, if you had Windows on the first partition of the first drive, and Linux on the second partition of the same drive, you would use hd(0,1) to refer to the second partition of the first drive. Read Drive Letters and Numbers for more info and a colorful history of this topic.&lt;br /&gt;&lt;br /&gt;(hd0,0)   first primary partition on first hard disk&lt;br /&gt;(hd0,1)   second primary partition&lt;br /&gt;(hd0,2)   third primary partition&lt;br /&gt;(hd0,3)   fourth primary partition (usually an extended partition)&lt;br /&gt;(hd0,4)   first logical partition&lt;br /&gt;(hd0,5)   second logical partition ...&lt;br /&gt;&lt;br /&gt;Once you've got that value, type this in, substituting (hdx,y) for the output of the previous command.&lt;br /&gt;&lt;br /&gt;root (hdx,y)&lt;br /&gt;setup (hdx,y)&lt;br /&gt;setup (hdx,y)&lt;br /&gt;quit&lt;br /&gt;&lt;br /&gt;The setup line is repeated twice because often times the first GRUB setup command will error out, and the second will succeed - because of changes made by the first. No harm done running it twice. We've just installed GRUB to the bootsector of the partition. (If we wanted to install it to the MBR, we would have written hdx only - but we don't want to do that!)&lt;br /&gt;&lt;br /&gt;If you're using a Live CD, restart your PC now. The shutdown -r 0 command will reboot your PC. Make sure you've removed the CD from the drive so that you can get back into Windows Vista.&lt;br /&gt;Back in Windows Vista&lt;br /&gt;&lt;br /&gt;At this point, you should be back in Windows Vista with either GRUB or LILO tucked away in a hidden sector somewhere on your drive. Fire up everyone's favorite bootloader manager (why, EasyBCD, of course!) and go to the "Add\Remove Entries" screen.&lt;br /&gt;&lt;br /&gt;   1. Choose "Linux\BSD" from the tabs on the top.&lt;br /&gt;   2. Select either GRUB or LILO from the drop-down menu depending on what you configured earlier.&lt;br /&gt;   3. Choose the correct drive and partition number for your Linux partition. This should be the same partition as the one we just finished configuring. Refer to the image above for an example.&lt;br /&gt;   4. Enter the name you would like to give the Linux entry in the bootloader.&lt;br /&gt;   5. Press "Add Entry" and reboot to test.&lt;br /&gt;&lt;br /&gt;These steps can be a bit tricky, and making mistakes could lead to some unwanted trouble (but don't worry, nothing that can't be fixed without dataloss). If you're hesitant about something, don't risk it - just ask for help.&lt;br /&gt;Method 2: Using NeoGrub to boot Linux&lt;br /&gt;&lt;br /&gt;NeoGrub is NeoSmart Technologies' implementation of the open-source GRUB bootloader (ported over to Windows by the Grub4Dos team) intended to allow Windows users to boot into Linux without having to resort to rescue discs, second bootloaders, or messy install routines for GRUB or LILO.&lt;br /&gt;&lt;br /&gt;NeoGrub is the recommended solution for *nix-phobics - and for people that don't have a rescue/live CD on hand. It's a nifty way of getting Linux to boot quickly and efficiently without spending hours switiching CDs and rebooting your PC over and over again.&lt;br /&gt;&lt;br /&gt;NeoGrub can be used to read existing menu.lst files from old dual-boot setups and allows for fine-grain control over dual-boot settings for experienced users.&lt;br /&gt;External Links&lt;br /&gt;&lt;br /&gt;These are links to external (non-NST) guides that revolve around dual-booting Windows Vista and Linux - with the help of EasyBCD. Please note that these articles were written with regards to EasyBCD 1.5x — EasyBCD 1.6 has some new features that make certain steps used in these guys no longer necessary.&lt;br /&gt;&lt;br /&gt;    * Herman's excellent Guide to GRUB (via SGD)&lt;br /&gt;    * APC Magazine's Vista &amp; Linux Dual Boot Guides&lt;br /&gt;    * GNU GRUB Native Installation Docs (no details, rather useless)&lt;br /&gt;&lt;br /&gt;Children (2)&lt;br /&gt;  Hide Children  |  View in Hierarchy&lt;br /&gt;[Fedora] Fedora&lt;br /&gt;[Ubuntu] Ubuntu&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-4184503038013017222?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/4184503038013017222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=4184503038013017222' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/4184503038013017222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/4184503038013017222'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/10/grub-and-bcd-edit.html' title='grub and bcd edit'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-4227604994082666917</id><published>2009-09-22T13:39:00.000-07:00</published><updated>2009-09-22T13:40:10.621-07:00</updated><title type='text'>Htaccess</title><content type='html'>.htaccess is used to allow access to httpd apart from hosts.allow and hosts.deny :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-4227604994082666917?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/4227604994082666917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=4227604994082666917' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/4227604994082666917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/4227604994082666917'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/09/htaccess.html' title='Htaccess'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-8256250154830347303</id><published>2009-08-31T21:01:00.001-07:00</published><updated>2009-08-31T21:01:32.096-07:00</updated><title type='text'>Heap</title><content type='html'>http://www.openasthra.com/multithreading/heap-overview/&lt;br /&gt;&lt;br /&gt;An Overview of Heap Overflow&lt;br /&gt;&lt;br /&gt;Each threads of a running program has a stack where local variables are stored. In&lt;br /&gt;virtual memory space&lt;br /&gt;linux all program has a .BSS (global and static uninitialized varibles) and&lt;br /&gt;.DATA segment (global and static initialized varibles) along with other segments&lt;br /&gt;used by malloc() and allocated with brk() - Sets the end of data segment to the&lt;br /&gt;values specified or mmap() - map file into memory, it ask length bytes&lt;br /&gt;starting at offset from the file specified by the file descriptor fd into&lt;br /&gt;memory, preferably at address start.&lt;br /&gt;&lt;br /&gt;malloc() breaks up a chunk of memory allocated using brk() into small parts and&lt;br /&gt;gives the user one of those part when a request is made.&lt;br /&gt;It used various&lt;br /&gt;techniques like smallest-first, best-fit, next best fit, first-fit etc.&lt;br /&gt;Lot&lt;br /&gt;of meta-data about the location of the chunks, ths size of the chunks and other&lt;br /&gt;special area for small parts.&lt;br /&gt;All these is information are organized into&lt;br /&gt;buckets and in some others into balanced tree structure.&lt;br /&gt;&lt;br /&gt;So like stack&lt;br /&gt;overflow we can overflow heap also, by overwriting those meta-data.&lt;br /&gt;&lt;br /&gt;One such vulenrable program is cprog1.c&lt;br /&gt;&lt;br /&gt;[highlight lang=”CPP”]&lt;br /&gt;#define BLOCKSIZE 666&lt;br /&gt;int main(int argc, char *argv[])&lt;br /&gt;{&lt;br /&gt;char *pcBuf1, *pcBuf2;&lt;br /&gt;pcBuf1 = (char *) malloc (BLOCKSIZE);&lt;br /&gt;pcBuf2 = (char *) malloc (BLOCKSIZE);&lt;br /&gt;printf(”Buffer 1: %p Buffer 2: %pn”,pcBuf1,pcBuf2)&lt;br /&gt;strcpy(pcBuf1,argv[1]);&lt;br /&gt;free(pcBuf2);&lt;br /&gt;free(pcBuf1);&lt;br /&gt;}&lt;br /&gt;[/highlight]&lt;br /&gt;&lt;br /&gt;$&gt; gcc -o cprog1 cprog1.c&lt;br /&gt;$&gt; ./cprog1&lt;br /&gt;Buffer1: 0×9017008 Buffer2: 0×90172a8***glibc detected *** double free or corruption (out): 0×90172a8 ***Aborted&lt;br /&gt;&lt;br /&gt;Here we are overflowing&lt;br /&gt;&lt;br /&gt;Buffer2 with the data in&lt;br /&gt;&lt;br /&gt;argv[1]&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;malloc implementations, including Linux’s dlmalloc, store&lt;br /&gt;extra information in a free chunk. As free chunks can be used to store&lt;br /&gt;information about other chunks.&lt;br /&gt;&lt;br /&gt;Note: The output of all the programs&lt;br /&gt;discussed here will be complier/platform dependent.&lt;br /&gt;&lt;br /&gt;Instead of malloc we&lt;br /&gt;could have used something like&lt;br /&gt;&lt;br /&gt;p = (char *) sbrk(BLOCKSIZE);&lt;br /&gt;&lt;br /&gt;But it isn’t efficient,&lt;br /&gt;portable. What about free?&lt;br /&gt;&lt;br /&gt;Allocation Algorithms :&lt;br /&gt;&lt;br /&gt;Following are some of the memory allocation&lt;br /&gt;algorithms used.&lt;br /&gt;&lt;br /&gt;    * First Fit&lt;br /&gt;          o Keep a linked list of free node&lt;br /&gt;          o Search for the first one that’s BIG enough&lt;br /&gt;    * Best Fit&lt;br /&gt;          o Keep a linked list of free node&lt;br /&gt;          o Search for the smallest one that’s BIG enough&lt;br /&gt;    * Free list: A circular list&lt;br /&gt;&lt;br /&gt;[tags] heap usage, heap, heap overview, heap in&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-8256250154830347303?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/8256250154830347303/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=8256250154830347303' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/8256250154830347303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/8256250154830347303'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/heap.html' title='Heap'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-8153531025829287099</id><published>2009-08-31T20:59:00.001-07:00</published><updated>2009-08-31T20:59:26.440-07:00</updated><title type='text'>Some algorithms</title><content type='html'>. Reverse a singly linked list&lt;br /&gt;&lt;br /&gt;    //&lt;br /&gt;    // iterative version&lt;br /&gt;    //&lt;br /&gt;    Node* ReverseList( Node ** List )   &lt;br /&gt;    {&lt;br /&gt;      Node *temp1 = *List;&lt;br /&gt;      Node * temp2 = NULL;&lt;br /&gt;      Node * temp3 = NULL;&lt;br /&gt;     &lt;br /&gt;      while ( temp1 )&lt;br /&gt;      {&lt;br /&gt;        //set the head to last node&lt;br /&gt;        *List = temp1;       &lt;br /&gt;     &lt;br /&gt;        // save the next ptr in temp2 &lt;br /&gt;        temp2= temp1-&gt;pNext; &lt;br /&gt;     &lt;br /&gt;        // change next to privous&lt;br /&gt;        temp1-&gt;pNext = temp3; &lt;br /&gt;        temp3 = temp1;&lt;br /&gt;        temp1 = temp2;&lt;br /&gt;      }&lt;br /&gt;     &lt;br /&gt;      return *List;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;2. Delete a node in double linked list&lt;br /&gt;&lt;br /&gt;    void deleteNode(node *n)&lt;br /&gt;    {&lt;br /&gt;      node *np = n-&gt;prev;&lt;br /&gt;      node *nn = n-&gt;next;&lt;br /&gt;      np-&gt;next = n-&gt;next;&lt;br /&gt;      nn-&gt;prev = n-&gt;prev;&lt;br /&gt;      delete n;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;3. Sort a linked list&lt;br /&gt;&lt;br /&gt;    //sorting in descending order&lt;br /&gt;    struct node&lt;br /&gt;    {&lt;br /&gt;      int value;&lt;br /&gt;      node* NEXT;&lt;br /&gt;    }&lt;br /&gt;    //Assume HEAD pointer denotes the first &lt;br /&gt;    //element in the linked list&lt;br /&gt;    //only change the values? don't have to &lt;br /&gt;    //change the pointers&lt;br /&gt;    Sort( Node *Head)&lt;br /&gt;    {&lt;br /&gt;      node* first,second,temp;&lt;br /&gt;      first= Head;&lt;br /&gt;      while(first!=null)&lt;br /&gt;      {&lt;br /&gt;        second=first-&gt;NEXT;&lt;br /&gt;        while(second!=null)&lt;br /&gt;        {&lt;br /&gt;          if(first-&gt;value &lt; second-&gt;value)&lt;br /&gt;          {&lt;br /&gt;            temp = new node();&lt;br /&gt;            temp-&gt;value=first-&gt;value;&lt;br /&gt;            first-&gt;value=second-&gt;value;&lt;br /&gt;            second-&gt;value=temp-&gt;value;&lt;br /&gt;            delete temp;&lt;br /&gt;          }&lt;br /&gt;          second=second-&gt;NEXT;&lt;br /&gt;        }&lt;br /&gt;        first=first-&gt;NEXT;&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;4. Reverse a string&lt;br /&gt;&lt;br /&gt;    void ReverseString (char *String)&lt;br /&gt;    {&lt;br /&gt;      char *Begin = String;&lt;br /&gt;      char *End = String + strlen(String) - 1;&lt;br /&gt;      char TempChar;&lt;br /&gt;     &lt;br /&gt;      while (Begin &lt; End)&lt;br /&gt;      {&lt;br /&gt;        TempChar = *Begin;&lt;br /&gt;        *Begin = *End;&lt;br /&gt;        *End = TempChar;&lt;br /&gt;        Begin++;&lt;br /&gt;        End- -;&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;5. Insert a node a sorted linked list&lt;br /&gt;&lt;br /&gt;    void sortedInsert(Node * head, Node* newNode)&lt;br /&gt;    {&lt;br /&gt;      Node *current = head;&lt;br /&gt;     &lt;br /&gt;      // traverse the list until you find &lt;br /&gt;      //item bigger the new node value&lt;br /&gt;      //   &lt;br /&gt;      while ((current!= NULL) &amp;&amp; &lt;br /&gt;             (current-&gt;data &lt; newNode-&gt;data))&lt;br /&gt;      {&lt;br /&gt;        current = current-&gt;next;&lt;br /&gt;      }&lt;br /&gt;      //&lt;br /&gt;      // insert the new node before the big item&lt;br /&gt;      //&lt;br /&gt;      newNode-&gt;next = current-&gt;next;&lt;br /&gt;      current = newNode;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;6. Covert a string to upper case&lt;br /&gt;&lt;br /&gt;    void ToUpper(char * S)&lt;br /&gt;    {&lt;br /&gt;      while (*S!=0)&lt;br /&gt;      {&lt;br /&gt;        *S=(*S &gt;= 'a' &amp;&amp; *S &lt;= 'z')?(*S-'a'+'A'):*S;&lt;br /&gt;        S++;&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;7. Multiple a number by 7 without using * and + operator.&lt;br /&gt;&lt;br /&gt;    // mulitplied by 2 ^ 3 = 8&lt;br /&gt;    NewNum = Num &lt;&lt; 3; &lt;br /&gt;     &lt;br /&gt;    // 8 � 1 = 7&lt;br /&gt;    NewNum = NewNum - Num;&lt;br /&gt;&lt;br /&gt;8. Write a function that takes in a string parameter and checks to see whether or not it is an integer, and if it is then return the integer value.&lt;br /&gt;&lt;br /&gt;    9574719ba5683186a52a574383d220e9007 &lt;br /&gt;&lt;br /&gt;9. Print a data from a binary tree - In-order(ascending)&lt;br /&gt;&lt;br /&gt;    //&lt;br /&gt;    // recursive version&lt;br /&gt;    //&lt;br /&gt;     &lt;br /&gt;    Void PrintTree ( struct * node node )&lt;br /&gt;    {&lt;br /&gt;      if ( node == NULL )&lt;br /&gt;        return;&lt;br /&gt;     &lt;br /&gt;      PrintTree(node-&gt;left );&lt;br /&gt;      printf("%d", node-&gt;data);&lt;br /&gt;      PrintTree(node-&gt;right );&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;10. print integer using only putchar&lt;br /&gt;&lt;br /&gt;    //&lt;br /&gt;    // recursive version&lt;br /&gt;    //&lt;br /&gt;    void PrintNum ( int Num )&lt;br /&gt;    {&lt;br /&gt;      if ( Num == 0 )&lt;br /&gt;        return;&lt;br /&gt;      PrintNum ( Num / 10 );&lt;br /&gt;      puthcar ( '0'+ Num % 10 );&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;11. Find the factorial of number&lt;br /&gt;&lt;br /&gt;    //&lt;br /&gt;    // recursive version&lt;br /&gt;    //&lt;br /&gt;     &lt;br /&gt;    int Factorial( int Num )&lt;br /&gt;    {&lt;br /&gt;      if ( num &gt; 0 )&lt;br /&gt;        return Num * Factorial ( Num �1 ); &lt;br /&gt;      else&lt;br /&gt;        return 1;&lt;br /&gt;    }&lt;br /&gt;     &lt;br /&gt;    //&lt;br /&gt;    // iterative version&lt;br /&gt;    //&lt;br /&gt;     &lt;br /&gt;    int Factorial( int Num )&lt;br /&gt;    {&lt;br /&gt;      int I&lt;br /&gt;      int result = 1;&lt;br /&gt;     &lt;br /&gt;      for ( I= Num; I &gt; 0; I- - )&lt;br /&gt;      {&lt;br /&gt;        result = result * I;&lt;br /&gt;      }&lt;br /&gt;     &lt;br /&gt;      return result;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;12. Generate Fib numbers:&lt;br /&gt;&lt;br /&gt;    // recursive version&lt;br /&gt;    int fib( n ) &lt;br /&gt;    {&lt;br /&gt;      if ( n &lt; 2 )&lt;br /&gt;        return 1;&lt;br /&gt;      else&lt;br /&gt;        return fib ( n-1 ) + fib ( n-2 );&lt;br /&gt;    }&lt;br /&gt;     &lt;br /&gt;    //iterative version&lt;br /&gt;    int fib( n ) &lt;br /&gt;    {&lt;br /&gt;      int f1 =1, f2 = 1;&lt;br /&gt;     &lt;br /&gt;      if ( n &lt; 2 )&lt;br /&gt;        return 1; &lt;br /&gt;      for ( i = 1; i &lt; N; i++)&lt;br /&gt;      {&lt;br /&gt;        f = f1 + f2;&lt;br /&gt;        f1= f2;&lt;br /&gt;        f = f1;&lt;br /&gt;      }&lt;br /&gt;      return f;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;13. Write a function that finds the last instance of a character in a string&lt;br /&gt;&lt;br /&gt;    char *lastchar(char *String, char ch)&lt;br /&gt;    {&lt;br /&gt;      char *pStr = NULL;&lt;br /&gt;     &lt;br /&gt;      // traverse the entire string&lt;br /&gt;     &lt;br /&gt;      while( * String ++ != NULL ) &lt;br /&gt;      {&lt;br /&gt;        if( *String == ch ) &lt;br /&gt;        pStr = String;&lt;br /&gt;      }&lt;br /&gt;     &lt;br /&gt;      return pStr;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;14. Return Nth the node from the end of the linked list in one pass.&lt;br /&gt;&lt;br /&gt;    Node * GetNthNode ( Node* Head , int NthNode )&lt;br /&gt;    {&lt;br /&gt;      Node * pNthNode = NULL;&lt;br /&gt;      Node * pTempNode = NULL;&lt;br /&gt;      int nCurrentElement = 0;&lt;br /&gt;     &lt;br /&gt;      for ( pTempNode = Head; &lt;br /&gt;            pTempNode != NULL; &lt;br /&gt;            pTempNode = pTempNode-&gt;pNext )&lt;br /&gt;      {&lt;br /&gt;        nCurrentElement++;   &lt;br /&gt;        if ( nCurrentElement - NthNode == 0 )&lt;br /&gt;        {&lt;br /&gt;          pNthNode = Head;&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        if ( nCurrentElement - NthNode &gt; 0)&lt;br /&gt;        {&lt;br /&gt;          pNthNode = pNthNode -&gt;pNext;&lt;br /&gt;        }     &lt;br /&gt;      }&lt;br /&gt;      if (pNthNode )&lt;br /&gt;      {&lt;br /&gt;        return pNthNode;&lt;br /&gt;      }&lt;br /&gt;      else&lt;br /&gt;        return NULL;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;15. Counting set bits in a number.&lt;br /&gt;&lt;br /&gt;    //First version:&lt;br /&gt;    int CoutSetBits(int Num)&lt;br /&gt;    {&lt;br /&gt;      for(int count=0; Num; Num &gt;&gt;= 1)&lt;br /&gt;      {&lt;br /&gt;        if (Num &amp; 1) &lt;br /&gt;        count++;&lt;br /&gt;      }&lt;br /&gt;      return count;&lt;br /&gt;    }&lt;br /&gt;     &lt;br /&gt;    //Optimized version:&lt;br /&gt;    int CoutSetBits(int Num)&lt;br /&gt;    {&lt;br /&gt;      for(int count =0; Num; count++)&lt;br /&gt;      {&lt;br /&gt;        Num &amp;= Num -1;&lt;br /&gt;      }&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-8153531025829287099?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/8153531025829287099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=8153531025829287099' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/8153531025829287099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/8153531025829287099'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/some-algorithms.html' title='Some algorithms'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-3918578901510472683</id><published>2009-08-31T20:56:00.001-07:00</published><updated>2009-08-31T20:56:37.294-07:00</updated><title type='text'>auto_ptr in C++</title><content type='html'>In C++, local instances (these not allocated by hand) have their destructors run as soon as they go out of scope. This behavior is explored in a few different schemes, besides its obvious intent of destructing the instance. The most known one is the auto_ptr class, part of the STL. It is merely a memory guard which takes care of deallocating the given pointer once its own scope is over. In the short example below, the s variable won’t leak.&lt;br /&gt;&lt;br /&gt;#include&lt;br /&gt;using namespace std;&lt;br /&gt;void f()&lt;br /&gt;{&lt;br /&gt;  char *s = strdup("foobar");&lt;br /&gt;  auto_ptr sp(s);&lt;br /&gt;  cout &lt;&lt; sp.get();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;While this is an interesting place to use this concept, it’s a good algorithm to be aware of generically. A good example of how useful this could be is how the apt-shell (part of APT-RPM) cache guard mechanism was implemented. This program was implemented as a refactoring of apt-get, but they have a fundamental difference: while apt-get is a one-shot program (run just once, and get back to the user), apt-shell maintains the internal cache (the structure where information about the packages is kept) alive for a long time, and changes it in many different ways during its execution time. Thus, I had to implement some way to make it easy to protect this cache against being unadvisedly changed in all these functions coming from apt-get. To do that, I have implemented an AutoRestore class which takes care of restoring the original state of the cache, unless explicitly told to release it. Here is the complete class, from apt-shell.cc:&lt;br /&gt;&lt;br /&gt;class AutoRestore  {&lt;br /&gt;&lt;br /&gt;  pkgDepCache::State State;&lt;br /&gt;&lt;br /&gt;  bool Guarded;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt;&lt;br /&gt;  inline pkgDepCache::State *operator -&gt;() {return &amp;State;};&lt;br /&gt;&lt;br /&gt;  inline pkgDepCache::State *operator &amp;() {return &amp;State;};&lt;br /&gt;&lt;br /&gt;  inline void UnGuard() { Guarded = false; };&lt;br /&gt;&lt;br /&gt;  AutoRestore(pkgDepCache &amp;Cache)  : State(&amp;Cache), Guarded(true) {};&lt;br /&gt;&lt;br /&gt;  ~AutoRestore() { if (Guarded) State.Restore(); };&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To use it, it’s just a matter of creating a local instance, passing the cache to the constructor. It will take care of undoing unexpected changes. Really comfortable! [tags]auto_ptr[/tags]&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-3918578901510472683?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/3918578901510472683/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=3918578901510472683' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/3918578901510472683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/3918578901510472683'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/autoptr-in-c.html' title='auto_ptr in C++'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-4019670696696849915</id><published>2009-08-31T20:55:00.000-07:00</published><updated>2009-08-31T20:56:03.440-07:00</updated><title type='text'>inline functions</title><content type='html'>Yes and no. Sometimes. Maybe.&lt;br /&gt;&lt;br /&gt;There are no simple answers. inline functions might make the code faster, they might make it slower. They might make the executable larger, they might make it smaller. They might cause thrashing, they might prevent thrashing. And they might be, and often are, totally irrelevant to speed.&lt;br /&gt;&lt;br /&gt;inline functions might make it faster: procedural integration might remove a bunch of unnecessary instructions, which might make things run faster.&lt;br /&gt;&lt;br /&gt;inline functions might make it slower: Too much inlining might cause code bloat, which might cause “thrashing” on demand-paged virtual-memory systems. In other words, if the executable size is too big, the system might spend most of its time going out to disk to fetch the next chunk of code.&lt;br /&gt;&lt;br /&gt;inline functions might make it larger: This is the notion of code bloat, as described above. For example, if a system has 100 inline functions each of which expands to 100 bytes of executable code and is called in 100 places, that’s an increase of 1MB. Is that 1MB going to cause problems? Who knows, but it is possible that that last 1MB could cause the system to “thrash,” and that could slow things down.&lt;br /&gt;&lt;br /&gt;inline functions might make it smaller: The compiler often generates more code to push/pop registers/parameters than it would by inline-expanding the function’s body. This happens with very small functions, and it also happens with large functions when the optimizer is able to remove a lot of redundant code through procedural integration ? that is, when the optimizer is able to make the large function small.&lt;br /&gt;&lt;br /&gt;inline functions might cause thrashing: Inlining might increase the size of the binary executable, and that might cause thrashing.&lt;br /&gt;&lt;br /&gt;inline functions might prevent thrashing: The working set size (number of pages that need to be in memory at once) might go down even if the executable size goes up. When f() calls g(), the code is often on two distinct pages; when the compiler procedurally integrates the code of g() into f(), the code is often on the same page.&lt;br /&gt;&lt;br /&gt;inline functions might increase the number of cache misses: Inlining might cause an inner loop to span across multiple lines of the memory cache, and that might cause thrashing of the memory-cache.&lt;br /&gt;&lt;br /&gt;inline functions might decrease the number of cache misses: Inlining usually improves locality of reference within the binary code, which might decrease the number of cache lines needed to store the code of an inner loop. This ultimately could cause a CPU-bound application to run faster.&lt;br /&gt;&lt;br /&gt;inline functions might be irrelevant to speed: Most systems are not CPU-bound. Most systems are I/O-bound, database-bound or network-bound, meaning the bottleneck in the system’s overall performance is the file system, the database or the network. Unless your “CPU meter” is pegged at 100%, inline functions probably won’t make your system faster. (Even in CPU-bound systems, inline will help only when used within the bottleneck itself, and the bottleneck is typically in only a small percentage of the code.)&lt;br /&gt;&lt;br /&gt;There are no simple answers: You have to play with it to see what is best. Do not settle for simplistic answers like, “Never use inline functions” or “Always use inline functions” or “Use inline functions if and only if the function is less than N lines of code.” These one-size-fits-all rules may be easy to write down, but they will produce sub-optimal results.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-4019670696696849915?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/4019670696696849915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=4019670696696849915' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/4019670696696849915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/4019670696696849915'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/inline-functions.html' title='inline functions'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-6683576467235375886</id><published>2009-08-31T20:30:00.001-07:00</published><updated>2009-08-31T20:30:49.532-07:00</updated><title type='text'>Difference between C in UNIX and C on DOS</title><content type='html'>There is no difference but UNIX is a multitasking, multi-user OS unlike DOS. In DOS, serial multi-tasking can be achieved but it makes the computer work less efficiently. If, for example, there was some calculation being done and we called in Sidekick, then all work on the calculations would stop as the computer responded to Sidekick. Wouldn’t it then be far better to give Sidekick only a part of the computer’s time? So that even while we were in Sidekick the calculations would carry on being performed in the background.&lt;br /&gt;&lt;br /&gt;Under UNIX, all we have to do is to compile and link the background while we carry on doing whatever else we want in the foreground.&lt;br /&gt;&lt;br /&gt;Background Process:&lt;br /&gt;&lt;br /&gt;    main()&lt;br /&gt;    {&lt;br /&gt;      long l;&lt;br /&gt;      for(i=0;i&lt;=4000000;i++);&lt;br /&gt;        printf("l is %d \n",i);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    1)Compile it at UNIX prompt by saying CC&lt;program name&gt;.&lt;br /&gt;&lt;br /&gt;    2)The file generated will be a.out.&lt;br /&gt;&lt;br /&gt;    3)Execute it through the command a.out &amp;. The &amp; will make it a background process which is terminated only if process ends, or is interrupted with a DEL.&lt;br /&gt;&lt;br /&gt;The UNIX prompt will come back on screen immediately. Load the editor again and wait. After some time a l is 4000000 will be displayed at the top left corner of the screen.&lt;br /&gt;&lt;br /&gt;Isn’t this more convenient than DOS’s single tasking environment?&lt;br /&gt;&lt;br /&gt;UNIX is able to switch between processes because each process has an identification number. This identification number identifies the variables and REGISTER values that are associated with this process. These variables are in a state of limbo when the process is suspended. And get activated again once the microprocessor resumes execution of the process. &lt;br /&gt;&lt;br /&gt;Process Identification:&lt;br /&gt;&lt;br /&gt;/*There is a UNIX function getpid()- that enables us to get the identification number of a process*/&lt;br /&gt;&lt;br /&gt;    main()&lt;br /&gt;    {&lt;br /&gt;      int pid;&lt;br /&gt;      pid=getpid();&lt;br /&gt;      print("Process ID is %d\n",pid);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;The pid value will depend on the number of processes already running. It will always be unique.&lt;br /&gt;&lt;br /&gt;Parent And Child:&lt;br /&gt;&lt;br /&gt;A process in UNIX is not a stand-alone. This results in a parent-child relationship existing between processes.&lt;br /&gt;&lt;br /&gt;    main()&lt;br /&gt;    {&lt;br /&gt;      int ppid;&lt;br /&gt;      ppid=getppid();&lt;br /&gt;      print("Parent Process ID is %d\n",ppid);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;This program will give the ID number of its parent. So who is this parent?&lt;br /&gt;&lt;br /&gt;When we boot the system, a special process called the SWAPPER or SCHEDULER is created with a PID of 0. The SWAPPER manages memory allocation for processes and influences CPU allocation. The SWAPPER in turn creates three children:the process dispatcher, vhand and bdflush with ID numbers 1,2,3 respectively.&lt;br /&gt;&lt;br /&gt;This is done by executing the file init which exists in the etc sub-directory. The dispatcher now gives birth to the shell. From now on all processes initiated by us are children of the shell.&lt;br /&gt;&lt;br /&gt;The fork():&lt;br /&gt;&lt;br /&gt;Processes initiated by us can also create children in the same manner as the swapper and the process dispatcher did. These children processes are created using the fork() function. It is by forking processes that we can exploit the multitasking capability of UNIX.&lt;br /&gt;&lt;br /&gt;    main()&lt;br /&gt;    {&lt;br /&gt;      fork();&lt;br /&gt;      printf("Hello World\n");&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;Can you guess what the output of this program will be?&lt;br /&gt;&lt;br /&gt;The statement Hello World will be displayed twice on screen. The fork() creates a child that is a duplicate of the parent process. The parent process in this case being the program listed above. Since now there are two identical processes in memory, the Hello World is printed twice.&lt;br /&gt;&lt;br /&gt;The moment a call is made to the fork(), a child process is created. The child copy, too, gets a copy of the variable pid, but with a value of 0 by default. The parent process, is returned a value greater than 0 by the fork().&lt;br /&gt;&lt;br /&gt;For UNIX is more than just a multi-tasking OS. It also has the facility to enable many users to access the machine it is housed in at one time. And not just access the machine at same time but also interact with each other.&lt;br /&gt;&lt;br /&gt;But how UNIX is able to take care of different users simultaneously?&lt;br /&gt;&lt;br /&gt;The kernel creates various processes that ultimately allows us to login. The first one is INIT process. INIT decides which of the terminals that can be used to login. The program GETTY, tells UNIX which program to execute. GETTY in turn reads data from the etc/gettydefs file, displays the login: prompt on screen and waits for input. After which it spawns the login program, which takes the login name we have keyed in as a parameter. Then INIT processes creates a child process by forking, through which login processes is executed with the help of exec() fuction.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-6683576467235375886?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/6683576467235375886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=6683576467235375886' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/6683576467235375886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/6683576467235375886'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/difference-between-c-in-unix-and-c-on.html' title='Difference between C in UNIX and C on DOS'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-3761849083481835789</id><published>2009-08-31T20:27:00.000-07:00</published><updated>2009-08-31T20:28:00.571-07:00</updated><title type='text'>Bad APIs at a glance</title><content type='html'>Bad APIs at a glance&lt;br /&gt;&lt;br /&gt;strcpy — Too easy to create a buffer overrun&lt;br /&gt;strcat   –  Too easy to create a buffer overrun&lt;br /&gt;strncpy   –  Deceptive. Doesn’t always NUL terminate!&lt;br /&gt;strncat   –  Deceptive. Doesn’t always NUL terminate!&lt;br /&gt;wstrcpy   –  Too easy to create a buffer overrun&lt;br /&gt;wstrcat   –  Too easy to create a buffer overrun&lt;br /&gt;wstrncpy   –  Deceptive. Doesn’t always NUL terminate!&lt;br /&gt;wstrncat   –  Deceptive. Doesn’t always NUL terminate!&lt;br /&gt;sprintf   –  Difficult to avoid buffer overruns with complex format strings&lt;br /&gt;vsprintf  –  Difficult to avoid buffer overruns with complex format strings&lt;br /&gt;wsprintf –  Difficult to avoid buffer overruns with complex format strings&lt;br /&gt;gets   –  Impossible to be safe with gets&lt;br /&gt;strtok   –  Not reentrant&lt;br /&gt;&lt;br /&gt;strcpy and friends&lt;br /&gt;&lt;br /&gt; The problem&lt;br /&gt;&lt;br /&gt;There is no way to limit the number of characters copied to the&lt;br /&gt;destination buffer. Therefore there is potential for a buffer overflow&lt;br /&gt;when the source has a length greater than that of destination buffer.&lt;br /&gt;&lt;br /&gt;In the first code example below, the stack buffer aDest can be&lt;br /&gt;overrun if GetString returns a string longer than 9 characters. If an&lt;br /&gt;attacker can manipulate what GetString returns, perhaps because it is&lt;br /&gt;read out of a network protocol or out of a multimedia file, they can&lt;br /&gt;then manipulate the call stack. In the worst case they can cause a jump&lt;br /&gt;to any address on the device by overwriting the return address that is&lt;br /&gt;stored on the stack.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Strncpy, strncat&lt;br /&gt;&lt;br /&gt; strncpy is deceptive&lt;br /&gt;&lt;br /&gt;Strncpy will never copy past the end of the buffer given it which is&lt;br /&gt;good. However if the input won’t fit into the buffer it will fill the&lt;br /&gt;buffer and NOT terminate it with a NUL. Your string won’t be what you&lt;br /&gt;think it is and code reading the string will read off the end of the&lt;br /&gt;buffer. std_strlcpy will always NUL terminate whether or not the&lt;br /&gt;destination buffer is large enough.&lt;br /&gt;&lt;br /&gt;These comments apply to strncat, wstrncpy and wstrncat too.&lt;br /&gt;&lt;br /&gt;gets&lt;br /&gt;&lt;br /&gt;Gets has no way to bound how much is writes and worse what it writes&lt;br /&gt;by definition comes from an external source. This is probably the most&lt;br /&gt;dangerous function of the lot. Fortunately it is not widely used.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;sprintf&lt;br /&gt;&lt;br /&gt; Why sprintf is bad&lt;br /&gt;&lt;br /&gt;There is no way to limit the number of characters written to the&lt;br /&gt;destination. Therefore there is potential of buffer overflow when the&lt;br /&gt;resulting output has a length greater than that of destination buffer.&lt;br /&gt;&lt;br /&gt;strtok&lt;br /&gt;&lt;br /&gt; Why strtok is bad&lt;br /&gt;&lt;br /&gt;This function maintains internal state as a global variable&lt;br /&gt;. Because&lt;br /&gt;of that it is not re entrant and not safe in a multi-threaded&lt;br /&gt;environment. Calls to it from one thread to parse one string may&lt;br /&gt;interleave with calls to it from another thread to parse another&lt;br /&gt;string. The result will be that pointers one caller will get a pointer&lt;br /&gt;to the other callers string.&lt;br /&gt;&lt;br /&gt;Contemporary code is multi-threaded and thus it is not safe to use this. A bug&lt;br /&gt;caused by the use of this function will be very difficult to track down&lt;br /&gt;because it could be in code completely unrelated to the code&lt;br /&gt;manifesting the problem.&lt;br /&gt;&lt;br /&gt; What to do instead&lt;br /&gt;&lt;br /&gt;The function strtok_r is safe because the caller passed storage for&lt;br /&gt;the single pointer it can use to maintain the state it needs. Note that&lt;br /&gt;strtok_r should always be checked for a NULL return value.&lt;br /&gt;&lt;br /&gt;Scanf&lt;br /&gt;&lt;br /&gt;This discussion applies to sscanf as well as scanf. &lt;br /&gt;Why scanf is bad&lt;br /&gt;&lt;br /&gt;If you use %s with scanf without a field length qualifier there is&lt;br /&gt;no limit on how much data it will write to the buffer for the token&lt;br /&gt;matching %s.&lt;br /&gt;&lt;br /&gt;Also, as with any form of printf, the format string should be&lt;br /&gt;constant, or if not constant, unmodifiable from out side the software&lt;br /&gt;or the device. If the attacker can change the format string they can&lt;br /&gt;trivially overrun a buffer. &lt;br /&gt;Using scanf safely&lt;br /&gt;&lt;br /&gt;Always specify a length for %s.&lt;br /&gt;&lt;br /&gt;Always make the format string a compile time static const string (just use strings in quote marks like "%d %d").&lt;br /&gt;&lt;br /&gt;In general scanf is cumbersome and error prone for parsing input.&lt;br /&gt;Often other parsing approaches are better. If all you need is string to&lt;br /&gt;integer conversion, strtoul is better.&lt;br /&gt;&lt;br /&gt;[tags]bad standard apis, bad apis, dangerous standard APIs[/tags]&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-3761849083481835789?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/3761849083481835789/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=3761849083481835789' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/3761849083481835789'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/3761849083481835789'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/bad-apis-at-glance.html' title='Bad APIs at a glance'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-5708034687744271129</id><published>2009-08-31T20:26:00.001-07:00</published><updated>2009-08-31T20:26:59.012-07:00</updated><title type='text'>bffer overrun</title><content type='html'>What is a buffer overrun&lt;br /&gt;&lt;br /&gt;Simply stated it is running a read or write pointer off the end of the allocated buffer into some other buffer. Usually it occurs because pointer arithmatic is bad worse there’s not buffer length checking at all.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Why are they bad&lt;br /&gt;&lt;br /&gt;Hackers have figured out many ways to exploit buffer overruns to take over the device. In particular they can be used to load and run hostile code. Since handsets at this point in time still run mostly with a single memory space (little memory protection) a clever attacker can potentiall do the following:&lt;br /&gt;&lt;br /&gt;    * brick the phone so it has to go back to a service center&lt;br /&gt;    * break SIM locking&lt;br /&gt;    * take protected content&lt;br /&gt;    * reboot the phone&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Are some worse than others?&lt;br /&gt;&lt;br /&gt;In one sense all buffer overruns are the same and horribly bad because of the single memory space. They all give access to the whole handset.&lt;br /&gt;&lt;br /&gt;In another sense they are not the same because some are easier to discover than others. For example well known overruns in open source are the easiest.&lt;br /&gt;&lt;br /&gt;In another sense they are not all the same because some are easier to exploit than others. A one byte read overrun is not useful for an attacker. An overrun that smashes the stack that is easy to exploit via SMS is very useful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-5708034687744271129?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/5708034687744271129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=5708034687744271129' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/5708034687744271129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/5708034687744271129'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/bffer-overrun.html' title='bffer overrun'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-8633188384470064494</id><published>2009-08-31T20:22:00.000-07:00</published><updated>2009-08-31T20:26:11.567-07:00</updated><title type='text'>buffer overruns</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_jvvGtLIs87Y/SpyUSxyJvFI/AAAAAAAAAvA/pYNFxBNT-lA/s1600-h/fig2.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 161px;" src="http://3.bp.blogspot.com/_jvvGtLIs87Y/SpyUSxyJvFI/AAAAAAAAAvA/pYNFxBNT-lA/s320/fig2.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5376335105495776338" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_jvvGtLIs87Y/SpyUJQN6nXI/AAAAAAAAAu4/GSSkT56Mt30/s1600-h/fig1.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 205px;" src="http://2.bp.blogspot.com/_jvvGtLIs87Y/SpyUJQN6nXI/AAAAAAAAAu4/GSSkT56Mt30/s320/fig1.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5376334941866597746" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_jvvGtLIs87Y/SpyUCY3yAdI/AAAAAAAAAuw/8g2soeZgaZI/s1600-h/layout.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 139px; height: 320px;" src="http://2.bp.blogspot.com/_jvvGtLIs87Y/SpyUCY3yAdI/AAAAAAAAAuw/8g2soeZgaZI/s320/layout.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5376334823930593746" /&gt;&lt;/a&gt;&lt;br /&gt;http://www.openasthra.com/cc-programming-concepts/buffer-overruns-part1/&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Buffer Overruns/Overflows are typically caused by trusting input data to a function that is external and is unchecked. Most of the times, this is unintentionally invoked by bad sloppy code. However, when done intentionally by a hacker, this can cause havoc. Some of the most common, buffer overrun prone functions include strcpy, memcpy, strcat etc. (bad standard APIs are explained in another post) In unintentional buffer overruns/overflows, this mostly results in writing to memory not owned by your processes address space. In such cases this would end, in an access violation or a core dump, causing the program to be aborted in most cases. However, these buffer overruns can be exploited to run arbitrary code on the machine, even code that is injected in by the attacker.  Before going deep into this overruns let us understand the program executable layout, this helps us in better understanding of the overurns.&lt;br /&gt;&lt;br /&gt;Memory layout for a executable on linux is described below. The layout is called ELF (Executable and linkable format), windows counterpart format would be little different but it is similar to the ELF.&lt;br /&gt;&lt;br /&gt;program layout&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Text segment is read-only segment and it includes all the program instructions. All initialized variables (but not local variables) are stored in initialized data segment and all uninitialized variables are stored in BSS (block start by symbol). All malloc/new variables in heap segment, all auto/local variables will be in Stack. Lets take an example and see how variables are stored.&lt;br /&gt;&lt;br /&gt;Static int a;&lt;br /&gt;&lt;br /&gt;Int x = 1;&lt;br /&gt;&lt;br /&gt;Int y;&lt;br /&gt;&lt;br /&gt;Int main()&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;Int b;&lt;br /&gt;&lt;br /&gt;Char c[10];&lt;br /&gt;&lt;br /&gt;Int *d = (int *)malloc(sizeof(int));&lt;br /&gt;&lt;br /&gt;/*?. ?.*/&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;In the above program x is stored in initialized data segment, y is stored in BSS, b &amp; c are stored in stack, d is stored in heap. The stack frame in C contains args, return address, base pointer. Feeding more data to stack vars than they can hold will cause overwrite return address.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Stack Overruns: These type of buffer overruns occur, when a buffer that is declared on the stack is overwritten by copying more data than the buffer can hold. It so happens, that the variables (buffer in this case) declared on the stack are located next to the return address of the function?s caller (this is what we have discussed above). As I mentioned above, this usually occurs when user input is unchecked, e.g. strcat. And because the return address is next to the buffer on the stack, overwriting the buffer, means overwriting the return address, which is what gets executed with the function returns. An attacker can carefully exploit the overrun in such a way the data that is overwriting the return address, is an address of a function that he wants to execute.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Heap Overruns: Like Stack Overruns, Heap overruns can also cause memory and stack corruption. But unlike contrary developer belief, although heap overruns are harder to exploit, they are definitely exploitable.&lt;br /&gt;Array Indexing Errors (Overruns and Underruns): These type of errors are less exploited compared to static buffer overruns. You can think of an array as a block on memory (buffer) that you can index into and then read/write from that location. Bad array implementation do not check indices well before access the memory locations. Sloppy code like this can be exploited to run arbitrary code and create havoc. (Well, in some cases you may never ever now that your machine is freely accessible and controlled by the attacker ). Again, unlike contrary developer belief, don?t be fooled that only memory past the end of the array can be exploited.&lt;br /&gt;Format Strings Exploits: These type of exploits are not exactly buffer overruns, but they lead to the same class of problems. These errors are usually caused in functions that take in variable number of arguments, because there isn?t a good way for the function to determine the number of arguments passed into these functions. (printf family in the CRT). The %n type field for printf represents the number of characters successfully written so far to the stream or buffer. This value is stored in the integer whose address is given as the argument. So, this can basically be used to write into memory of the processes address space. But how can an attacker inject such code, the answer lies to the way the sloppy programmer writes code ala printf(input), rather than printf(?%s?, input). The latter prevent the user from using his own format, since its already defined, unlike the earlier case, where the input can be manipulated to create the format string.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Here are some buffer overrun examples explained?.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Casting exploitation:&lt;br /&gt;&lt;br /&gt;fig1&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Overflow:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;fig2&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Please post your comments so that we can eloborate more on required areas.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-8633188384470064494?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/8633188384470064494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=8633188384470064494' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/8633188384470064494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/8633188384470064494'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/buffer-overruns.html' title='buffer overruns'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_jvvGtLIs87Y/SpyUSxyJvFI/AAAAAAAAAvA/pYNFxBNT-lA/s72-c/fig2.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-7679846173630029092</id><published>2009-08-31T20:21:00.001-07:00</published><updated>2009-08-31T20:21:35.860-07:00</updated><title type='text'>padding</title><content type='html'>What is Padding?&lt;br /&gt;Aligning members of a structre to a byte boundary. Padding is done by compiler to gain the performance. Most hardware architectures&lt;br /&gt;access addresses fast if they are aligned properly, otherwise there will be performance penalty. In order to increase performance compiler pads structures.&lt;br /&gt;&lt;br /&gt;How Padding done?&lt;br /&gt;Normally processors require members of the structure aligned to byte boundary, for instance char member(1 byte) should be aligned to&lt;br /&gt;one byte boundary that is it can appear at any byte boundary, a short int(2 bytes) should be aligned to 2 byte boundary that is it should appear at 2 byte boundary, long int(4 bytes) should be aligned to 4 byte boundary. If we declare a basic data type in structure it should appear at sizeof(basic data type) byte boundary, in order to make the start address of the next member at an aligned address.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;Struct X&lt;br /&gt;{&lt;br /&gt;Char a;&lt;br /&gt;Short int b;&lt;br /&gt;Char c;&lt;br /&gt;Long&lt;br /&gt;d;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;| a(1) | P(1)| b(2) | c(1)| P(3) | d(4) |&lt;br /&gt;&lt;br /&gt;P - padding bytes&lt;br /&gt;&lt;br /&gt;Why Padding?&lt;br /&gt;If the processor is serious about alignment it raises an exception/signal (ex. SIGBUS), otherwise there will be a performance penalty&lt;br /&gt;will be there as misalignment slowdown data access.&lt;br /&gt;&lt;br /&gt;Are members order going to be changed?&lt;br /&gt;ANSI C requires fields of a structure need to allocated in the order they are declared.&lt;br /&gt;&lt;br /&gt;As a programmer how does padding matter to me?&lt;br /&gt;It matters if you are concerned about space it takes. By changing the members order of declarations, some amount space can be saved. For example&lt;br /&gt;Struct X&lt;br /&gt;{&lt;br /&gt;Char a;&lt;br /&gt;Long&lt;br /&gt;Int b;&lt;br /&gt;Char c;&lt;br /&gt;Long int d;&lt;br /&gt;Char e;&lt;br /&gt;Long int f;&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;Sizeof(struct X) = 24 bytes&lt;br /&gt;&lt;br /&gt;Lets reorder the above structure as below&lt;br /&gt;&lt;br /&gt;Struct X&lt;br /&gt;{&lt;br /&gt;Char a;&lt;br /&gt;Char c;&lt;br /&gt;Char e;&lt;br /&gt;Long Int b;&lt;br /&gt;Long int&lt;br /&gt;d;&lt;br /&gt;Long int f;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;Sizeof(struct X) = 16 bytes&lt;br /&gt;&lt;br /&gt;Padding is only done to members or to the structure as a whole&lt;br /&gt;also?&lt;br /&gt;Padding will be done by compiler to structure’s members and to the structure as a whole also. Compiler pads structure as whole because this allows each member of structure aligned in array of structures.&lt;br /&gt;&lt;br /&gt;Packed structures&lt;br /&gt;Some compilers provide #pragma to suppress padding or to make it packed to n number of bytes. Some provide keywords to do this.&lt;br /&gt;Generally pragma which is used for modifying structure padding will be in the below format (depends on compiler)&lt;br /&gt;#pragma pack(n)&lt;br /&gt;For example arm&lt;br /&gt;provides __packed keyword to suppress structure padding. Go through your compiler manual to know more about this.&lt;br /&gt;&lt;br /&gt;So a packed structure is a structure without padding.&lt;br /&gt;Generally packed structures will be used&lt;br /&gt;-&gt;to save space, and&lt;br /&gt;-&gt;to format a data structure to transmit over network using some protocol (this is not a good practice of course because you need to deal&lt;br /&gt;with endianness)&lt;br /&gt;&lt;br /&gt;How to declare array of packed structures?&lt;br /&gt;We can not declare array of packed structures as for declaring as an array we need each member of structure aligned. So alternatively either we can declare something like this&lt;br /&gt;Struct X&lt;br /&gt;{&lt;br /&gt;Unsigned char a;&lt;br /&gt;Unsigned long b;&lt;br /&gt;}array[NUM_ELEMENTS];&lt;br /&gt;&lt;br /&gt;The above structure yields compilation error, if we declare this as below, we should be able to handle..&lt;br /&gt;Unsigned char array_bytes[sizeof(structure) * NUM_ELEMENTS];&lt;br /&gt;And take special care while handling array_bytes.&lt;br /&gt;&lt;br /&gt;When I need to be careful about structure padding?&lt;br /&gt;1)when writing structures to a file on one machine and reading them on different machine&lt;br /&gt;This involves problem, consider this example&lt;br /&gt;Struct X&lt;br /&gt;{&lt;br /&gt;Char a;&lt;br /&gt;Long int b;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;x.a = 0�01;&lt;br /&gt;x.b = 0�02;&lt;br /&gt;&lt;br /&gt;If you write struct X to a file, it would have written 0�01 G G G 0�00 0�00 0�00 0�02 (G is garbled value, because this area is padded)&lt;br /&gt;While reading this on different machine(could be big endian) we read the structure as whole, on big-endian these values will be altered and as a result we read corrupted value for member a;&lt;br /&gt;Solution for this would be using a packed structures we can eliminate this.&lt;br /&gt;&lt;br /&gt;How can I pack structures Using GCC?&lt;br /&gt;Using the "packed" attribute against the members of a structure. This attribute mechanism is an extension to the GNU C compiler. An example of how you would do this is below.&lt;br /&gt;&lt;br /&gt;struct X&lt;br /&gt;{&lt;br /&gt;unsigned char a __attribute__((__packed__));&lt;br /&gt;unsigned&lt;br /&gt;short b __attribute__((__packed__));&lt;br /&gt;unsigned long c&lt;br /&gt;__attribute__((__packed__));&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;Another way to achieve the same is as shown below:&lt;br /&gt;struct X&lt;br /&gt;{&lt;br /&gt;unsigned char a;&lt;br /&gt;unsigned short b;&lt;br /&gt;unsigned long c;&lt;br /&gt;}&lt;br /&gt;__attribute__((__packed__));&lt;br /&gt;&lt;br /&gt;How can I pack structures Using ARM compiler?&lt;br /&gt;__packed keyword is used for this purpose, usage is shown below&lt;br /&gt;&lt;br /&gt;__packed struct X&lt;br /&gt;{&lt;br /&gt;char a;&lt;br /&gt;Long int b;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;May be in some other post, I try to give details about how padding done for&lt;br /&gt;global variables, pointers and etc. on some selected machines. Your comments,&lt;br /&gt;suggestions, criticism, etc. most welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-7679846173630029092?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/7679846173630029092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=7679846173630029092' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/7679846173630029092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/7679846173630029092'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/padding.html' title='padding'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-2722812652693391239</id><published>2009-08-31T20:17:00.001-07:00</published><updated>2009-08-31T20:21:01.970-07:00</updated><title type='text'>endianness</title><content type='html'>//returns zero for little endian&lt;br /&gt;//returns 1 for big endian&lt;br /&gt;//otherwise some error occured&lt;br /&gt;int find_endianness()&lt;br /&gt;{&lt;br /&gt;  int x = 0x01 ;&lt;br /&gt;  if (* (char *) &amp;x == 1)&lt;br /&gt;  {&lt;br /&gt;    //little endian&lt;br /&gt;    return 0;&lt;br /&gt;  }&lt;br /&gt;  else if (*((char *)&amp;x+sizeof(int)-1)==1)&lt;br /&gt;  {&lt;br /&gt;    //big endian&lt;br /&gt;    return 1;&lt;br /&gt;  }&lt;br /&gt;  else&lt;br /&gt;  {&lt;br /&gt;    //could not find what we have written in that byte&lt;br /&gt;    return -1;&lt;br /&gt;  }  &lt;br /&gt; &lt;br /&gt;  return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Big endian and little endian&lt;br /&gt;"Little Endian" means that the low-order byte of the number is stored in memory at the lowest address, and the high-order byte at the highest address. (The little end comes first.) For example, a 4 byte Long integer&lt;br /&gt;&lt;br /&gt;    Byte3 Byte2 Byte1 Byte0&lt;br /&gt;&lt;br /&gt;will be arranged in memory as follows:&lt;br /&gt;&lt;br /&gt;   Base Address+0  Byte0&lt;br /&gt;&lt;br /&gt;   Base Address+1  Byte1&lt;br /&gt;&lt;br /&gt;   Base Address+2  Byte2&lt;br /&gt;&lt;br /&gt;   Base Address+3  Byte3&lt;br /&gt;&lt;br /&gt;Intel processors (those used in PC’s) use "Little Endian" byte order.&lt;br /&gt;&lt;br /&gt;"Big Endian" means that the high-order byte of the number is stored in memory at the lowest address, and the low-order byte at the highest address. (The big end comes first.) Our LongInt, would then be stored as:&lt;br /&gt;&lt;br /&gt;  Base Address+0  Byte3&lt;br /&gt;&lt;br /&gt;  Base Address+1  Byte2&lt;br /&gt;&lt;br /&gt;  Base Address+2  Byte1&lt;br /&gt;&lt;br /&gt;  Base Address+3  Byte0&lt;br /&gt;&lt;br /&gt;Motorola processors (those used in Mac’s) use "Big Endian" byte order.&lt;br /&gt;&lt;br /&gt;Which is Better?&lt;br /&gt;&lt;br /&gt;You may see a lot of discussion about the relative merits of the two formats, mostly religious arguments based on the relative merits of the PC versus the Mac. Both formats have their advantages and disadvantages.&lt;br /&gt;&lt;br /&gt;In "Little Endian" form, assembly language instructions for picking up a 1, 2, 4, or longer byte number proceed in exactly the same way for all formats: first pick up the lowest order byte at offset 0. Also, because of the 1:1 relationship between address offset and byte number (offset 0 is byte 0), multiple precision math routines are correspondingly easy to write.&lt;br /&gt;&lt;br /&gt;In "Big Endian" form, by having the high-order byte come first, you can always test whether the number is positive or negative by looking at the byte at offset zero. You don’t have to know how long the number is, nor do you have to skip over any bytes to find the byte containing the sign information. The numbers are also stored in the order in which they are printed out, so binary to decimal routines are particularly efficient.&lt;br /&gt;&lt;br /&gt;Ex :&lt;br /&gt;&lt;br /&gt;1024 (0×00000400) stored in little endian machine&lt;br /&gt;&lt;br /&gt;as&lt;br /&gt;&lt;br /&gt;00 00 04 00&lt;br /&gt;&lt;br /&gt;in big endian machine stored as&lt;br /&gt;&lt;br /&gt;00 04 00 00&lt;br /&gt;&lt;br /&gt;is it possible to find endianness at compile time?&lt;br /&gt;&lt;br /&gt;no, it is not possible. but we can use compile time flags&lt;br /&gt;&lt;br /&gt;ex.&lt;br /&gt;&lt;br /&gt;#ifdef _BIG_ENDIAN&lt;br /&gt;&lt;br /&gt;//this code&lt;br /&gt;&lt;br /&gt;#else&lt;br /&gt;&lt;br /&gt;//this code&lt;br /&gt;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;How to find endianness by a program&lt;br /&gt;&lt;br /&gt;int x=1 ;if(*(char *) &amp;x == 1)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;printf("little endian") ;&lt;br /&gt;&lt;br /&gt;else&lt;br /&gt;&lt;br /&gt;pritf("big endian") ;&lt;br /&gt;&lt;br /&gt;[tags]big endian, little endian, endianness, embedded system programming[/tags]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Byte order utililities&lt;br /&gt;&lt;br /&gt;Previous post little, big endianness explained deals with theoretical part of endianness, now let us write some utility functions for endainness.&lt;br /&gt;&lt;br /&gt;Little Endian To Host: Data we are taking here is little endian data and this program converts little endian to host format. program takes a buffer of data and rearranges it to the native order of the machine. if the native order is little endian no conversion happens.&lt;br /&gt;&lt;br /&gt;IsLittleEndian function is already listed in previous post, as it is used here, we?ve copied that function?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;bool IsLittleEndian()&lt;br /&gt;{&lt;br /&gt;int x=1 ;&lt;br /&gt;if(*(char *) &amp;x == 1)&lt;br /&gt;return true;&lt;br /&gt;else&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int LittleEndianToNative(char *data, unsigned int size)&lt;br /&gt;{&lt;br /&gt;char tmp;&lt;br /&gt;char *sptr, *eptr;&lt;br /&gt;&lt;br /&gt;if (!data || !size)&lt;br /&gt;{&lt;br /&gt;return -1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if (IsLittleEndian())&lt;br /&gt;{&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;sptr = data;&lt;br /&gt;eptr = data + size - 1;&lt;br /&gt;&lt;br /&gt;while (sptr &lt;= eptr-1)&lt;br /&gt;  {&lt;br /&gt;    tmp  = *sptr;&lt;br /&gt;    *sptr++ = *eptr;&lt;br /&gt;    *eptr– = tmp;&lt;br /&gt;  }&lt;br /&gt;  return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Host to Little Endian:&lt;br /&gt;&lt;br /&gt;Data we are taking here is host or native order data and this program converts host to little endian format. program takes a buffer of data and rearranges it to little endian. if the native order is little endian no conversion happens.&lt;br /&gt;&lt;br /&gt;int NativeToLittleEndian(char *data, unsigned int size)&lt;br /&gt;{&lt;br /&gt;//conversion process is same&lt;br /&gt;return LittleEndianToNative(data, size);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Big Endian To Host:&lt;br /&gt;&lt;br /&gt;Data we are taking here is big endian data and this program converts big endian to native order format. program takes a buffer of data and rearranges it to the native order of the machine. if the native order is big endian no conversion happens.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int BigEndianToNative(char *data, unsigned int size)&lt;br /&gt;{&lt;br /&gt;char tmp;&lt;br /&gt;char *sptr, *eptr;&lt;br /&gt;&lt;br /&gt;if (!data || !size) { return -1; }&lt;br /&gt;&lt;br /&gt;if (!IsLittleEndian())&lt;br /&gt;{&lt;br /&gt;//no conversion required&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;sptr = data;&lt;br /&gt;eptr = data + size - 1;&lt;br /&gt;&lt;br /&gt;while (sptr &lt;= eptr-1)&lt;br /&gt;  {&lt;br /&gt;    tmp  = *sptr;&lt;br /&gt;    *sptr++ = *eptr;&lt;br /&gt;    *eptr– = tmp;&lt;br /&gt;  }&lt;br /&gt;  return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Host to Big Endian:&lt;br /&gt;&lt;br /&gt;Data we are taking here is host or native order data and this program converts host to big endian format. program takes a buffer of data and rearranges it to big endian. if the native order is big endian no conversion happens.&lt;br /&gt;&lt;br /&gt;int NativeToBigEndian(char *data, unsigned int size)&lt;br /&gt;{&lt;br /&gt;//conversion process is same&lt;br /&gt;return BigEndianToNative(data, size);&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-2722812652693391239?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/2722812652693391239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=2722812652693391239' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/2722812652693391239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/2722812652693391239'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/endianness.html' title='endianness'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-6666047796884875481</id><published>2009-08-31T19:18:00.000-07:00</published><updated>2009-08-31T20:15:46.633-07:00</updated><title type='text'>sections of a program</title><content type='html'>-&gt; volatile, static, const, register vars&lt;br /&gt;-&gt; Sections/Segments (text, data, stack, heap, bss, etc) of an ELF file&lt;br /&gt;-&gt; where various variables stored&lt;br /&gt;local, formal vars: stack&lt;br /&gt;  static,global (unintialised): bss (block start by symbol)&lt;br /&gt;  static, global(initialised) : data section&lt;br /&gt;  vars allocated thru malloc, new: heap&lt;br /&gt;&lt;br /&gt;-&gt; static linking (.a), dynamic linking and loading (.so)&lt;br /&gt;-&gt; Bitwise operations&lt;br /&gt;-&gt; swap two vars without using tmp var&lt;br /&gt;  a=a+b; b=a-b; b= a-b;&lt;br /&gt;u can also swap with using xor operations&lt;br /&gt;  a^=b^=a^=b? (ofcourse this doesn’t work always as u expected, check the sequence point.. modify it)&lt;br /&gt;-&gt; calling conventions&lt;br /&gt;info: c-calling convention, standard calling convention, pascal. etc. (this stuff specific windows,&lt;br /&gt;  unix don’t bother about this, it just uses c calling convention)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;C++&lt;br /&gt;&lt;br /&gt;===&lt;br /&gt;-&gt; Difference between structure and class&lt;br /&gt;-&gt; access specifiers&lt;br /&gt;-&gt; Whats the size of an empty class&lt;br /&gt;-&gt; When do you use composition/aggregation and inheritance&lt;br /&gt;-&gt; When RTTI useful?&lt;br /&gt;-&gt; inline, macros&lt;br /&gt;-&gt; virtual polymorphism (abt vtables, vptrs also)&lt;br /&gt;-&gt; virtual destructors, why not virtual constructors&lt;br /&gt;-&gt; If u invoke a virtual function in constructor what will happen&lt;br /&gt;-&gt; How static behave in C++&lt;br /&gt;-&gt; Name mangling (all related issues like function overloading, using a C or other language function, etc)&lt;br /&gt;-&gt; oop concepts (just abstraction, encapsulation, inheritance, polymorphism)&lt;br /&gt;-&gt; copy constructors&lt;br /&gt;-&gt; “delete this”… is it advisable to use like this? is it useful in any situation?&lt;br /&gt;-&gt; what happens if an exception occurs in between construction of an object&lt;br /&gt;-&gt; If I link a library which I compiled on solaris with a linux executable, will it work?&lt;br /&gt;  why?&lt;br /&gt;-&gt; difference between #define constants and enums&lt;br /&gt;-&gt; class&lt;br /&gt;  {&lt;br /&gt;   enum x{one, two}X1;&lt;br /&gt;   enum y{one, two}Y1;&lt;br /&gt;  };&lt;br /&gt;  is this is OK?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Programming&lt;br /&gt;===========&lt;br /&gt;&lt;br /&gt;-&gt; Write a program to search a list of unsorted elements with only one condition&lt;br /&gt;Ans:&lt;br /&gt;  Normal routine: for(i=0;i Manage an array efficiently to implement two stacks on it&lt;br /&gt;Ans:&lt;br /&gt;  manage like this:&lt;br /&gt;&lt;br /&gt;   ————————————&lt;br /&gt;   |1st stack–&gt;  &lt;–2nd stack|&lt;br /&gt;&lt;br /&gt;  ————————————-&lt;br /&gt;&lt;br /&gt; no explicit bounds&lt;br /&gt;&lt;br /&gt;Write a program to traverse a n-ary tree and store the nodes in disk in such way that&lt;br /&gt;tree is reconstructable from the storage&lt;br /&gt;&lt;br /&gt;Ans: like java’s serialise data structures&lt;br /&gt;&lt;br /&gt;-&gt; Write a program to traverse an array spirally&lt;br /&gt;Ans: write this using directions and maintaining states&lt;br /&gt;&lt;br /&gt;-&gt; Write a program to find sub-array of any number of elements with optimum&lt;br /&gt;sum-value in an array (array elements may be -ve)&lt;br /&gt;&lt;br /&gt;-&gt; Reverse a double linked list&lt;br /&gt;&lt;br /&gt;-&gt; Reverse a single linked list&lt;br /&gt;Ans: use a stack to reverse it&lt;br /&gt;&lt;br /&gt;-&gt; Write a recursive program to print a linked list reversely&lt;br /&gt;&lt;br /&gt;print(Node *node)&lt;br /&gt;  {&lt;br /&gt;    if(node-&gt;next)&lt;br /&gt;     print(node-&gt;next)&lt;br /&gt;   else&lt;br /&gt;    return;&lt;br /&gt;  printf(node-&gt;info)&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;-&gt; How do you find loops in a single linked list&lt;br /&gt;  1) use flags&lt;br /&gt;  2) use two or three pointers and increment them at different levels&lt;br /&gt;      like one ptr with ptr=ptr-&gt;next , another with second_ptr=second_ptr-&gt;next-&gt;next.&lt;br /&gt;  if these pointers meet, then it got loops&lt;br /&gt;&lt;br /&gt;-&gt; Write a program to find x^n in O(log n)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;  xpown(x,n)&lt;br /&gt;  {&lt;br /&gt;    val = x;&lt;br /&gt;&lt;br /&gt;    do {&lt;br /&gt;      if(n % 2)&lt;br /&gt;        val *= x;&lt;br /&gt;      else&lt;br /&gt;        val *= val;&lt;br /&gt;    }while(n /= 2);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;-&gt; Write a program for preorder traversal without using recursion&lt;br /&gt;ans: use stack&lt;br /&gt;&lt;br /&gt;-&gt; Write a program to traverse a binary tree in level by level manner&lt;br /&gt;ans: its just BFS… use queue&lt;br /&gt;&lt;br /&gt;-&gt; finding a number is power of 2 or not&lt;br /&gt;ans:&lt;br /&gt;if(!(n &amp; n-1)) printf(”power of 2″);&lt;br /&gt;better answer like this “count number of 1’s… if(count==1) power of 2)&lt;br /&gt;&lt;br /&gt;-&gt;In an unsorted array find the sum of 3 maximum numbers in less than O(n) time&lt;br /&gt;ans: 1)do bubble sort until u sort 3 elemnts then stop it, sum the nums&lt;br /&gt;   2) build heap (O(n)), delete_max 3 elements (O(logn))&lt;br /&gt;&lt;br /&gt;-&gt; in a sorted array only two elements are misplaced, find the desired element still&lt;br /&gt;  maintaining the o(logn) time&lt;br /&gt;&lt;br /&gt;-&gt; basics of all data structres&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-6666047796884875481?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/6666047796884875481/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=6666047796884875481' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/6666047796884875481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/6666047796884875481'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/sections-of-program.html' title='sections of a program'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-4266784199078962119</id><published>2009-08-31T15:14:00.002-07:00</published><updated>2009-08-31T15:36:56.187-07:00</updated><title type='text'>Structure</title><content type='html'>5. DATA STRUCTURES&lt;br /&gt;5.1 Data Structure&lt;br /&gt;&lt;br /&gt;A collection of the same type of objects is called a data structure.&lt;br /&gt;5.2 Linked List&lt;br /&gt;&lt;br /&gt;If you want to maintain a collection of the same objects, you may first think of an array of that type of objects. But as we already know, the size of the array have to be decided before compiling. Then we may think of using dynamic memory allocation to create the array, so that we can decide the memory size at run time:&lt;br /&gt;&lt;br /&gt;    Test * array = new Test [size];&lt;br /&gt;&lt;br /&gt;But still there is limitation: once the array is created, you can not vary the size, unless you delete the whole array and create a new one. You can’t expand or shrink the list dynamically.&lt;br /&gt;&lt;br /&gt;In order to put a group of objects into a flexible data structure, you can use wrapper objects to wrap around the original objects, with some additional pointers pointing to each other. Through these pointers, all the wrapper objects can be linked together. Such a pointer-linked collection is called “linked list”.&lt;br /&gt;&lt;br /&gt;The disadvantages of linked list is that you can not directly access one node with subscript like array. You have to find the first one, go through the list through the pointers, until you reach the one you want. The other thing to remember is: nodes in linked list are created dynamically. They are not as fast as automatic objects.&lt;br /&gt;&lt;br /&gt;If in a data structure each of the nodes is only connected to one node downstream and one node upstream, such a structure is called a “linear linked list”.&lt;br /&gt;&lt;br /&gt;There are “open-loop” lists, each has a start node and end node. The pointer of the end node is always set to 0 to mark the end. There are also “close-loop” lists, whose start node and end node are connected together forming a circular loop of nodes.&lt;br /&gt;&lt;br /&gt;There are Singly-linked lists whose nodes only contain one pointer pointing to the downstream node. You can’t traverse upstream. There are also doubly-linked lists whose nodes each contains a pointer to both the upstream and downstream node. You can traverse on both directions.&lt;br /&gt;&lt;br /&gt;Using pointers to link objects you can create lists as queues, which only removes a node from the front and adds a node to the back, or stacks, which only adds and removes nodes to and from the front, or any other types.&lt;br /&gt;5.3 Tree&lt;br /&gt;&lt;br /&gt;A tree is a structure whose nodes each connected to one upstream node and many down-stream nodes. A binary tree is a structure which is connected to one upstream and two downstream nodes. A tree has a root node.&lt;br /&gt;5.4 Struct&lt;br /&gt;&lt;br /&gt;A structure is a simplified class with all public members:&lt;br /&gt;&lt;br /&gt;    struct Card &lt;br /&gt;    {&lt;br /&gt;      char * face;&lt;br /&gt;      char * suit;&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;Structure members are not necessarily stored in consecutive bytes of memory. If the word length of the computer is 2 bytes, and one data member is only one-byte long, there will be a one-byte hole between this member and the next member. Because the value stored in the hole is undefined, a structure can not be compared.&lt;br /&gt;&lt;br /&gt;A structure is initialized the same way as an array:&lt;br /&gt;&lt;br /&gt;    Card c1 = {"Three", "Hearts"};&lt;br /&gt;&lt;br /&gt;If the initialization list contains not enough initializers, the rest will be initialized to 0.&lt;br /&gt;5.5 Bitwise Operators&lt;br /&gt;&lt;br /&gt;Up to now data is regarded as a whole number without considering its bit status. Internally a number is represented by binary bits. C++ provides the following bitwise operators:&lt;br /&gt;&lt;br /&gt;1)&amp;: bitwise AND. One bit is 1 if the corresponding bits of the both operands are both 1.&lt;br /&gt;2)|: bitwise inclusive OR. One bit is 1 if one of both corresponding bits of the two operands is/are 1.&lt;br /&gt;3)^: bitwise exclusive OR. One bit is 1 if the corresponding bits of the two operands are different: one is 1 and one is 0&lt;br /&gt;4)&lt;&lt;: left shift. Shifts the bits of the first operand left by the number of bits specified by the second operand; fill from right with 0. For example, 0001 &lt;&lt; 2 will be 0100. Result will be undefined if the second operand is negative.&lt;br /&gt;5)&gt;&gt;: right shift. Shifts the bits of the first operand right by the number of bits specified by the second operand; The way of filling the left is machine-dependent, some use 0 and some use the sign bit.&lt;br /&gt;6)~: complement. All 0 bits are 1 and all 1 bits are 0. For example, ~0101 will be 1010.&lt;br /&gt;7)Assignment operators: &amp;=, |=, ^=, &lt;&lt;=, &gt;&gt;=. For example: a &amp;= b means a = a &amp; b, a &gt;&gt;= b means a = a &gt;&gt; b.&lt;br /&gt;5.6 Example: Display a Number in Binary Form&lt;br /&gt;&lt;br /&gt;    void BinaryDisplay1(unsigned value)&lt;br /&gt;    {&lt;br /&gt;      mask = 1 &lt;&lt; 15;   // 1000000000000000&lt;br /&gt;     &lt;br /&gt;      for (int c = 1; c &lt;= 16; c++)&lt;br /&gt;      {&lt;br /&gt;        // 1000000000000000 is regarded as true&lt;br /&gt;        cout &lt;&lt; (value &amp; mask ? '1': '0'); &lt;br /&gt;     &lt;br /&gt;        if(c % 8 == 0)&lt;br /&gt;          cout &lt;&lt; ' '; &lt;br /&gt;      }&lt;br /&gt;     &lt;br /&gt;      cout &lt;&lt; endl; &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;5.7 Bit Field&lt;br /&gt;&lt;br /&gt;C++ provides the ability to specify the number of bits in which an unsigned or int member of a class or a structure (or a union) is stored. Such a member is called a bit filed member:&lt;br /&gt;&lt;br /&gt;    struct Card &lt;br /&gt;    {&lt;br /&gt;      unsigned face : 4;&lt;br /&gt;      unsigned suit : 2;&lt;br /&gt;      unsigned color: 1;&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;Therefore, three members are stored in one byte. The number of bits of one member is decided by the maximum number it will represent. For example, the number of faces of cards is 13, less than 16, so member “face” can be defined with four bits.&lt;br /&gt;&lt;br /&gt;Bit field members are accessed the same way as normal members. But they can not have addresses, and “&amp;” can not be used, because there is no unique address of each part of one word.&lt;br /&gt;&lt;br /&gt;Unnamed bit field with a width is used as padding, nothing can be stored in these padding bits:&lt;br /&gt;&lt;br /&gt;    structure Example &lt;br /&gt;    {&lt;br /&gt;      unsigned a : 13;&lt;br /&gt;      unsigned   : 3;&lt;br /&gt;      unsigned b : 4;&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;Unnamed bit field with 0 width is used to align the next bit field with next word:&lt;br /&gt;&lt;br /&gt;    structure Example &lt;br /&gt;    {&lt;br /&gt;      unsigned a : 13;&lt;br /&gt;      unsigned   : 0;&lt;br /&gt;      unsigned b : 4;&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;Although bit fields save space, it consumes more machine time, because extra codes have to be generated to deal with them. This is one of the many examples of space-time trade off that occur in computer science.&lt;br /&gt;5.8 Character Handling Library&lt;br /&gt;&lt;br /&gt;Characters are often manipulated as integers. Header file of the character handling library is .&lt;br /&gt;&lt;br /&gt;int isdigit(int c): returns true if c is a digit — ‘0′ to ‘9′.&lt;br /&gt;int isxdigit(int c): returns true if c is a hex digit — ‘0′, ‘1′,…, ‘E’, ‘F’.&lt;br /&gt;int isalpha(int c): returns true if c is a letter.&lt;br /&gt;int isalnum(int c): returns true if c is a letter or a digit.&lt;br /&gt;int islower(int c): returns true if c is a lower case&lt;br /&gt;int isupper(int c): returns true if c is a upper case&lt;br /&gt;int tolower(int c): if c is upper case then return c in lower case, otherwise return c unchanged&lt;br /&gt;int toupper(int c): if c is lower case then return c in upper case, otherwise return c unchanged.&lt;br /&gt;int isspace(int c): returns true if c is a whitespace character: newline(’\n’), space, form feed(’\f’), carriage return(’\r’), horizontal tab(’\t’), or vertical tab(’\v’).&lt;br /&gt;int iscntrl(int c): returns true if c is a control character.&lt;br /&gt;int ispunct(int c): returns true if c is a printing character other than a space, a digit or a letter.&lt;br /&gt;int isprint(int c): returns true if c is a printing character including space.&lt;br /&gt;int isgraph(int c): returns true if c is a printing character other than space.&lt;br /&gt;5.9 String Conversion Methods&lt;br /&gt;&lt;br /&gt;String conversion methods are in .&lt;br /&gt;&lt;br /&gt;double atof(const char *): converts a numbered string to double. E.g.: if ptr = “23.85″, double 23.85 will be returned.&lt;br /&gt;int atoi(const char *): converts a numbered string to integer. E.g.: if ptr = “2593″, integer 2593 will be returned.&lt;br /&gt;long atol(const char *): converts a numbered string to long integer.&lt;br /&gt;&lt;br /&gt;double strtod(const char *, char **): converts the double portion of string ptr1 to double, and locate the second pointer at the first remaining character in the first string. E.g.: if ptr1 = “1234.2ABCD”, double 1234.2 will be returned and second pointer will be “ABCD”.&lt;br /&gt;&lt;br /&gt;long strtol(const char * ptr1, char ** ptr2, int base): converts the long int portion of string ptr1 to long integer, and locate pointer ptr2 at the first remaining character in ptr1. The long integer can be in any base: if base = 0, then it can be decimal, octal or hexadecimal; if base = 8, it is octal; if base = 10, it is decimal; if base = 16, it is hexadecimal. But the base can be any value from 2 to 36, limited only by the number of Latin letters A-Z. Using NULL for the second argument will cause the remaining portion be ignored.&lt;br /&gt;&lt;br /&gt;unsigned long strtoul(const char * ptr1, char ** ptr2, int base): only difference with method strtol is the integer is unsigned.&lt;br /&gt;5.10 String Handling Library “string.h”&lt;br /&gt;=&gt;Searching character in string&lt;br /&gt;&lt;br /&gt;char * strchr(const char * s, int c): locate the first c in string s, or return NULL if not found.&lt;br /&gt;size_t strcspn(const char * s1, const char * s2): return the length of the initial segment of s1 which consists of characters not included in s2.&lt;br /&gt;size_t strspn(const char * s1, const char * s2): return the length of the initial segment of string s1 which consists only characters in s2.&lt;br /&gt;char * strpbrk(const char * s1, const char * s2): locate the first occurrence in s1 of any character contained in s2 or NULL if not found.&lt;br /&gt;char * strrchr(const char * s, int c): locate the last occurrence of c in s or NULL if not found.&lt;br /&gt;char * strstr(const char * s1, const char * s2): locate the first occurrence in s1 of s2 or NULL if not found.&lt;br /&gt;=&gt;Memory manipulating methods&lt;br /&gt;&lt;br /&gt;The basic unit of memory is byte, and a byte can be regarded as a character. The following methods manipulate memory buffers in characters. The pointer parameters in these methods are declared “void *”. Because pointers of any type can be directly assigned to a pointer of type “void *”, therefore methods can receive pointers of any type.&lt;br /&gt;&lt;br /&gt;void * memcpy(void * s1, const void * s2, size_t n)&lt;br /&gt;Copies n characters from buffer s2 to s1, and return a pointer to the resulting buffer.&lt;br /&gt;&lt;br /&gt;void * memmove(void * s1, const void * s2, size_t n)&lt;br /&gt;The same as memcpy, but the characters are first copied from s2 into a temporary location, then copied to s1. This allows to copy part of one object and overlap with itself:&lt;br /&gt;&lt;br /&gt;    int main()&lt;br /&gt;    {&lt;br /&gt;       char x[] = "123 456 789";&lt;br /&gt;       cout &lt;&lt; (char *)memmove(x, x+4, 3);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;then x will become “456 456 789″.&lt;br /&gt;&lt;br /&gt;    int  memcmp(const void * s1, const void s2, size_t n)&lt;br /&gt;    //Compares the first n characters of object s1 and s2, &lt;br /&gt;    //and returns 0, &lt;0, or &gt;0.&lt;br /&gt;&lt;br /&gt;    void *  memchr(const void * s, int c, size_t n)&lt;br /&gt;    //Locates the first occurrence of c in the first n &lt;br /&gt;    //characters of object s, or return 0 if not found.&lt;br /&gt;&lt;br /&gt;    void *  memset(void * s, int c, size_t n)&lt;br /&gt;    //Set the first n characters of object s to character c, &lt;br /&gt;    //and return a pointer to the result&lt;br /&gt;&lt;br /&gt;    int main()&lt;br /&gt;    {&lt;br /&gt;       char x[] = "AAAA";&lt;br /&gt;       cout &lt;&lt; (char *)memset(x, 'B', 2);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;result will be “BBAA”.&lt;br /&gt;5.11 Error Message Method&lt;br /&gt;&lt;br /&gt;    char * strerror(int code);&lt;br /&gt;&lt;br /&gt;Error messages have their codes. This method maps the error code into a full text string in a system dependent way, and returns a pointer to that mapped message.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-4266784199078962119?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/4266784199078962119/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=4266784199078962119' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/4266784199078962119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/4266784199078962119'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/structure.html' title='Structure'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-495129532827220433</id><published>2009-08-31T15:14:00.001-07:00</published><updated>2009-08-31T15:14:54.380-07:00</updated><title type='text'>unnamed bit field</title><content type='html'>An unnamed bit field is used for padding to conform to external imposed layouts.&lt;br /&gt;&lt;br /&gt;Unnamed bit-field with a width of zero specifies alignment of the next bit field at an allocation unit boundary.&lt;br /&gt;&lt;br /&gt;struct becks {&lt;br /&gt;…&lt;br /&gt;int :3 //three bit field&lt;br /&gt;…&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-495129532827220433?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/495129532827220433/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=495129532827220433' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/495129532827220433'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/495129532827220433'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/unnamed-bit-field.html' title='unnamed bit field'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-4274993186558922576</id><published>2009-08-31T15:12:00.001-07:00</published><updated>2009-08-31T15:12:57.548-07:00</updated><title type='text'>Padding the the significance!</title><content type='html'>What is Padding?&lt;br /&gt;Aligning members of a structre to a byte boundary. Padding is done by compiler to gain the performance. Most hardware architectures&lt;br /&gt;access addresses fast if they are aligned properly, otherwise there will be performance penalty. In order to increase performance compiler pads structures.&lt;br /&gt;&lt;br /&gt;How Padding done?&lt;br /&gt;Normally processors require members of the structure aligned to byte boundary, for instance char member(1 byte) should be aligned to&lt;br /&gt;one byte boundary that is it can appear at any byte boundary, a short int(2 bytes) should be aligned to 2 byte boundary that is it should appear at 2 byte boundary, long int(4 bytes) should be aligned to 4 byte boundary. If we declare a basic data type in structure it should appear at sizeof(basic data type) byte boundary, in order to make the start address of the next member at an aligned address.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;Struct X&lt;br /&gt;{&lt;br /&gt;Char a;&lt;br /&gt;Short int b;&lt;br /&gt;Char c;&lt;br /&gt;Long&lt;br /&gt;d;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;| a(1) | P(1)| b(2) | c(1)| P(3) | d(4) |&lt;br /&gt;&lt;br /&gt;P - padding bytes&lt;br /&gt;&lt;br /&gt;Why Padding?&lt;br /&gt;If the processor is serious about alignment it raises an exception/signal (ex. SIGBUS), otherwise there will be a performance penalty&lt;br /&gt;will be there as misalignment slowdown data access&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;Are members order going to be changed?&lt;br /&gt;ANSI C requires fields of a structure need to allocated in the order they are declared.&lt;br /&gt;&lt;br /&gt;As a programmer how does padding matter to me?&lt;br /&gt;It matters if you are concerned about space it takes. By changing the members order of declarations, some amount space can be saved. For example&lt;br /&gt;Struct X&lt;br /&gt;{&lt;br /&gt;Char a;&lt;br /&gt;Long&lt;br /&gt;Int b;&lt;br /&gt;Char c;&lt;br /&gt;Long int d;&lt;br /&gt;Char e;&lt;br /&gt;Long int f;&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;Sizeof(struct X) = 24 bytes&lt;br /&gt;&lt;br /&gt;Lets reorder the above structure as below&lt;br /&gt;&lt;br /&gt;Struct X&lt;br /&gt;{&lt;br /&gt;Char a;&lt;br /&gt;Char c;&lt;br /&gt;Char e;&lt;br /&gt;Long Int b;&lt;br /&gt;Long int&lt;br /&gt;d;&lt;br /&gt;Long int f;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;Sizeof(struct X) = 16 bytes&lt;br /&gt;&lt;br /&gt;Padding is only done to members or to the structure as a whole&lt;br /&gt;also?&lt;br /&gt;Padding will be done by compiler to structure’s members and to the structure as a whole also. Compiler pads structure as whole because this allows each member of structure aligned in array of structures.&lt;br /&gt;&lt;br /&gt;Packed structures&lt;br /&gt;Some compilers provide #pragma to suppress padding or to make it packed to n number of bytes. Some provide keywords to do this.&lt;br /&gt;Generally pragma which is used for modifying structure padding will be in the below format (depends on compiler)&lt;br /&gt;#pragma pack(n)&lt;br /&gt;For example arm&lt;br /&gt;provides __packed keyword to suppress structure padding. Go through your compiler manual to know more about this.&lt;br /&gt;&lt;br /&gt;So a packed structure is a structure without padding.&lt;br /&gt;Generally packed structures will be used&lt;br /&gt;-&gt;to save space, and&lt;br /&gt;-&gt;to format a data structure to transmit over network using some protocol (this is not a good practice of course because you need to deal&lt;br /&gt;with endianness)&lt;br /&gt;&lt;br /&gt;How to declare array of packed structures?&lt;br /&gt;We can not declare array of packed structures as for declaring as an array we need each member of structure aligned. So alternatively either we can declare something like this&lt;br /&gt;Struct X&lt;br /&gt;{&lt;br /&gt;Unsigned char a;&lt;br /&gt;Unsigned long b;&lt;br /&gt;}array[NUM_ELEMENTS];&lt;br /&gt;&lt;br /&gt;The above structure yields compilation error, if we declare this as below, we should be able to handle..&lt;br /&gt;Unsigned char array_bytes[sizeof(structure) * NUM_ELEMENTS];&lt;br /&gt;And take special care while handling array_bytes.&lt;br /&gt;&lt;br /&gt;When I need to be careful about structure padding?&lt;br /&gt;1)when writing structures to a file on one machine and reading them on different machine&lt;br /&gt;This involves problem, consider this example&lt;br /&gt;Struct X&lt;br /&gt;{&lt;br /&gt;Char a;&lt;br /&gt;Long int b;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;x.a = 0�01;&lt;br /&gt;x.b = 0�02;&lt;br /&gt;&lt;br /&gt;If you write struct X to a file, it would have written 0�01 G G G 0�00 0�00 0�00 0�02 (G is garbled value, because this area is padded)&lt;br /&gt;While reading this on different machine(could be big endian) we read the structure as whole, on big-endian these values will be altered and as a result we read corrupted value for member a;&lt;br /&gt;Solution for this would be using a packed structures we can eliminate this.&lt;br /&gt;&lt;br /&gt;How can I pack structures Using GCC?&lt;br /&gt;Using the "packed" attribute against the members of a structure. This attribute mechanism is an extension to the GNU C compiler. An example of how you would do this is below.&lt;br /&gt;&lt;br /&gt;struct X&lt;br /&gt;{&lt;br /&gt;unsigned char a __attribute__((__packed__));&lt;br /&gt;unsigned&lt;br /&gt;short b __attribute__((__packed__));&lt;br /&gt;unsigned long c&lt;br /&gt;__attribute__((__packed__));&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;Another way to achieve the same is as shown below:&lt;br /&gt;struct X&lt;br /&gt;{&lt;br /&gt;unsigned char a;&lt;br /&gt;unsigned short b;&lt;br /&gt;unsigned long c;&lt;br /&gt;}&lt;br /&gt;__attribute__((__packed__));&lt;br /&gt;&lt;br /&gt;How can I pack structures Using ARM compiler?&lt;br /&gt;__packed keyword is used for this purpose, usage is shown below&lt;br /&gt;&lt;br /&gt;__packed struct X&lt;br /&gt;{&lt;br /&gt;char a;&lt;br /&gt;Long int b;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;May be in some other post, I try to give details about how padding done for&lt;br /&gt;global variables, pointers and etc. on some selected machines. Your comments,&lt;br /&gt;suggestions, criticism, etc. most welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-4274993186558922576?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/4274993186558922576/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=4274993186558922576' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/4274993186558922576'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/4274993186558922576'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/padding-the-significance.html' title='Padding the the significance!'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-3142086292629050721</id><published>2009-08-30T18:37:00.001-07:00</published><updated>2009-08-30T18:37:17.884-07:00</updated><title type='text'>link list</title><content type='html'>#include&lt;stdio.h&gt;&lt;br /&gt;#include&lt;stdlib.h&gt;&lt;br /&gt;struct link_list{&lt;br /&gt; int data;&lt;br /&gt; struct link_list *next;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;void insert(int data, struct link_list **usrlist){&lt;br /&gt;struct link_list *temp, *trav;&lt;br /&gt;temp=(struct link_list *)malloc(sizeof(struct link_list));&lt;br /&gt;temp-&gt;data=data;&lt;br /&gt;temp-&gt;next=NULL;&lt;br /&gt;if(*usrlist==NULL){&lt;br /&gt; *usrlist=temp;&lt;br /&gt; }&lt;br /&gt;else{&lt;br /&gt; trav=*usrlist;&lt;br /&gt; while(trav-&gt;next){&lt;br /&gt;  trav=trav-&gt;next;&lt;br /&gt;  }&lt;br /&gt; trav-&gt;next=temp;&lt;br /&gt; &lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void display(struct link_list **usrlist){&lt;br /&gt;struct link_list *trav=*usrlist;&lt;br /&gt;printf("\n");&lt;br /&gt;if(trav==NULL)&lt;br /&gt; printf("\nThe list is empty\n");&lt;br /&gt;while(trav){&lt;br /&gt; printf("data: %d --&gt;",trav-&gt;data);&lt;br /&gt; trav=trav-&gt;next;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;struct link_list * revlist(struct link_list **userlist){&lt;br /&gt;struct link_list *temp, *usrlist,*prev=NULL;&lt;br /&gt;usrlist=*userlist;&lt;br /&gt;while(usrlist-&gt;next){&lt;br /&gt; temp=usrlist-&gt;next;&lt;br /&gt; usrlist-&gt;next=prev;&lt;br /&gt; prev=usrlist;&lt;br /&gt; usrlist=temp;&lt;br /&gt; }&lt;br /&gt; usrlist-&gt;next=prev;&lt;br /&gt; return usrlist;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;struct link_list * freelist(struct link_list **usrlist){&lt;br /&gt;struct link_list *temp;&lt;br /&gt; while(*usrlist){&lt;br /&gt;  temp=*usrlist; &lt;br /&gt;  *usrlist=(*usrlist)-&gt;next;&lt;br /&gt;  free(temp);&lt;br /&gt;  printf("\nEntry freed");&lt;br /&gt;  }&lt;br /&gt; return NULL;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;struct link_list * revlistrec(struct link_list *L)&lt;br /&gt;{&lt;br /&gt;    struct link_list *first, *rest, *trav, *reftrav;&lt;br /&gt; first=L;&lt;br /&gt; rest=L-&gt;next;&lt;br /&gt;    if(!L)&lt;br /&gt;  return NULL;&lt;br /&gt; if(!L-&gt;next)&lt;br /&gt;  {&lt;br /&gt;  return L;&lt;br /&gt;  }&lt;br /&gt; if(!L-&gt;next-&gt;next)&lt;br /&gt;  {&lt;br /&gt;  L-&gt;next-&gt;next=first;&lt;br /&gt;  first-&gt;next=NULL;&lt;br /&gt;  return rest;&lt;br /&gt;  }&lt;br /&gt; reftrav=trav=revlistrec(rest);&lt;br /&gt; while(reftrav-&gt;next)&lt;br /&gt;  {&lt;br /&gt;  reftrav=reftrav-&gt;next;&lt;br /&gt;  }&lt;br /&gt; reftrav-&gt;next=first;&lt;br /&gt; first-&gt;next=NULL;&lt;br /&gt; return trav;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void sortlist(struct link_list *L){&lt;br /&gt; struct link_list *temp;&lt;br /&gt; int datatemp;&lt;br /&gt; while(L){&lt;br /&gt;  temp=L;&lt;br /&gt;  while(temp){&lt;br /&gt;   if(L-&gt;data&gt;temp-&gt;data){&lt;br /&gt;    datatemp=temp-&gt;data;&lt;br /&gt;    temp-&gt;data=L-&gt;data;&lt;br /&gt;    L-&gt;data=datatemp;&lt;br /&gt;   }&lt;br /&gt;   temp=temp-&gt;next;&lt;br /&gt;  }&lt;br /&gt;  L=L-&gt;next;&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void middlelist(struct link_list *L){&lt;br /&gt;struct link_list *second;&lt;br /&gt;second=L;&lt;br /&gt;while(L-&gt;next!=NULL &amp;&amp; second-&gt;next!=NULL &amp;&amp; second-&gt;next-&gt;next!=NULL){&lt;br /&gt; L=L-&gt;next;&lt;br /&gt; second=second-&gt;next-&gt;next;&lt;br /&gt; }&lt;br /&gt;printf("\n the middle element is %d", L-&gt;data);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void main()&lt;br /&gt;{&lt;br /&gt; struct link_list *usrlist=NULL;&lt;br /&gt; &lt;br /&gt; if(usrlist==NULL){&lt;br /&gt;  printf("\nThe users list is empty...i am inserting data");&lt;br /&gt;  insert(20, &amp;usrlist);&lt;br /&gt;  insert(2, &amp;usrlist);&lt;br /&gt;  insert(33, &amp;usrlist);&lt;br /&gt;  insert(1, &amp;usrlist);&lt;br /&gt;  insert(2, &amp;usrlist);&lt;br /&gt;  insert(63, &amp;usrlist);&lt;br /&gt;  insert(42, &amp;usrlist);&lt;br /&gt;  insert(90, &amp;usrlist);&lt;br /&gt;  insert(91, &amp;usrlist);&lt;br /&gt; }&lt;br /&gt; display(&amp;usrlist);&lt;br /&gt; //usrlist=revlist(&amp;usrlist);&lt;br /&gt; //usrlist=revlistrec(usrlist);&lt;br /&gt; //printf("\n\nreversed display");&lt;br /&gt; printf("\nmiddledisplay");&lt;br /&gt;// sortlist(usrlist);&lt;br /&gt; middlelist(usrlist);&lt;br /&gt; display(&amp;usrlist);&lt;br /&gt; printf("\n Insertion and display finished\n");&lt;br /&gt; usrlist=freelist(&amp;usrlist);&lt;br /&gt; display(&amp;usrlist);&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-3142086292629050721?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/3142086292629050721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=3142086292629050721' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/3142086292629050721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/3142086292629050721'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/link-list.html' title='link list'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-2965573093170512942</id><published>2009-08-30T15:04:00.000-07:00</published><updated>2009-08-30T15:05:02.403-07:00</updated><title type='text'>use of double pointers in structures</title><content type='html'>No. The reason for the pointer to a pointer parameter is so that the result of malloc could be reflected in the caller (i.e., if you just passed a pointer to a struct node, the result of malloc would just be assigned to the local struct node pointer rather than the struct node pointer from the caller). If you do not need such a call by reference parameter (which is the case for a print or a search function), then just passing a pointer to a struct node will do.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-2965573093170512942?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/2965573093170512942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=2965573093170512942' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/2965573093170512942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/2965573093170512942'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/use-of-double-pointers-in-structures.html' title='use of double pointers in structures'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-3231435608511145295</id><published>2009-08-28T21:21:00.000-07:00</published><updated>2009-08-28T21:24:27.750-07:00</updated><title type='text'>Rule 1 of software engineering</title><content type='html'>The amount of time trying to figure out a solution to the bug is directly proportional to the amount of stupidity involved in introducing it at the first place&lt;br /&gt;&lt;br /&gt;  ----- i was told about it by Viji but I dont know who gave the original version....&lt;br /&gt;&lt;br /&gt;Other laws by viji:&lt;br /&gt;&lt;br /&gt;A bug is constant, it migrates from one code to another.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-3231435608511145295?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/3231435608511145295/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=3231435608511145295' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/3231435608511145295'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/3231435608511145295'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/rule-1-of-software-engineering.html' title='Rule 1 of software engineering'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-293572536938177247</id><published>2009-08-07T13:27:00.000-07:00</published><updated>2009-08-07T13:35:04.459-07:00</updated><title type='text'>installing wireless using windows driver</title><content type='html'>OWTO: Dell Inspiron Wireless (Broadcom 1390 WLAN)&lt;br /&gt;This HOWTO describes how to get Wifi working on your Dell Inspiron E1505/6400 laptop using Ndiswrapper. This applies if you have the Broadcom "Dell Wireless 1390 WLAN MiniCard", which as far as I know, is the cheaper, low-end version that Dell currently offers in this laptop. This HOWTO has been tested and works with both 32 bit and 64 bit ubuntu, and uses the exact same method for both. It is VERY IMPORTANT that you read every part of this how-to and follow the steps EXACTLY as they're written. Many users have trouble because they only read the code sections and ignore my directions to change to the proper directories. Again, PLEASE BE SURE YOU ARE IN THE PROPER DIRECTORY WHEN EXECUTING THESE COMMANDS. This will save you a lot of trouble and will make the installation go a lot smoother.&lt;br /&gt;&lt;br /&gt;This HOWTO supports:&lt;br /&gt;&lt;br /&gt;    * Gutsy Gibbon 7.10&lt;br /&gt;    * Feisty Fawn 7.04&lt;br /&gt;    * Edgy Eft 6.10&lt;br /&gt;    * Dapper Drake 6.06&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;STEP 1: CLEAN YOUR SYSTEM&lt;br /&gt;&lt;br /&gt;IMPORTANT NOTE ABOUT CLEANING YOUR SYSTEM:&lt;br /&gt;&lt;br /&gt;One of the most common reasons why many people can't get their wireless working is because their system is in a state of chaos. If you have made ANY previous attempts to get your wireless working -- either using fwcutter, ndiswrapper, or the bcm43xx drivers -- this how-to will most likely not work UNTIL you reverse your previous changes. In many cases, it is much easier to simply reinstall ubuntu and come straight to this how-to. Alternatively, you can manually clean your system of the previous attempts, as outlined in various posts throughout this thread. But BE WARNED: If you have done ANY previous work on your wireless, there is almost no chance that this how-to will work unless you clean your system.&lt;br /&gt;&lt;br /&gt;If you have a fresh install of Ubuntu, you need to remove any and all versions of Ndiswrapper that come installed by default on your system:&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;sudo rmmod ndiswrapper&lt;br /&gt;sudo ndiswrapper -e bcmwl5&lt;br /&gt;sudo apt-get remove ndiswrapper-utils&lt;br /&gt;&lt;br /&gt;Don't worry if you get errors about not being able to find or remove these -- we're just making sure they're not present before we get started.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;STEP 2: GET NEEDED PACKAGES&lt;br /&gt;&lt;br /&gt;We'll need to install compiling tools (don't panic when you read that, just bear with me), the latest kernel headers, and then the source code for the latest ndiswrapper (seriously, don't panic. This will be very simple), and the wireless drivers from Dell.com.&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;sudo apt-get update&lt;br /&gt;sudo apt-get install build-essential&lt;br /&gt;sudo apt-get install linux-headers-`uname -r`&lt;br /&gt;wget http://ftp.us.dell.com/network/R151517.EXE&lt;br /&gt;&lt;br /&gt;NOTE: The characters around `uname -r` are BACK TICS, NOT apostrophes. A back tic is usually located at the top left of your keyboard, to the left of the 1 key. The command WILL NOT WORK if you use apostrophes. Just copy/paste the commands from this how-to in to your terminal to avoid making typos.&lt;br /&gt;&lt;br /&gt;At this point, you need to go to the ndiswrapper sourceforge site and get the latest version of the Ndiswrapper program.&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;wget http://superb-east.dl.sourceforge.net/sourceforge/ndiswrapper/ndiswrapper-1.51.tar.gz&lt;br /&gt;&lt;br /&gt;If that wget doesn't work, just go here: http://sourceforge.net/project/showf...group_id=93482&lt;br /&gt;&lt;br /&gt;Uncompress the ndiswrapper source (in my example, the file name is ndiswrapper-1.51.tar.gz):&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;tar -xzvf ndiswrapper-1.51.tar.gz&lt;br /&gt;&lt;br /&gt;Finally, we need to blacklist the broken and useless bcm43xx firmware drivers that try to load in a default ubuntu install:&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;sudo echo blacklist bcm43xx &gt;&gt; /etc/modprobe.d/blacklist&lt;br /&gt;&lt;br /&gt;NOTE: If the above command gives you a permission denied error, try this code instead:&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;sudo -s&lt;br /&gt;echo blacklist bcm43xx &gt;&gt; /etc/modprobe.d/blacklist&lt;br /&gt;exit&lt;br /&gt;&lt;br /&gt;YOU MUST REBOOT NOW!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;STEP 3: COMPILE PROGRAM&lt;br /&gt;&lt;br /&gt;Now we'll complile the Ndiswrapper program. In a terminal, go to the directory where you extracted ndiswrapper and execute the following:&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;cd YOUR-NDISWRAPPER-DIRECTORY&lt;br /&gt;sudo make uninstall&lt;br /&gt;&lt;br /&gt;IMPORTANT: Do the above command multiple times. You can stop when you get the message that says something about no files or directories found. This usually means running the command 2 or 3 times, but not more than about a dozen.&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;sudo make distclean&lt;br /&gt;sudo make&lt;br /&gt;sudo make install&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;STEP 4: INSTALL DRIVERS&lt;br /&gt;&lt;br /&gt;If that worked, then you now have Ndiswrapper installed. Now we need to install the drivers. In a terminal, go to the directory where you have the R151517.EXE file:&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;unzip -a R151517.EXE&lt;br /&gt;&lt;br /&gt;Now change directories to the DRIVER directory that was just extracted.&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;cd YOUR-DRIVER-DIRECTORY&lt;br /&gt;sudo ndiswrapper -i bcmwl5.inf&lt;br /&gt;sudo ndiswrapper -l&lt;br /&gt;&lt;br /&gt;you should see a message that says driver present, hardware detected&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;NDISwrapper in Fedora using Dell TrueMobile 1300&lt;br /&gt;Submitted by sandip on Sat, 10/09/2004 - 12:35. | Tags:&lt;br /&gt;&lt;br /&gt;    * Tutorials&lt;br /&gt;&lt;br /&gt;0&lt;br /&gt;points&lt;br /&gt;&lt;br /&gt;This step-by-step walk through is for Fedora CORE 1.0 using a Dell Latitude CPi with the PCMCIA Dell TrueMobile 1300 (BroadCom BCM94306) 802.11b/g wireless network card.&lt;br /&gt;&lt;br /&gt;Install the ndiswrapper by following the installation wiki documentation.&lt;br /&gt;&lt;br /&gt;NOTE: I was getting errors with the current release and 0.9 version finally worked for me, so try installing previous releases and use the one which works for you.&lt;br /&gt;&lt;br /&gt;Below are the steps that I took:&lt;br /&gt;1. Install the ndiswrapper using the rpm.&lt;br /&gt;&lt;br /&gt;#tar -zxvf ndiswrapper.tar.gz&lt;br /&gt;#cd ndiswrapper&lt;br /&gt;#make rpm&lt;br /&gt;#rpm -Uvh /usr/src/redhat/RPMS/i386/ndiswrapper*.rpm&lt;br /&gt;&lt;br /&gt;2. Install the windows driver as described in the infFile using ndiswrapper. You should have a ".inf" and a ".sys" file for this to work.&lt;br /&gt;&lt;br /&gt;#mount /mnt/cdrom (place the Dell TrueMobile Driver disk in the cdrom first)&lt;br /&gt;#ndiswrapper -i /mnt/cdrom/Setup/bcmwl5.inf&lt;br /&gt;&lt;br /&gt;3. Load the ndiswrapper module&lt;br /&gt;&lt;br /&gt;#modprobe ndiswrapper&lt;br /&gt;&lt;br /&gt;The light on the card should turn on at this point.&lt;br /&gt;&lt;br /&gt;4. Create and setup the network parameters for the interface wlan0.&lt;br /&gt;&lt;br /&gt;#cat &lt;&lt;EOF &gt; /etc/sysconfig/network-scripts/ifcfg-wlan0&lt;br /&gt;&gt;DEVICE=wlan0&lt;br /&gt;&gt;BOOTPROTO=dhcp&lt;br /&gt;&gt;ONBOOT=yes&lt;br /&gt;&gt;GATEWAY=192.168.2.1&lt;br /&gt;&gt;TYPE=Wireless&lt;br /&gt;&gt;ESSID=&lt;ESSID of your Access Point&gt;&lt;br /&gt;&gt;CHANNEL=&lt;CHANNEL # of your AP&gt;&lt;br /&gt;&gt;MODE=Managed&lt;br /&gt;&gt;KEY=&lt;your hex key&gt;&lt;br /&gt;&gt;EOF&lt;br /&gt;&lt;br /&gt;5. Configure the wireless network interface&lt;br /&gt;&lt;br /&gt;#iwconfig (look for your wlan card, mine came up with wlan0)&lt;br /&gt;#iwconfig wlan0 mode Managed&lt;br /&gt;#iwconfig wlan0 key &lt;your hex key&gt;&lt;br /&gt;#iwconifg wlan0 essid &lt;ESSID of your Access Point&gt;&lt;br /&gt;#ifconfig wlan0 &lt;IP Address&gt;&lt;br /&gt;#route add default gw &lt;192.168.2.1&gt;&lt;br /&gt;#ifup wlan0 &lt;br /&gt;&lt;br /&gt;I got an error but then it said '... done'.&lt;br /&gt;&lt;br /&gt;6. Check the wireless interface is up.&lt;br /&gt;&lt;br /&gt;#ifconfig (should list out wlan0 with an inet address)&lt;br /&gt;#ping 192.168.2.1 (Voila success!!)&lt;br /&gt;&lt;br /&gt;When this worked I instantly went to linuxweblog.com and noted down these steps for reference.&lt;br /&gt;&lt;br /&gt;7. Instead of automating the modprobe settings to load ndiswrapper as mentioned in the install docs via `ndiswrapper -m`, I put `modprobe ndiswrapper` in the "rc.local" file.&lt;br /&gt;&lt;br /&gt;#cat &lt;&lt;EOF &gt;&gt; /etc/rc.d/rc.local&lt;br /&gt;&gt;# Load ndiswrapper module&lt;br /&gt;&gt;modprobe ndiswrapper&lt;br /&gt;&gt;EOF&lt;br /&gt;&lt;br /&gt;sudo ndiswrapper -m&lt;br /&gt;sudo modprobe ndiswrapper&lt;br /&gt;sudo echo ndiswrapper &gt;&gt; /etc/modules&lt;br /&gt;&lt;br /&gt;NOTE: If the above echo command gives you a permission denied error, try this code instead:&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;sudo -s&lt;br /&gt;echo ndiswrapper &gt;&gt; /etc/modules&lt;br /&gt;exit&lt;br /&gt;&lt;br /&gt;Some users have reported the need to reboot here.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;STEP 5: TEST WIRELESS&lt;br /&gt;&lt;br /&gt;Your wifi light on your laptop should be illuminated, and you're all set! Try running this to see if your wireless card is functioning properly:&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;sudo iwlist scanning&lt;br /&gt;&lt;br /&gt;Even if it doesn't detect any wireless networks in range, it will still tell you if linux is recognizing your wireless card properly. If you'd like a better way to scan for wireless networks, I'd suggest installing/using network-manager or wifi-radar.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;TO ALL WHO REQUEST HELP:&lt;br /&gt;&lt;br /&gt;1) Please indicate:&lt;br /&gt;&lt;br /&gt;   1. your laptop model&lt;br /&gt;   2. ubuntu version&lt;br /&gt;   3. your lspci output&lt;br /&gt;   4. the relevant rows from /var/log/syslog&lt;br /&gt;   5. the relevant rows from dmesg&lt;br /&gt;   6. any unexpected output when following the steps in the how-to&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2) If your wireless card is being recognized by the system, but you simply cannot connect to your desired wireless network, please understand that your issue is beyond the scope of this how-to, due largely to the fact that such issues are very complicated and often have absolutely nothing to do with the way you got ubuntu to recognize your wireless card. That said, I will do what I can to help. My first suggestion will always be to turn off all encryption first to see if you can at least connect to an open network.&lt;br /&gt;&lt;br /&gt;NOTES:&lt;br /&gt;&lt;br /&gt;- Dell driver version updated to R151517.EXE on 30 March 2007&lt;br /&gt;- Ndiswrapper version updated to 1.51 on 7 January 2008&lt;br /&gt;- If you are using a Dell laptop that's NOT model E1505, you need to go to Dell.com and search for the drivers that correspond to your specific model. Use those instead.&lt;br /&gt;&lt;br /&gt;***********************************************************************************************&lt;br /&gt;NDISwrapper in Fedora using Dell TrueMobile 1300&lt;br /&gt;Submitted by sandip on Sat, 10/09/2004 - 12:35. | Tags:&lt;br /&gt;&lt;br /&gt;    * Tutorials&lt;br /&gt;&lt;br /&gt;0&lt;br /&gt;points&lt;br /&gt;&lt;br /&gt;This step-by-step walk through is for Fedora CORE 1.0 using a Dell Latitude CPi with the PCMCIA Dell TrueMobile 1300 (BroadCom BCM94306) 802.11b/g wireless network card.&lt;br /&gt;&lt;br /&gt;Install the ndiswrapper by following the installation wiki documentation.&lt;br /&gt;&lt;br /&gt;NOTE: I was getting errors with the current release and 0.9 version finally worked for me, so try installing previous releases and use the one which works for you.&lt;br /&gt;&lt;br /&gt;Below are the steps that I took:&lt;br /&gt;1. Install the ndiswrapper using the rpm.&lt;br /&gt;&lt;br /&gt;#tar -zxvf ndiswrapper.tar.gz&lt;br /&gt;#cd ndiswrapper&lt;br /&gt;#make rpm&lt;br /&gt;#rpm -Uvh /usr/src/redhat/RPMS/i386/ndiswrapper*.rpm&lt;br /&gt;&lt;br /&gt;2. Install the windows driver as described in the infFile using ndiswrapper. You should have a ".inf" and a ".sys" file for this to work.&lt;br /&gt;&lt;br /&gt;#mount /mnt/cdrom (place the Dell TrueMobile Driver disk in the cdrom first)&lt;br /&gt;#ndiswrapper -i /mnt/cdrom/Setup/bcmwl5.inf&lt;br /&gt;&lt;br /&gt;3. Load the ndiswrapper module&lt;br /&gt;&lt;br /&gt;#modprobe ndiswrapper&lt;br /&gt;&lt;br /&gt;The light on the card should turn on at this point.&lt;br /&gt;&lt;br /&gt;4. Create and setup the network parameters for the interface wlan0.&lt;br /&gt;&lt;br /&gt;#cat &lt;&lt;EOF &gt; /etc/sysconfig/network-scripts/ifcfg-wlan0&lt;br /&gt;&gt;DEVICE=wlan0&lt;br /&gt;&gt;BOOTPROTO=dhcp&lt;br /&gt;&gt;ONBOOT=yes&lt;br /&gt;&gt;GATEWAY=192.168.2.1&lt;br /&gt;&gt;TYPE=Wireless&lt;br /&gt;&gt;ESSID=&lt;ESSID of your Access Point&gt;&lt;br /&gt;&gt;CHANNEL=&lt;CHANNEL # of your AP&gt;&lt;br /&gt;&gt;MODE=Managed&lt;br /&gt;&gt;KEY=&lt;your hex key&gt;&lt;br /&gt;&gt;EOF&lt;br /&gt;&lt;br /&gt;5. Configure the wireless network interface&lt;br /&gt;&lt;br /&gt;#iwconfig (look for your wlan card, mine came up with wlan0)&lt;br /&gt;#iwconfig wlan0 mode Managed&lt;br /&gt;#iwconfig wlan0 key &lt;your hex key&gt;&lt;br /&gt;#iwconifg wlan0 essid &lt;ESSID of your Access Point&gt;&lt;br /&gt;#ifconfig wlan0 &lt;IP Address&gt;&lt;br /&gt;#route add default gw &lt;192.168.2.1&gt;&lt;br /&gt;#ifup wlan0 &lt;br /&gt;&lt;br /&gt;I got an error but then it said '... done'.&lt;br /&gt;&lt;br /&gt;6. Check the wireless interface is up.&lt;br /&gt;&lt;br /&gt;#ifconfig (should list out wlan0 with an inet address)&lt;br /&gt;#ping 192.168.2.1 (Voila success!!)&lt;br /&gt;&lt;br /&gt;When this worked I instantly went to linuxweblog.com and noted down these steps for reference.&lt;br /&gt;&lt;br /&gt;7. Instead of automating the modprobe settings to load ndiswrapper as mentioned in the install docs via `ndiswrapper -m`, I put `modprobe ndiswrapper` in the "rc.local" file.&lt;br /&gt;&lt;br /&gt;#cat &lt;&lt;EOF &gt;&gt; /etc/rc.d/rc.local&lt;br /&gt;&gt;# Load ndiswrapper module&lt;br /&gt;&gt;modprobe ndiswrapper&lt;br /&gt;&gt;EOF&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-293572536938177247?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/293572536938177247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=293572536938177247' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/293572536938177247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/293572536938177247'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/08/installing-wireless-using-windows.html' title='installing wireless using windows driver'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-3653480085577575499</id><published>2009-07-23T09:35:00.001-07:00</published><updated>2009-07-23T09:35:39.102-07:00</updated><title type='text'>hack the crack :D something i discovered during the last years of my undergrad!</title><content type='html'>We will have a very basic and simple approach. We will use a disassemble and an assembler.&lt;br /&gt;&lt;br /&gt;Disassemble is the process that will let us to view the "asm" source code of the&lt;br /&gt;dissembled file.&lt;br /&gt;Assembler - is the process that will allow us to make changes to the code.&lt;br /&gt;&lt;br /&gt;The most classic disassemble is W32Dasm, download it here:&lt;br /&gt;CODE&lt;br /&gt;http://foff.astalavista.ms/downloads/W32Dasm_8.93.zip&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The best assembler is HIEW32, download it here:&lt;br /&gt;CODE&lt;br /&gt;http://foff.astalavista.ms/downloads/Hiew726w.zip&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Download the file that we will crack here:&lt;br /&gt;CODE&lt;br /&gt;http://foff.astalavista.ms/downloads/cim_crackme.zip&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Unzip everything and we are ready to start!!!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Step1.&lt;br /&gt;&lt;br /&gt;Run the file "cim_crackme.exe", we see there two empty boxes. Name and Serial like many&lt;br /&gt;shareware software. Put there your name and any serial number then click on "Check"&lt;br /&gt;button. We will receive this message: "This is not a valid serial......" Write this&lt;br /&gt;message down, don't make errors. Just write the message without the quotes and the dots of course then close everything.&lt;br /&gt;&lt;br /&gt;Step2.&lt;br /&gt;&lt;br /&gt;Run W32Dasm disassemble, on the menu bar open the first menu "Disassemble" the "Open&lt;br /&gt;file to disassemble". Browse to our target "cim_crackme.exe" then disassemble. You now&lt;br /&gt;should see a lot of code on your screen&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Go at the search menu of W32Dasm and click on "Find Text", put in the search box the text&lt;br /&gt;string we did memorize somewhere: "this is not a valid serial" (without the quotes).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;:&lt;br /&gt;&lt;br /&gt;*Referenced by (U)nconditional or ©onditional Jump at Address:&lt;br /&gt;|:004010D7&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You should record the address you see: 004010D7 (is very important)&lt;br /&gt;&lt;br /&gt;Now, go up once more until you find the address you just recorded,&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The arrow number 1 show who is addresses group located. In the circle is the address we&lt;br /&gt;were looking for. The address and all the row is selected by the green bar too! I hope&lt;br /&gt;everything is clear enough! As you see, there is an other arrow, "arrow 2" that indicates&lt;br /&gt;"JNE". What does "JNE" mean???&lt;br /&gt;&lt;br /&gt;JNE - Jump if not equal&lt;br /&gt;JE - Jump if equal&lt;br /&gt;&lt;br /&gt;When we enter a fake serial number, it jumps. Hmmm, we should reverse it. The reverse of&lt;br /&gt;"JNE" is "JE". If we do this, the program will accept any serial number as a real one!!!&lt;br /&gt;&lt;br /&gt;But how do we edit it???&lt;br /&gt;&lt;br /&gt;Using an assembler of course&lt;br /&gt;&lt;br /&gt;Our mission now is to reverse "JNE" to "JE" at the address: "004010D7".&lt;br /&gt;&lt;br /&gt;Step3.&lt;br /&gt;&lt;br /&gt;Now send a desktop icon of HIEW32 then drag and drop "cim_crackme.exe" over it. You should&lt;br /&gt;see some crap code, now press F4 from the keyboard then choose decode from the selection.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, return to HIEW and press F5 from keyboard then enter the address we recorded above&lt;br /&gt;but don't forget to add a dot before the address and to remove the zeros before the&lt;br /&gt;address number. Enter it like this: ".4010D7" (without the quotes of course) then hit&lt;br /&gt;ENTER. After this you will land in the exact address where we will do the reversing.&lt;br /&gt;Notice this line carefully:&lt;br /&gt;&lt;br /&gt;.004010D7: 7516 jne .0004010EF&lt;br /&gt;&lt;br /&gt;We should change the bytes here. Without moving the selection from "75" press F3 from&lt;br /&gt;keyboard then hit the right arrow of the keyboard directional keys one time, be sure to&lt;br /&gt;have the cursor under the number "5". Carefully press the number 4 from the keyboard. The&lt;br /&gt;number will change from "7516" to "7416". Carefully press F9 from keyboard to save our&lt;br /&gt;changes and F10 to exit at all! We are done!!!&lt;br /&gt;&lt;br /&gt;Now check that everything is ok, run "cim_crackme.exe" that you just cracked and put you&lt;br /&gt;name and any serial number..............CONGRATULATIONS!!! You Cracked It.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-3653480085577575499?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/3653480085577575499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=3653480085577575499' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/3653480085577575499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/3653480085577575499'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/07/hack-crack-d-something-i-discovered.html' title='hack the crack :D something i discovered during the last years of my undergrad!'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-1455154883730644057</id><published>2009-05-13T16:32:00.000-07:00</published><updated>2009-05-13T16:34:36.383-07:00</updated><title type='text'>MBR and its back up</title><content type='html'>1. Use the Norton Utilities.&lt;br /&gt;&lt;br /&gt;2. Use Debug, as found in DOS, it is also available from the DOS prompt&lt;br /&gt;   in Windows/95 so I assume it is also available in Windows/98.&lt;br /&gt;&lt;br /&gt;   Enter the following commands to save the MBR on the C drive, ignore&lt;br /&gt;   the text after the '&lt;=' on each line as it is only a comment:&lt;br /&gt;&lt;br /&gt;   DEBUG MBR.DAT       &lt;= Ignore the FILE NOT FOUND message&lt;br /&gt;   A                   &lt;= Assemble a program&lt;br /&gt;   MOV DX,9000         &lt;= Use segment 9000&lt;br /&gt;   MOV ES,DX           &lt;= Setup the segment register&lt;br /&gt;   XOR BX,BX           &lt;= Clear BX to zero&lt;br /&gt;   MOV CX,0001         &lt;= Start at track 00 sector 01, the MBR&lt;br /&gt;   MOV DX,0080         &lt;= 80=C:, 81=D:, 00=A:, 01=B:&lt;br /&gt;   MOV AX,0201         &lt;= Read 1 sector, 02=read&lt;br /&gt;   INT 13              &lt;= BIOS disk i/o call&lt;br /&gt;   INT 20              &lt;= Return to o/s&lt;br /&gt;                       &lt;= Press the return key to end program entry&lt;br /&gt;   G                   &lt;= Execute the program&lt;br /&gt;   R CX                &lt;= Display the value of CX&lt;br /&gt;   :200                &lt;= Change the value of CX to decimal 512, size of&lt;br /&gt;MBR&lt;br /&gt;   W 9000:00           &lt;= Write the sector stored at address 9000 to&lt;br /&gt;MBR.DAT&lt;br /&gt;   Q                   &lt;= exit DEBUG&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you examine the contents of MBR.DAT using a disk file editor the last&lt;br /&gt;&lt;br /&gt;2 bytes must be AA55.&lt;br /&gt;&lt;br /&gt;At this point you should copy the MBR to a bootable floppy along with&lt;br /&gt;DEBUG.EXE&lt;br /&gt;&lt;br /&gt;This technique may be used to recover the MBR as well, assuming you can&lt;br /&gt;boot from another device (say a floppy with DEBUG.EXE on it).&lt;br /&gt;&lt;br /&gt;Enter the following commands to restore the MBR on the C drive, ignore&lt;br /&gt;the text after the '&lt;=' on each line as it is only a comment:&lt;br /&gt;&lt;br /&gt;  DEBUG MBR.DAT        &lt;= The file containing the desired MBR, if you&lt;br /&gt;get a&lt;br /&gt;                          FILE NOT FOUND message type Q immediately! If&lt;br /&gt;you&lt;br /&gt;                          continue you will write garbage over the MBR.&lt;br /&gt;  L 9000:00            &lt;= Load the MBR into memory at this address&lt;br /&gt;  A                    &lt;= Assemble a program&lt;br /&gt;  MOV DX,9000        &lt;= The segment address containing the MBR&lt;br /&gt;  MOV ES,DX            &lt;= Setup the segment address&lt;br /&gt;  XOR BX,BX&lt;br /&gt;  MOV CX,0001          &lt;= Track 00, sector 01&lt;br /&gt;  MOV DX,0080          &lt;= 80=C:&lt;br /&gt;  MOV AX,0301          &lt;= Write one sector, 03=write&lt;br /&gt;  INT 13&lt;br /&gt;  INT 20&lt;br /&gt;                       &lt;= Press the enter key to stop program entry&lt;br /&gt;  G                    &lt;= Execute the program&lt;br /&gt;  Q                    &lt;= Exit DEBUG&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The MBR should now be restored to the C drive, making it bootable.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For more information on this technique for saving and restoring an MBR I&lt;br /&gt;&lt;br /&gt;refer you the book 'The Complete PC Upgrade and Maintenance Guide' by&lt;br /&gt;Mark Minasi, published by Sybex.&lt;br /&gt;&lt;br /&gt;Once you have Linux running you can save the boot record with the&lt;br /&gt;command:&lt;br /&gt;&lt;br /&gt;  dd if=/dev/hda of=/boot/boot.MBR bs=512 count=1&lt;br /&gt;&lt;br /&gt;It can then be restored with:&lt;br /&gt;&lt;br /&gt;  dd if=/boot/boot.MBR of=/dev/hda bs=512 count=1&lt;br /&gt;&lt;br /&gt;or if you do not want/need to overwrite the partition table with:&lt;br /&gt;&lt;br /&gt;  dd if=/boot/boot.MBR of=/dev/hda bs=446 count=1&lt;br /&gt;&lt;br /&gt;as the partition table is kept in the last 66 bytes of the MBR.&lt;br /&gt;&lt;br /&gt;DISCLAIMER:&lt;br /&gt;  Although I have double checked the above, I cannot be held responsible&lt;br /&gt;  for any errors. I suggest you try it on a bootable floppy disk before&lt;br /&gt;  using it on a hard drive. If it does not work on a floppy disk let me&lt;br /&gt;  know.&lt;br /&gt;&lt;br /&gt;BTW: I find it easier to boot Linux from a floppy disk or CD-ROM than to&lt;br /&gt;recover an MBR from DOS. The Slackware 3.5 (or greater) CD-ROM&lt;br /&gt;makes a good rescue disk if you have a bios that supports bootable CDs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-1455154883730644057?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/1455154883730644057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=1455154883730644057' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/1455154883730644057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/1455154883730644057'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/05/mbr-and-its-back-up.html' title='MBR and its back up'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-3828563466714160509</id><published>2009-01-05T11:36:00.001-08:00</published><updated>2009-01-05T17:53:03.621-08:00</updated><title type='text'>types of libraries and their creation</title><content type='html'>&lt;b&gt;&lt;big&gt;Why libraries are used:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/big&gt;&lt;/b&gt;The following content has been taken from:&lt;br /&gt;&lt;br /&gt;http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html&lt;br /&gt;&lt;br /&gt;This methodology, also known as "shared components" or "archive libraries", groups together multiple compiled object code files into a single file known as a library. Typically C functions/C++ classes and methods which can be shared by more than one application are broken out of the application's source code, compiled and bundled into a library. The C standard libraries and C++ STL are examples of shared components which can be linked with your code. The benefit is that each and every object file need not be stated when linking because the developer can reference the individual library. This simplifies the multiple use and sharing of software components between applications. It also allows application vendors a way to simply release an API to interface with an application. Components which are large can be created for dynamic use, thus the library remain separate from the executable reducing it's size and thus disk space used. The library components are then called by various applications for use when needed.        &lt;p&gt;        &lt;/p&gt;       &lt;hr /&gt;       &lt;table width="100%" border="0" cellpadding="2" cellspacing="0"&gt;          &lt;tbody&gt;           &lt;tr bgcolor="#ffcc33"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;Linux Library Types: &lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;          &lt;/tbody&gt;       &lt;/table&gt;        &lt;p&gt; There are two library types which can be created:       &lt;/p&gt;       &lt;ol&gt;&lt;li&gt;Static libraries (.a): Library of object code which is linked with, and becomes part of the application.         &lt;/li&gt;&lt;li&gt;Dynamically linked shared object libraries (.so): There is only one form of this library but it can be used in two ways.                &lt;ol&gt;&lt;li&gt;Dynamically linked at run time but statically aware. The libraries must be available during compile/link phase. The shared objects are not included into the executable component but are tied to the execution. &lt;/li&gt;&lt;li&gt;Dynamically loaded/unloaded and linked during execution (i.e. browser plug-in) using the dynamic linking loader system functions. &lt;/li&gt;&lt;/ol&gt;          &lt;/li&gt;&lt;/ol&gt;        &lt;p&gt;        &lt;/p&gt;       &lt;h4&gt;Library naming conventions:&lt;/h4&gt; Libraries are typically names with the prefix "lib". This is true for all the C standard libraries. When linking, the command line reference to the library will not contain the library prefix or suffix.       &lt;p&gt; Thus the following link command: &lt;tt&gt;gcc src-file.c -lm -lpthread&lt;/tt&gt;     &lt;br /&gt;The libraries referenced in this example for inclusion during linking  are the math library and the thread library. They are found in        &lt;tt&gt;/usr/lib/lib&lt;b&gt;m&lt;/b&gt;.a&lt;/tt&gt; and &lt;tt&gt;/usr/lib/lib&lt;b&gt;pthread&lt;/b&gt;.a&lt;/tt&gt;.        &lt;/p&gt;       &lt;p&gt;        &lt;/p&gt;       &lt;hr /&gt;       &lt;table width="100%" border="0" cellpadding="2" cellspacing="0"&gt;          &lt;tbody&gt;           &lt;tr bgcolor="#ffcc33"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;Static Libraries: (.a)&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;          &lt;/tbody&gt;       &lt;/table&gt;        &lt;p&gt;  How to generate a library:      &lt;/p&gt;       &lt;ul&gt;&lt;li&gt;Compile: &lt;tt&gt;cc -Wall -c ctest1.c ctest2.c&lt;/tt&gt;       &lt;br /&gt;        Compiler options:                    &lt;ul&gt;&lt;li&gt;-Wall: include warnings. See man page for warnings specified.         &lt;/li&gt;&lt;/ul&gt;      &lt;/li&gt;&lt;li&gt;Create library "libctest.a": &lt;tt&gt;ar -cvq libctest.a ctest1.o ctest2.o&lt;/tt&gt;     &lt;/li&gt;&lt;li&gt;List files in library: &lt;tt&gt;ar -t libctest.a&lt;/tt&gt;     &lt;/li&gt;&lt;li&gt;Linking with the library:                     &lt;ul&gt;&lt;li&gt;&lt;tt&gt;cc -o &lt;i&gt;executable-name&lt;/i&gt; prog.c libctest.a&lt;/tt&gt;         &lt;/li&gt;&lt;li&gt;&lt;tt&gt;cc -o &lt;i&gt;executable-name&lt;/i&gt; prog.c -L/path/to/library-directory -lctest&lt;/tt&gt;         &lt;/li&gt;&lt;/ul&gt;      &lt;/li&gt;&lt;li&gt;Example files:                     &lt;ul&gt;&lt;li&gt;ctest1.c                            &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;              &lt;tbody&gt;                   &lt;tr bgcolor="#c0c0c0"&gt;                     &lt;td&gt;                                  &lt;pre&gt;void ctest1(int *i)&lt;br /&gt;{&lt;br /&gt; *i=5;&lt;br /&gt;}&lt;br /&gt;          &lt;/pre&gt;              &lt;/td&gt;                   &lt;/tr&gt;                 &lt;/tbody&gt;               &lt;/table&gt;          &lt;/li&gt;&lt;li&gt;ctest2.c                            &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;              &lt;tbody&gt;                   &lt;tr bgcolor="#c0c0c0"&gt;                     &lt;td&gt;                                  &lt;pre&gt;void ctest2(int *i)&lt;br /&gt;{&lt;br /&gt; *i=100;&lt;br /&gt;}&lt;br /&gt;          &lt;/pre&gt;              &lt;/td&gt;                   &lt;/tr&gt;                 &lt;/tbody&gt;               &lt;/table&gt;          &lt;/li&gt;&lt;li&gt;prog.c                            &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;              &lt;tbody&gt;                   &lt;tr bgcolor="#c0c0c0"&gt;                     &lt;td&gt;                                  &lt;pre&gt;#include &lt;stdio.h&gt;&lt;br /&gt;void ctest1(int *);&lt;br /&gt;void ctest2(int *);&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; int x;&lt;br /&gt; ctest1(&amp;amp;x);&lt;br /&gt; printf("Valx=%d\n",x);&lt;br /&gt;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;          &lt;/stdio.h&gt;&lt;/pre&gt;              &lt;/td&gt;                   &lt;/tr&gt;                 &lt;/tbody&gt;               &lt;/table&gt;          &lt;/li&gt;&lt;/ul&gt;      &lt;/li&gt;&lt;/ul&gt;  Historical note:  After creating the library it was once necessary to run the command: &lt;tt&gt;ranlib ctest.a&lt;/tt&gt;. This created a symbol table within the archive. Ranlib is now embedded into the "ar" command.       &lt;p&gt; Note for MS/Windows developers: The Linux/Unix ".a" library is conceptually the same as the Visual C++ static ".lib" libraries.       &lt;/p&gt;       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;table width="100%" border="0" cellpadding="2" cellspacing="0"&gt;          &lt;tbody&gt;           &lt;tr bgcolor="#ffcc33"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;Dynamically Linked "Shared Object" Libraries: (.so)&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;          &lt;/tbody&gt;       &lt;/table&gt;        &lt;p&gt; How to generate a shared object: (Dynamically linked object library file.) Note that this is a two step process.       &lt;/p&gt;       &lt;ol&gt;&lt;li&gt;Create object code         &lt;/li&gt;&lt;li&gt;Create library         &lt;/li&gt;&lt;li&gt;Optional: create default version using a symbolic link.         &lt;/li&gt;&lt;/ol&gt;        &lt;b&gt;Library creation example:&lt;/b&gt;          &lt;dl&gt;&lt;dd&gt;          &lt;pre&gt;    gcc -Wall -fPIC -c *.c&lt;br /&gt;  gcc -shared -Wl,-soname,libctest.so.1 -o libctest.so.1.0   *.o&lt;br /&gt;  mv libctest.so.1.0 /opt/lib&lt;br /&gt;  ln -sf /opt/lib/libctest.so.1.0 /opt/lib/libctest.so&lt;br /&gt;  ln -sf /opt/lib/libctest.so.1.0 /opt/lib/libctest.so.1&lt;br /&gt;        &lt;/pre&gt;      This creates the library &lt;tt&gt;libctest.so.1.0&lt;/tt&gt; and symbolic links to it.          &lt;p&gt;     Compiler options:     &lt;/p&gt;     &lt;ul&gt;&lt;li&gt;&lt;tt&gt;-Wall&lt;/tt&gt;: include warnings. See man page for warnings specified.     &lt;/li&gt;&lt;li&gt;&lt;tt&gt;-fPIC&lt;/tt&gt;: Compiler directive to output position independent code,  a characteristic required by shared libraries. Also see "-fpic".     &lt;/li&gt;&lt;li&gt;&lt;tt&gt;-shared&lt;/tt&gt;: Produce  a  shared  object which can then be linked with other objects to form an executable.     &lt;/li&gt;&lt;li&gt;&lt;tt&gt;-W1&lt;/tt&gt;: Pass options to linker.       &lt;br /&gt;In this example the options to be passed on to the linker are:         "&lt;tt&gt;-soname libctest.so.1&lt;/tt&gt;".         The name passed with the "-o" option is passed to &lt;tt&gt;gcc&lt;/tt&gt;.     &lt;/li&gt;&lt;li&gt;Option &lt;tt&gt;-o&lt;/tt&gt;: Output of operation. In this case the name of the shared object to be output will be "&lt;tt&gt;libctest.so.1.0&lt;/tt&gt;"     &lt;/li&gt;&lt;/ul&gt;                 &lt;p&gt;     Library Links:     &lt;/p&gt;           &lt;ul&gt;&lt;li&gt;The link to &lt;tt&gt;/opt/lib/libctest.so&lt;/tt&gt; allows the naming convention for the compile flag &lt;tt&gt;-lctest&lt;/tt&gt; to work.     &lt;/li&gt;&lt;li&gt;The link to &lt;tt&gt;/opt/lib/libctest.so.1&lt;/tt&gt; allows the run time binding to work. See dependency below.     &lt;/li&gt;&lt;/ul&gt;      &lt;/dd&gt;&lt;/dl&gt;             &lt;p&gt;       &lt;b&gt;Compile main program and link with shared object library:&lt;/b&gt;       &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt; Compiling for runtime linking with a dynamically linked &lt;tt&gt;libctest.so.1.0&lt;/tt&gt;:           &lt;pre&gt;    gcc -Wall -I&lt;i&gt;/path/to/include-files&lt;/i&gt; -L&lt;i&gt;/path/to/libraries&lt;/i&gt; prog.c -lctest -o prog&lt;br /&gt;Use:&lt;br /&gt;  gcc -Wall -L/opt/lib prog.c -lctest -o prog&lt;br /&gt;    &lt;/pre&gt;  Where the name of the library is &lt;tt&gt;libctest.so&lt;/tt&gt;. (This is why you must create the symbolic links or you will get the error "/usr/bin/ld: cannot find -lctest".)   &lt;br /&gt;The libraries will NOT be included in the executable but will be dynamically linked during runtime execution.         &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt;       &lt;b&gt;List Dependencies:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; The shared library dependencies of the executable can be listed with the command: &lt;tt&gt;&lt;a href="http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=ldd"&gt;&lt;b&gt;ldd&lt;/b&gt;&lt;/a&gt; &lt;i&gt;name-of-executable&lt;/i&gt;&lt;/tt&gt;       &lt;/p&gt;       &lt;p&gt;     &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;     Example: &lt;tt&gt;ldd prog&lt;/tt&gt;                &lt;pre&gt;        libctest.so.1 =&gt; /opt/lib/libctest.so.1 (0x00002aaaaaaac000)&lt;br /&gt;      libc.so.6 =&gt; /lib64/tls/libc.so.6 (0x0000003aa4e00000)&lt;br /&gt;      /lib64/ld-linux-x86-64.so.2 (0x0000003aa4c00000)&lt;br /&gt;  &lt;/pre&gt;      &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt;       &lt;b&gt;Run Program:&lt;/b&gt;    &lt;/p&gt;       &lt;ul&gt;&lt;li&gt;Set path: &lt;tt&gt;export LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH&lt;/tt&gt;    &lt;/li&gt;&lt;li&gt;Run: &lt;tt&gt;prog&lt;/tt&gt;    &lt;/li&gt;&lt;/ul&gt;        &lt;p&gt;       &lt;b&gt;Man Pages:&lt;/b&gt;     &lt;/p&gt;       &lt;ul&gt;&lt;li&gt;&lt;a href="http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=gcc"&gt;gcc&lt;/a&gt; - GNU C compiler     &lt;/li&gt;&lt;li&gt;&lt;a href="http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=ld"&gt;ld&lt;/a&gt; - The GNU Linker     &lt;/li&gt;&lt;li&gt;&lt;a href="http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=ldd"&gt;ldd&lt;/a&gt; - List dependencies     &lt;/li&gt;&lt;/ul&gt;        &lt;p&gt;       &lt;b&gt;Links:&lt;/b&gt;       &lt;/p&gt;       &lt;ul&gt;&lt;li&gt;&lt;a href="http://www.tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html"&gt;LDP: Shared libraries&lt;/a&gt;         &lt;/li&gt;&lt;/ul&gt;        &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;table width="100%" border="0" cellpadding="2" cellspacing="0"&gt;          &lt;tbody&gt;           &lt;tr bgcolor="#c0c0c0"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;Library Path:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;          &lt;/tbody&gt;       &lt;/table&gt;        &lt;p&gt;In order for an executable to find the required libraries to link with during run time, one must configure the system so that the libraries can be found. Methods available: (Do at least one of the following) &lt;/p&gt;       &lt;ol&gt;&lt;li&gt;Add library directories to be included during dynamic linking to the file           &lt;tt&gt;/etc/ld.so.conf&lt;/tt&gt;           &lt;p&gt; Sample: &lt;tt&gt;/etc/ld.so.conf&lt;/tt&gt;           &lt;/p&gt;           &lt;dl&gt;&lt;dd&gt;               &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;                 &lt;tbody&gt;                   &lt;tr bgcolor="#c0c0c0"&gt;                     &lt;td&gt;                     &lt;pre&gt;/usr/X11R6/lib&lt;br /&gt;/usr/lib&lt;br /&gt;...&lt;br /&gt;..&lt;br /&gt;/usr/lib/sane&lt;br /&gt;/usr/lib/mysql&lt;br /&gt;/opt/lib&lt;br /&gt;                  &lt;/pre&gt;                     &lt;/td&gt;                   &lt;/tr&gt;                 &lt;/tbody&gt;               &lt;/table&gt;              &lt;/dd&gt;&lt;/dl&gt; Add the library path to this file and then execute the command (as root)           &lt;tt&gt;ldconfig&lt;/tt&gt; to configure the linker run-time bindings.          &lt;br /&gt;You can use the "&lt;b&gt;-f &lt;i&gt;file-name&lt;/i&gt;&lt;/b&gt;" flag to reference another  configuration file if you are developing for different environments.         &lt;br /&gt;See man page for command            &lt;a href="http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=ldconfig"&gt;ldconfig&lt;/a&gt;.           &lt;p&gt;           &lt;b&gt;OR&lt;/b&gt;           &lt;/p&gt;           &lt;p&gt;           &lt;/p&gt;         &lt;/li&gt;&lt;li&gt;Add specified directory to library cache: (as root)           &lt;br /&gt;         &lt;tt&gt;ldconfig -n &lt;i&gt;/opt/lib&lt;/i&gt;&lt;/tt&gt;           &lt;br /&gt;       Where &lt;tt&gt;/opt/lib&lt;/tt&gt; is the directory containing your library &lt;tt&gt;libctest.so&lt;/tt&gt;           &lt;br /&gt;(When developing and just adding your current directory: &lt;tt&gt;ldconfig -n .&lt;/tt&gt; Link with -L.)           &lt;p&gt;This will NOT permanently configure the system to include this directory. The information will be lost upon system reboot.           &lt;/p&gt;           &lt;p&gt;           &lt;b&gt;OR&lt;/b&gt;           &lt;/p&gt;           &lt;p&gt;           &lt;/p&gt;         &lt;/li&gt;&lt;li&gt;Specify the environment variable &lt;tt&gt;LD_LIBRARY_PATH&lt;/tt&gt; to point to the directory paths containing the shared object library. This will specify to the run time loader that the library paths will be used during execution to resolve dependencies.   &lt;br /&gt;(Linux/Solaris: &lt;tt&gt;LD_LIBRARY_PATH&lt;/tt&gt;, SGI: &lt;tt&gt;LD_LIBRARYN32_PATH&lt;/tt&gt;, AIX: &lt;tt&gt;LIBPATH&lt;/tt&gt;, Mac OS X: &lt;tt&gt;DYLD_LIBRARY_PATH&lt;/tt&gt;, HP-UX: &lt;tt&gt;SHLIB_PATH&lt;/tt&gt;)           &lt;p&gt; Example (bash shell): &lt;tt&gt;export LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH&lt;/tt&gt; or add to your &lt;tt&gt;~/.bashrc&lt;/tt&gt; file:           &lt;/p&gt;           &lt;dl&gt;&lt;dd&gt;               &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;                  &lt;tbody&gt;                   &lt;tr bgcolor="#c0c0c0"&gt;                     &lt;td&gt;                     &lt;pre&gt;...&lt;br /&gt;if [ -d /opt/lib ];&lt;br /&gt;then&lt;br /&gt; LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;export LD_LIBRARY_PATH&lt;br /&gt;    &lt;/pre&gt;                      &lt;/td&gt;                   &lt;/tr&gt;                 &lt;/tbody&gt;               &lt;/table&gt;              &lt;/dd&gt;&lt;/dl&gt;          &lt;br /&gt;This instructs the run time loader to look in the path described by the environment variable &lt;tt&gt;LD_LIBRARY_PATH&lt;/tt&gt;, to resolve shared libraries. This will include the path &lt;tt&gt;/opt/lib&lt;/tt&gt;.         &lt;/li&gt;&lt;/ol&gt;        &lt;p&gt; Library paths used should conform to the "&lt;a href="http://www.linuxbase.org/"&gt;Linux Standard Base&lt;/a&gt;" directory structure.       &lt;/p&gt;       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;table width="100%" border="0" cellpadding="2" cellspacing="0"&gt;          &lt;tbody&gt;           &lt;tr bgcolor="#c0c0c0"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;Library Info:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;          &lt;/tbody&gt;       &lt;/table&gt;        &lt;p&gt; The command "nm" lists symbols contained in the object file or shared library.       &lt;/p&gt;       &lt;p&gt; Use the command &lt;tt&gt;nm -D libctest.so.1.0&lt;/tt&gt;     &lt;br /&gt;(or &lt;tt&gt;nm --dynamic libctest.so.1.0&lt;/tt&gt;)       &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;pre&gt;0000000000100988 A __bss_start&lt;br /&gt;000000000000068c T ctest1&lt;br /&gt;00000000000006a0 T ctest2&lt;br /&gt;               w __cxa_finalize&lt;br /&gt;00000000001007b0 A _DYNAMIC&lt;br /&gt;0000000000100988 A _edata&lt;br /&gt;0000000000100990 A _end&lt;br /&gt;00000000000006f8 T _fini&lt;br /&gt;0000000000100958 A _GLOBAL_OFFSET_TABLE_&lt;br /&gt;               w __gmon_start__&lt;br /&gt;00000000000005b0 T _init&lt;br /&gt;               w _Jv_RegisterClasses&lt;br /&gt;    &lt;/pre&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;a href="http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=nm"&gt;Man page for nm&lt;/a&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table border="1"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;th&gt;Symbol Type&lt;/th&gt;                 &lt;th&gt;Description&lt;/th&gt;               &lt;/tr&gt;                &lt;tr&gt;                 &lt;td&gt;A&lt;/td&gt;                 &lt;td&gt;The  symbol's  value  is absolute, and will not be changed by further linking.&lt;/td&gt;               &lt;/tr&gt;                &lt;tr&gt;                 &lt;td&gt;B&lt;/td&gt;                 &lt;td&gt;Un-initialized data section&lt;/td&gt;               &lt;/tr&gt;                &lt;tr&gt;                 &lt;td&gt;D&lt;/td&gt;                 &lt;td&gt;Initialized data section&lt;/td&gt;               &lt;/tr&gt;                &lt;tr&gt;                 &lt;td&gt;T&lt;/td&gt;                 &lt;td&gt;Normal code section&lt;/td&gt;               &lt;/tr&gt;                &lt;tr&gt;                 &lt;td&gt;U&lt;/td&gt;                 &lt;td&gt;Undefined symbol used but not defined. Dependency on another library.&lt;/td&gt;               &lt;/tr&gt;                &lt;tr&gt;                 &lt;td&gt;W&lt;/td&gt;                 &lt;td&gt;Doubly defined symbol. If found, allow definition in another library to resolve dependency.&lt;/td&gt;               &lt;/tr&gt;              &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt; Also see:       &lt;a href="http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=objdump"&gt;objdump&lt;/a&gt; man page       &lt;/p&gt;       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;table width="100%" border="0" cellpadding="2" cellspacing="0"&gt;          &lt;tbody&gt;           &lt;tr bgcolor="#ffcc33"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;Library Versions:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;          &lt;/tbody&gt;       &lt;/table&gt;        &lt;p&gt;Library versions should be specified for shared objects if the function interfaces are expected to change (C++ public/protected class definitions), more or fewer functions are included in the library, the function prototype changes (return data type (int, const int, ...) or argument list changes) or data type changes (object definitions: class data members, inheritance, virtual functions, ...). &lt;/p&gt;       &lt;p&gt;The library version can be specified when the shared object library is created. If the library is expected to be updated, then a library version should be specified. This is especially important for shared object libraries which are dynamically linked. This also avoids the Microsoft "DLL hell" problem of conflicting libraries where a system upgrade which changes a standard library breaks an older application expecting an older version of the the shared object function. &lt;/p&gt;       &lt;p&gt;Versioning occurs with the GNU C/C++ libraries as well. This often make binaries compiled with one version of the GNU tools incompatible with binaries compiled with other versions unless those versions also reside on the system. Multiple versions of the same library can reside on the same system due to versioning. The version of the library is included in the symbol name so the linker knows which version to link with. &lt;/p&gt;       &lt;p&gt; One can look at the symbol version used: &lt;tt&gt;nm csub1.o&lt;/tt&gt;       &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;pre&gt;00000000 T ctest1&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  No version is specified in object code by default.         &lt;/dd&gt;&lt;/dl&gt;        &lt;a href="http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_mono/ld.html"&gt;ld and object file layout&lt;/a&gt;       &lt;p&gt; There is one GNU C/C++ compiler flag that explicitly deals with symbol versioning. Specify the version script to use at compile time with the flag: &lt;tt&gt;--version-script=&lt;i&gt;your-version-script-file&lt;/i&gt;&lt;/tt&gt;     &lt;br /&gt;Note: This is only useful when creating shared libraries. It is assumed that the programmer knows which libraries to link with when static linking. Runtime linking allows opportunity for library incompatibility. &lt;/p&gt;       &lt;p&gt; GNU/Linux, see examples of version scripts here:     &lt;tt&gt;sysdeps/unix/sysv/linux/Versions&lt;/tt&gt;       &lt;/p&gt;       &lt;p&gt; Some symbols may also get version strings from assembler code which appears in glibc headers files.  Look at &lt;tt&gt;include/libc-symbols.h&lt;/tt&gt;.       &lt;/p&gt;       &lt;p&gt; Example: &lt;tt&gt; nm /lib/libc.so.6 | more&lt;/tt&gt;       &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;pre&gt;00000000 A GCC_3.0&lt;br /&gt;00000000 A GLIBC_2.0&lt;br /&gt;00000000 A GLIBC_2.1&lt;br /&gt;00000000 A GLIBC_2.1.1&lt;br /&gt;00000000 A GLIBC_2.1.2&lt;br /&gt;00000000 A GLIBC_2.1.3&lt;br /&gt;00000000 A GLIBC_2.2&lt;br /&gt;00000000 A GLIBC_2.2.1&lt;br /&gt;00000000 A GLIBC_2.2.2&lt;br /&gt;00000000 A GLIBC_2.2.3&lt;br /&gt;00000000 A GLIBC_2.2.4&lt;br /&gt;...&lt;br /&gt;..&lt;br /&gt;    &lt;/pre&gt;  Note the use of a version script.           &lt;p&gt; Library referencing a versioned library: &lt;tt&gt;nm /lib/libutil-2.2.5.so&lt;/tt&gt;           &lt;/p&gt;           &lt;pre&gt;..&lt;br /&gt;...&lt;br /&gt;       U strcpy@@GLIBC_2.0&lt;br /&gt;       U strncmp@@GLIBC_2.0&lt;br /&gt;       U strncpy@@GLIBC_2.0&lt;br /&gt;...&lt;br /&gt;..&lt;br /&gt;    &lt;/pre&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt;       &lt;b&gt;Links:&lt;/b&gt;       &lt;/p&gt;       &lt;ul&gt;&lt;li&gt;&lt;a href="http://gcc.gnu.org/ml/gcc-help/2004-03/msg00265.html"&gt;Symbol versioning&lt;/a&gt;         &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_mono/ld.html#SEC25"&gt;GNU.org: ld version scripts&lt;/a&gt;         &lt;/li&gt;&lt;/ul&gt;        &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;table width="100%" border="0" cellpadding="2" cellspacing="0"&gt;          &lt;tbody&gt;           &lt;tr bgcolor="#ffcc33"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;Dynamic loading and un-loading of shared libraries using libdl:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;          &lt;/tbody&gt;       &lt;/table&gt;        &lt;p&gt;  These libraries are dynamically loaded / unloaded and linked during execution.  Usefull for creating a "plug-in" architecture.       &lt;/p&gt;       &lt;p&gt;  Prototype include file for the library: &lt;tt&gt;ctest.h&lt;/tt&gt;       &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;              &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;#ifndef CTEST_H&lt;br /&gt;#define CTEST_H&lt;br /&gt;&lt;br /&gt;#ifdef __cplusplus&lt;br /&gt;extern "C" {&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;void ctest1(int *);&lt;br /&gt;void ctest2(int *);&lt;br /&gt;&lt;br /&gt;#ifdef __cplusplus&lt;br /&gt;}&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;#endif&lt;br /&gt;    &lt;/pre&gt;                  &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;  Use the notation &lt;tt&gt;extern "C"&lt;/tt&gt; so the libraries can be used with C and C++. This statement prevents the C++ from name mangling and thus creating "unresolved symbols" when linking. &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt;  Load and unload the library &lt;tt&gt;libctest.so&lt;/tt&gt; (created above), dynamically:       &lt;/p&gt;       &lt;dl&gt;&lt;dd&gt;           &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;             &lt;tbody&gt;               &lt;tr bgcolor="#c0c0c0"&gt;                 &lt;td&gt;                 &lt;pre&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;dlfcn.h&gt;&lt;br /&gt;#include "ctest.h"&lt;br /&gt;&lt;br /&gt;int main(int argc, char **argv)&lt;br /&gt;{&lt;br /&gt; void *lib_handle;&lt;br /&gt; double (*fn)(int *);&lt;br /&gt; int x;&lt;br /&gt; char *error;&lt;br /&gt;&lt;br /&gt; lib_handle = dlopen("/opt/lib/libctest.so", RTLD_LAZY);&lt;br /&gt; if (!lib_handle)&lt;br /&gt; {&lt;br /&gt;    fprintf(stderr, "%s\n", dlerror());&lt;br /&gt;    exit(1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; fn = dlsym(lib_handle, "ctest1");&lt;br /&gt; if ((error = dlerror()) != NULL)&lt;br /&gt; {&lt;br /&gt;    fprintf(stderr, "%s\n", error);&lt;br /&gt;    exit(1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; (*fn)(&amp;amp;x);&lt;br /&gt; printf("Valx=%d\n",x);&lt;br /&gt;&lt;br /&gt; dlclose(lib_handle);&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;               &lt;/dlfcn.h&gt;&lt;/stdio.h&gt;&lt;/pre&gt;                 &lt;/td&gt;               &lt;/tr&gt;             &lt;/tbody&gt;           &lt;/table&gt;          &lt;/dd&gt;&lt;/dl&gt;        &lt;p&gt;        &lt;tt&gt;gcc -rdynamic -o progdl progdl.c -ldl&lt;/tt&gt;       &lt;/p&gt;       &lt;p&gt;  Explanation:       &lt;/p&gt;       &lt;ul&gt;&lt;li&gt;&lt;tt&gt;dlopen("/opt/lib/libctest.so", RTLD_LAZY);&lt;/tt&gt;   &lt;br /&gt;Open shared library named "&lt;tt&gt;libctest.so&lt;/tt&gt;".   &lt;br /&gt;The second argument indicates the binding. See include file &lt;tt&gt;dlfcn.h&lt;/tt&gt;.   &lt;br /&gt;Returns NULL if it fails.   &lt;br /&gt;Options:                    &lt;ul&gt;&lt;li&gt;RTLD_LAZY: If specified, Linux is not concerned about unresolved symbols until they are referenced.         &lt;/li&gt;&lt;li&gt;RTLD_NOW: All unresolved symbols resolved when &lt;tt&gt;dlopen()&lt;/tt&gt; is called.         &lt;/li&gt;&lt;li&gt;RTLD_GLOBAL: Make symbol libraries visible.         &lt;/li&gt;&lt;/ul&gt;          &lt;/li&gt;&lt;li&gt;&lt;tt&gt;dlsym(lib_handle, "ctest1");&lt;/tt&gt;   &lt;br /&gt;Returns address to the function which has been loaded with the shared library..   &lt;br /&gt;Returns NULL if it fails.   &lt;br /&gt;Note: When using C++ functions, first use &lt;tt&gt;nm&lt;/tt&gt; to find the      "mangled" symbol name or use the &lt;tt&gt;extern "C"&lt;/tt&gt; construct to avoid      name mangling.    &lt;br /&gt;i.e. &lt;tt&gt;extern "C" void &lt;i&gt;function-name&lt;/i&gt;();&lt;/tt&gt;         &lt;/li&gt;&lt;/ul&gt; &lt;p&gt; &lt;b&gt;Object code location:&lt;/b&gt; Object code archive libraries can be located with either the executable or the loadable library. Object code routines used by both should not be duplicated in each. This is especially true for code which use static variables such as singleton classes. A static variable is global and thus can only be represented once. Including it twice will provide unexpected results. The programmer can specify that specific object code be linked with the executable by using linker commands which are passed on by the compiler. &lt;/p&gt; &lt;p&gt; Use the "-Wl" gcc/g++ compiler flag to pass command line arguments on to the GNU "ld" linker. &lt;/p&gt; &lt;p&gt;Example makefile statement: &lt;tt&gt;g++ -rdynamic -o appexe $(OBJ) $(LINKFLAGS) -Wl,--whole-archive -L{AA_libs} -laa -Wl,--no-whole-archive $(LIBS)&lt;/tt&gt; &lt;/p&gt; &lt;ul&gt;&lt;li&gt;--whole-archive: This linker directive specifies that the libraries listed following this directive (in this case &lt;tt&gt;AA_libs&lt;/tt&gt;) shall be included in the resulting output even though there may not be any calls requiring its pressence. This option is used to specify libraries which the loadable libraries will require at run time.&lt;/li&gt;&lt;li&gt;-no-whole-archive: This needs to be specified whether you list additional object files or not. The gcc/g++ compiler will add its own list of archive libraries and you would not want all the object code in the archive library linked in if not needed. It toggles the behavior back to normal for the rest of the archive libraries.&lt;/li&gt;&lt;/ul&gt;       &lt;p&gt;        &lt;b&gt;Man pages:&lt;/b&gt;       &lt;/p&gt;       &lt;ul&gt;&lt;li&gt;&lt;a href="http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=dlopen"&gt;dlopen()&lt;/a&gt; - gain access to an executable object file         &lt;/li&gt;&lt;li&gt;&lt;a href="http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=dlclose"&gt;dclose()&lt;/a&gt; - close a dlopen object         &lt;/li&gt;&lt;li&gt;&lt;a href="http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=dlsym"&gt;dlsym()&lt;/a&gt; - obtain the address of a symbol from a dlopen object         &lt;/li&gt;&lt;li&gt;&lt;a href="http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=dlvsym"&gt;dlvsym()&lt;/a&gt; - Programming interface to dynamic linking loader.         &lt;/li&gt;&lt;li&gt;&lt;a href="http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=dlerror"&gt;dlerror()&lt;/a&gt; - get diagnostic information         &lt;/li&gt;&lt;/ul&gt;        &lt;p&gt;        &lt;b&gt;Links:&lt;/b&gt;       &lt;/p&gt;       &lt;ul&gt;&lt;li&gt;&lt;a href="http://www.samspublishing.com/articles/article.asp?p=22435&amp;amp;rl=1"&gt;Shared Libraries-Dynamic Loading and Unloading&lt;/a&gt;         &lt;/li&gt;&lt;li&gt;&lt;a href="http://developer.gnome.org/doc/API/glib/glib-dynamic-loading-of-modules.html"&gt;GNOME Glib dynamic loading of modules&lt;/a&gt; - cross platform API for dynamically loading "plug-ins".         &lt;/li&gt;&lt;/ul&gt;        &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;table width="100%" border="0" cellpadding="2" cellspacing="0"&gt;         &lt;tbody&gt;           &lt;tr bgcolor="#ffcc33"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;C++ class objects and dynamic loading:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;         &lt;/tbody&gt;       &lt;/table&gt;       &lt;p&gt; &lt;b&gt;C++ and name mangling:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; When running the above "C" examples with the "C++" compiler one will quickly find that "C++" function names get mangled and thus will not work unless the function definitions are protected with &lt;tt&gt;extern "C"{}&lt;/tt&gt;.        &lt;/p&gt;&lt;dl&gt;&lt;dd&gt; Note that the following are not equivalent:       &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;       &lt;tbody&gt;       &lt;tr bgcolor="#c0c0c0"&gt;       &lt;td width="50%"&gt;       &lt;pre&gt;extern "C"&lt;br /&gt;{&lt;br /&gt; int functionx();&lt;br /&gt;}&lt;br /&gt;    &lt;/pre&gt;       &lt;/td&gt;       &lt;td valign="top"&gt;       &lt;pre&gt;extern "C" int functionx();&lt;br /&gt;    &lt;/pre&gt;       &lt;/td&gt;       &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;       &lt;p&gt;       &lt;/p&gt;       The following are equivalent:       &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;       &lt;tbody&gt;       &lt;tr bgcolor="#c0c0c0"&gt;       &lt;td width="50%"&gt;       &lt;pre&gt;extern "C"&lt;br /&gt;{&lt;br /&gt; extern int functionx();&lt;br /&gt;}&lt;br /&gt;    &lt;/pre&gt;       &lt;/td&gt;       &lt;td valign="top"&gt;       &lt;pre&gt;extern "C" int functionx();&lt;br /&gt;    &lt;/pre&gt;       &lt;/td&gt;       &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;       &lt;/dd&gt;&lt;/dl&gt;              &lt;p&gt; &lt;b&gt;Dynamic loading of C++ classes:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; The dynamic library loading routines enable the programmer to load "C" functions. In C++ we would like to load class member functions. In fact the entire class may be in the library and we may want to load and have access to the entire object and all of its member functions. Do this by passing a "C" class factory function which instantiates the class. &lt;/p&gt;       The class ".h" file:       &lt;dl&gt;&lt;dd&gt;       &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;       &lt;tbody&gt;       &lt;tr bgcolor="#c0c0c0"&gt;       &lt;td&gt;       &lt;pre&gt;class Abc {&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;// Class factory "C" functions&lt;br /&gt;&lt;br /&gt;typedef Abc* create_t;&lt;br /&gt;typedef void destroy_t(Abc*);&lt;br /&gt;    &lt;/pre&gt;       &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;       &lt;/dd&gt;&lt;/dl&gt;       &lt;p&gt;       &lt;/p&gt;       The class ".cpp" file:       &lt;dl&gt;&lt;dd&gt;       &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;       &lt;tbody&gt;       &lt;tr bgcolor="#c0c0c0"&gt;       &lt;td&gt;       &lt;pre&gt;Abc::Abc()&lt;br /&gt;{&lt;br /&gt;  ...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;extern "C"&lt;br /&gt;{&lt;br /&gt; // These two "C" functions manage the creation and destruction of the class Abc&lt;br /&gt;&lt;br /&gt; Abc* create()&lt;br /&gt; {&lt;br /&gt;    return new Abc;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void destroy(Abc* p)&lt;br /&gt; {&lt;br /&gt;    delete p;   // Can use a base class or derived class pointer here&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;    &lt;/pre&gt;       &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; This file is the source to the library. The "C" functions to instantiate (create) and destroy a class defined in the dynamically loaded library where "Abc" is the C++ class. &lt;/dd&gt;&lt;/dl&gt;       &lt;p&gt;       &lt;/p&gt;       Main executable which calls the loadable libraries:       &lt;dl&gt;&lt;dd&gt;       &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;       &lt;tbody&gt;       &lt;tr bgcolor="#c0c0c0"&gt;       &lt;td&gt;       &lt;pre&gt;// load the symbols&lt;br /&gt;  create_t* create_abc = (create_t*) dlsym(lib_handle, "create");&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;  destroy_t* destroy_abc = (destroy_t*) dlsym(lib_handle, "destroy");&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;...&lt;br /&gt;    &lt;/pre&gt;       &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;       &lt;/dd&gt;&lt;/dl&gt; &lt;p&gt; &lt;/p&gt; &lt;b&gt;Pitfalls:&lt;/b&gt;       &lt;ul&gt;&lt;li&gt;The new/delete of the C++ class should both be provided by the            executable or the library but not split. This is so that there is            no surprise if one overloads new/delete in one or the other.       &lt;/li&gt;&lt;/ul&gt; &lt;p&gt; &lt;/p&gt; &lt;b&gt;Links:&lt;/b&gt;       &lt;ul&gt;&lt;li&gt;&lt;a href="http://www.linuxjournal.com/article/3687"&gt;LinuxJournal.com: Dynamic Class Loading for C++ on Linux&lt;/a&gt;       &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.isotton.com/howtos/C++-dlopen-mini-HOWTO/C++-dlopen-mini-HOWTO.html"&gt;dlopen howto&lt;/a&gt;       &lt;/li&gt;&lt;/ul&gt;       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;table width="100%" border="0" cellpadding="2" cellspacing="0"&gt;          &lt;tbody&gt;           &lt;tr bgcolor="#ffcc33"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;Comparison to the Microsoft DLL:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;          &lt;/tbody&gt;       &lt;/table&gt;        &lt;p&gt; The Microsoft Windows equivalent to the Linux / Unix shared object (".so") is the ".dll". The Microsoft Windows DLL file usually has the extension ".dll", but may also use the extension ".ocx". On the old 16 bit windows, the dynamically linked libraries were also named with the ".exe" suffix. "Executing" the DLL will load it into memory. &lt;/p&gt;       &lt;p&gt; The Visual C++ .NET IDE wizard will create a DLL framework through the GUI,  and generates a ".def" file. This "module definition file" lists the  functions to be exported. When exporting C++ functions, the C++ mangled names are used. Using the Visual C++ compiler to generate a ".map" file will allow you to discover the C++ mangled name to use in the ".def" file. The "SECTIONS" label in the ".def" file will define the portions which are "shared". Unfortunately the generation of DLLs are tightly coupled to the Microsoft IDE, so much so that I would not recomend trying to create one without it.       &lt;/p&gt;       &lt;p&gt; The Microsoft Windows C++ equivalent functions to libdl are the following functions:       &lt;/p&gt;       &lt;ul&gt;&lt;li&gt;::LoadLibrary() - dlopen()         &lt;/li&gt;&lt;li&gt;::GetProcAddress() - dlsym()         &lt;/li&gt;&lt;li&gt;::FreeLibrary() - dlclose()         &lt;/li&gt;&lt;/ul&gt;       &lt;p&gt;       &lt;span style="color: rgb(255, 0, 0);"&gt;[Potential Pitfall]&lt;/span&gt;: Microsoft Visual C++ .NET compilers do not allow the linking controll that the GNU linker "ld" allows (i.e. --whole-archive, -no-whole-archive). All symbols need to be resolved by the VC++ compiler for both the loadable library and the application executable individually and thus it can cause duplication of libraries when the library is loaded. This is especially bad when using static variables (i.e. used in singleton patterns) as you will get two memory locations for the static variable, one used by the loadable library and the other used by the program executable. This breaks the whole static variable concept and the singleton pattern. Thus you can not use a static variable which is referenced by by both the loadable library and the application executable as they will be unique and different. To use a unique static variable, you must pass a pointer to that static variable to the other module so that each module (main executable and DLL library) can use the same instatiation. On MS/Windows you can use shared memory or a memory mapped file so that the main executable and DLL library can share a pointer to an address they both will use. &lt;/p&gt; Cross platform (Linux and MS/Windows) C++ code snippet:       &lt;p&gt;       &lt;/p&gt;       Include file declaration: (.h or .hpp)       &lt;dl&gt;&lt;dd&gt;       &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;       &lt;tbody&gt;       &lt;tr bgcolor="#c0c0c0"&gt;       &lt;td&gt;       &lt;pre&gt;class Abc{&lt;br /&gt;public:&lt;br /&gt; static Abc* Instance(); // Function declaration. Could also be used as a public class member function.&lt;br /&gt;&lt;br /&gt;private:&lt;br /&gt; static Abc *mInstance;      // Singleton. Use this declaration in C++ class member variable declaration.&lt;br /&gt; ...&lt;br /&gt;}&lt;br /&gt;    &lt;/pre&gt;       &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;       &lt;/dd&gt;&lt;/dl&gt;       &lt;p&gt;       &lt;/p&gt;       C/C++ Function source: (.cpp)       &lt;dl&gt;&lt;dd&gt;       &lt;table width="100%" bgcolor="#000000" border="0" cellpadding="4" cellspacing="1"&gt;       &lt;tbody&gt;       &lt;tr bgcolor="#c0c0c0"&gt;       &lt;td&gt;       &lt;pre&gt;/// Singleton instantiation&lt;br /&gt;Abc* Abc::mInstance = 0;   // Use this declaration for C++ class member variable&lt;br /&gt;                         // (Defined outside of class definition in ".cpp" file)&lt;br /&gt;&lt;br /&gt;// Return unique pointer to instance of Abc or create it if it does not exist.&lt;br /&gt;// (Unique to both exe and dll)&lt;br /&gt;&lt;br /&gt;static Abc* Abc::Instance() // Singleton&lt;br /&gt;{&lt;br /&gt;#ifdef WIN32&lt;br /&gt;  // If pointer to instance of Abc exists (true) then return instance pointer else look for&lt;br /&gt;  // instance pointer in memory mapped pointer. If the instance pointer does not exist in&lt;br /&gt;  // memory mapped pointer, return a newly created pointer to an instance of Abc.&lt;br /&gt;&lt;br /&gt;  return mInstance ?&lt;br /&gt;     mInstance : (mInstance = (Abc*) MemoryMappedPointers::getPointer("Abc")) ?&lt;br /&gt;     mInstance : (mInstance = (Abc*) MemoryMappedPointers::createEntry("Abc",(void*)new Abc));&lt;br /&gt;#else&lt;br /&gt;  // If pointer to instance of Abc exists (true) then return instance pointer&lt;br /&gt;  // else return a newly created pointer to an instance of Abc.&lt;br /&gt;&lt;br /&gt;  return mInstance ? mInstance : (mInstance = new Abc);&lt;br /&gt;#endif&lt;br /&gt;}&lt;br /&gt;    &lt;/pre&gt;       &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;       &lt;/dd&gt;&lt;/dl&gt; Windows linker will pull two instances of object, one in exe and one in loadable module.  Specify one for both to use by using memory mapped pointer so both exe and loadable library point to same variable or object.&lt;br /&gt;Note that the GNU linker does not have this problem.       &lt;p&gt;       &lt;/p&gt; For more on singletons see the YoLinux.com &lt;a href="http://www.yolinux.com/TUTORIALS/C++Singleton.html"&gt;C++ singleton software design pattern tutorial&lt;/a&gt;.       &lt;p&gt;       &lt;/p&gt;       &lt;hr /&gt;       &lt;table width="100%" border="0" cellpadding="2" cellspacing="0"&gt;         &lt;tbody&gt;           &lt;tr bgcolor="#ffcc33"&gt;             &lt;td&gt;&lt;b&gt;&lt;big&gt;Cross platform programming of loadable libraries:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;           &lt;/tr&gt;         &lt;/tbody&gt;       &lt;/table&gt;       &lt;p&gt;       &lt;/p&gt;                                          &lt;pre&gt;#ifndef USE_PRECOMPILED_HEADERS&lt;br /&gt;#ifdef WIN32&lt;br /&gt;#include &lt;direct.h&gt;&lt;br /&gt;#include &lt;windows.h&gt;&lt;br /&gt;#else&lt;br /&gt;#include &lt;sys h=""&gt;&lt;br /&gt;#include &lt;dlfcn.h&gt;&lt;br /&gt;#endif&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;  using namespace std;&lt;br /&gt;&lt;br /&gt;#ifdef WIN32&lt;br /&gt;  HINSTANCE lib_handle;&lt;br /&gt;#else&lt;br /&gt;  void *lib_handle;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;  // Where retType is the pointer to a return type of the function&lt;br /&gt;  // This return type can be int, float, double, etc or a struct or class.&lt;br /&gt;&lt;br /&gt;  typedef retType* func_t;&lt;br /&gt;&lt;br /&gt;  // load the library -------------------------------------------------&lt;br /&gt;#ifdef WIN32&lt;br /&gt;  string nameOfLibToLoad("C:\opt\lib\libctest.dll");&lt;br /&gt;  lib_handle = LoadLibrary(TEXT(nameOfLibToLoad.c_str()));&lt;br /&gt;  if (!lib_handle) {&lt;br /&gt;      cerr &lt;&lt; "Cannot load library: " &lt;&lt; lib_handle =" dlopen(nameOfLibToLoad.c_str()," fn_handle =" (func_t*)" fn_handle=" (func_t*)" dlsym_error =" dlerror();"&gt;&lt;/dlfcn.h&gt;&lt;/sys&gt;&lt;/windows.h&gt;&lt;/direct.h&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-3828563466714160509?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/3828563466714160509/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=3828563466714160509' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/3828563466714160509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/3828563466714160509'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2009/01/types-of-libraries-and-their-creation.html' title='types of libraries and their creation'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-5832555949576388261</id><published>2008-12-19T23:19:00.000-08:00</published><updated>2008-12-19T23:21:02.908-08:00</updated><title type='text'>finally a break</title><content type='html'>finally a break until i resume for my doctorate at Georgia Institute of Technology at Center for Experimental Research in Computing Systems under Prof. Karsten Schwan.........but u guys can let me know if something interesting comes up relating systems, ill be happy to put it here :) :) :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-5832555949576388261?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/5832555949576388261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=5832555949576388261' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/5832555949576388261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/5832555949576388261'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2008/12/finally-break.html' title='finally a break'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-6515637734102802390</id><published>2008-12-16T09:56:00.000-08:00</published><updated>2008-12-16T09:57:20.159-08:00</updated><title type='text'>PCI passthrough for Xen</title><content type='html'>&lt;h2 id="head-a7947297375d20d34c1413f386aa47a59784b56f"&gt;2.2. How do I hide a pci device from dom0?&lt;/h2&gt; &lt;span class="anchor" id="line-47"&gt;&lt;/span&gt;&lt;p class="line862"&gt;In Xen 2.x, you can add the &lt;tt&gt;physdev_dom0_hide&lt;/tt&gt; parameter (see &lt;a href="http://wiki.xensource.com/xenwiki/XenBooting"&gt;XenBooting&lt;/a&gt; for more parameters) to hide one or more pci devices to Dom0, so you can affect them to domU. &lt;span class="anchor" id="line-48"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-49"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="line874"&gt;Pci slots MUST be formatted like this: &lt;span class="anchor" id="line-50"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-51"&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li style="list-style-type: none;"&gt;&lt;p class="line891"&gt;&lt;strong&gt;(nn:nn.n)&lt;/strong&gt; &lt;span class="anchor" id="line-52"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class="line874"&gt;so &lt;span class="anchor" id="line-53"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-54"&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p class="line891"&gt;&lt;tt&gt;(03:06.1)&lt;/tt&gt; is correct &lt;span class="anchor" id="line-55"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p class="line891"&gt;&lt;tt&gt;(03:6.1)&lt;/tt&gt; is NOT correct &lt;span class="anchor" id="line-56"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class="line874"&gt;You can get the pci bus address on a Linux system by using the lspci command (only the last bits are relevant): &lt;span class="anchor" id="line-57"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-58"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="line867"&gt;&lt;span class="anchor" id="line-59"&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;lspci | grep Ethernet&lt;br /&gt;&lt;span class="anchor" id="line-60"&gt;&lt;/span&gt;0000:02:03.0 Ethernet controller: Intel Corp. 82546EB Gigabit Ethernet Controller (Copper) (rev 01)&lt;br /&gt;&lt;span class="anchor" id="line-61"&gt;&lt;/span&gt;0000:02:03.1 Ethernet controller: Intel Corp. 82546EB Gigabit Ethernet Controller (Copper) (rev 01)&lt;br /&gt;&lt;span class="anchor" id="line-62"&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span class="anchor" id="line-63"&gt;&lt;/span&gt;&lt;p class="line874"&gt;Then: &lt;span class="anchor" id="line-64"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-65"&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p class="line862"&gt;to hide the second network interface from dom0, you can then append &lt;tt&gt;physdev_dom0_hide=(02:03.1)&lt;/tt&gt; to your &lt;tt&gt;kernel /boot/xen-2.0.gz&lt;/tt&gt;. &lt;span class="anchor" id="line-66"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p class="line862"&gt;to hide multiple pci devices, simply concatenate all the pci slots address like this: &lt;tt&gt;physdev_dom0_hide=(02:03.0)(02:03.1)&lt;/tt&gt; &lt;span class="anchor" id="line-67"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class="line874"&gt;If everything went ok, you should see the following lines after a reboot: &lt;span class="anchor" id="line-68"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-69"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="line867"&gt;&lt;span class="anchor" id="line-70"&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;(XEN) Hiding PCI device 02:03.0 from DOM0&lt;br /&gt;&lt;span class="anchor" id="line-71"&gt;&lt;/span&gt;(XEN) Hiding PCI device 02:03.1 from DOM0&lt;br /&gt;&lt;br /&gt;Also refer to the link:&lt;br /&gt;http://wiki.xensource.com/xenwiki/XenFaq#head-d5a7a247a5168517291228a6f02fd74b419badeb&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-6515637734102802390?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/6515637734102802390/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=6515637734102802390' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/6515637734102802390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/6515637734102802390'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2008/12/pci-passthrough-for-xen.html' title='PCI passthrough for Xen'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-2453855006443166784</id><published>2008-12-09T18:22:00.000-08:00</published><updated>2008-12-09T18:23:04.066-08:00</updated><title type='text'>Windows Installation using USB key device</title><content type='html'>&lt;h2&gt;&lt;a href="http://www.vandomburg.net/installing-windows-xp-from-usb/" rel="bookmark" title="Installing Windows XP from USB"&gt;Installing Windows XP from USB&lt;/a&gt;&lt;/h2&gt;            &lt;blockquote&gt; &lt;p&gt;I wrote this piece back in March 2006 before transferring it to my new blog. It’s quite possible that bits and pieces of this HOWTO are outdated. If any are and you find a solution, then please leave a comment for everyone to peruse.&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;What follows is a recipe on how to install Windows XP from USB. You can &lt;a href="http://www.vandomburg.net/installing-windows-xp-from-usb/#disclaimer"&gt;cut right to the case&lt;/a&gt; or read about how it happened to me, first. Sit tight, you’re in for a ride!&lt;/p&gt; &lt;h2&gt;Case In Point&lt;/h2&gt; &lt;p&gt;You’ve got this &lt;a href="http://www.acer.com/"&gt;Acer&lt;/a&gt; laptop with a malfunctioning DVD drive. Specifically, you removed it from its bay and now Windows XP crashes when you plug it back in. Knowledge Base article &lt;a href="http://support.microsoft.com/?kbid=310664"&gt;310664&lt;/a&gt; matches it to a tee.&lt;/p&gt; &lt;p&gt;Provided solution: update to Service Pack 1, or disable &lt;a href="http://en.wikipedia.org/wiki/Direct_memory_access"&gt;DMA&lt;/a&gt; in the &lt;a href="http://en.wikipedia.org/wiki/BIOS"&gt;BIOS&lt;/a&gt;. Current situation: running &lt;a href="http://en.wikipedia.org/wiki/SP2"&gt;SP2&lt;/a&gt; and blessed with a “user-friendly” BIOS that doesn’t allow you to disable DMA.&lt;/p&gt; &lt;p&gt;Your luck just ran out, but - being the geek that you are - you don’t whine about it. Instead, you come up with this bright idea: let’s install Linux, that’ll work some magic! And so you get &lt;a href="http://www.gentoo.org/"&gt;Gentoo Linux&lt;/a&gt; installed using a home-brewn &lt;a href="http://www.gentoo.org/doc/en/liveusb.xml"&gt;LiveUSB&lt;/a&gt; distribution. And much to your dismay, proper hotplugging implementation for your laptop is lacking. Curses.&lt;/p&gt; &lt;p&gt;So finally, you call the support line to have them collect your laptop for repair. One problem here: you’re betting they won’t like seeing Linux boot up and, hoping to forego additional service costs, it’s up to you to reinstall Windows XP.&lt;/p&gt; &lt;p&gt;One problem here: you don’t have a working CD-ROM drive to install Windows XP off, and from experience you know that Windows XP &lt;a href="http://blogs.msdn.com/oldnewthing/archive/2004/04/15/113811.aspx"&gt;won’t install from an external drive&lt;/a&gt;. Blasted!&lt;/p&gt; &lt;p&gt;Enter the cavalry.&lt;br /&gt;&lt;a title="disclaimer" name="disclaimer"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;Disclaimer&lt;/h2&gt; &lt;p&gt;The procedure here is provided without any warranty or support whatsoever. It worked for me and so it might for you. It also might blast you and your laptop to pieces. &lt;strong&gt;Some of the procedures described here can wipe all of your data.&lt;/strong&gt; Thought I’d warn you.&lt;/p&gt; &lt;p&gt;I don’t mean to be inventive here, either. In fact, all the technology has been laid out for us and is readily available. All I’m doing is wrapping it all up in writing. Shouts out to everyone who provided the technology!&lt;/p&gt; &lt;p&gt;That being said, let’s get down to business.&lt;/p&gt; &lt;h2&gt;Ground Zero: Ingredients&lt;/h2&gt; &lt;p&gt;You’ll be needing ample space on a USB storage device like a thumbdrive or external disk drive. 1 GB of storage will suffice. Possibly, you could access the setup files from a network share in which case you’ll only need a 256 MB thumbdrive, but I haven’t tried that.&lt;/p&gt; &lt;p&gt;Personally, I booted off a 512 MB thumbdrive and put the Windows XP setup files on an external disk drive. So a combination will do just fine, but just make sure that you’ve got sufficient USB ports: &lt;strong&gt;all USB devices will need to be plugged in and stay plugged in while we’re booted into BartPE later on!&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;You’ll also need a bunch of software, including a valid copy of Windows XP. The other software components can be downloaded freely:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a href="http://www.nu2.nu/pebuilder/"&gt;Bart’s Preinstalled Environment&lt;/a&gt; (BartPE)&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=22cfc239-337c-4d81-8354-72593b1c1f43&amp;amp;DisplayLang=en"&gt;Windows 2003 Server Service Pack 1&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt;&lt;p&gt;Q: Why Windows 2003 Server Service Pack 1? I want to install XP!&lt;/p&gt; &lt;p&gt;A: Well that’s exactly the trick, though it’s a bit technical. During booting, Windows resets the USB port and loses your boot device. That’s why an installation from USB normally fails. But by using Windows 2003 Server’s ramdisk feature in the early phases of booting, we circumvent that problem.&lt;/p&gt; &lt;p&gt;Don’t be mislead though: you’ll be installing Windows XP all the same. It’s just that we’ll be using two Windows 2003 Server files from the Service Pack to do it.&lt;/p&gt; &lt;p&gt;You can also perform a Windows 2003 Server installation using this exact same procedure, save that you’ll be needing to update to Windows 2003 Server Service Pack 1 instead of Windows XP SP2, below. That’s assuming, of course, that you’ve got a valid copy of Windows 2003 Server.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;You will also need an already functional Windows system to prep the USB disk from. In addition, your target system (the one that needs reinstalling) should support booting from USB. Virtually all modern ones do though.&lt;/p&gt; &lt;p&gt;Finally, not all cheaper USB devices properly support being booted from. The &lt;a href="http://www.911cd.net/forums/index.php?showtopic=10806"&gt;BartPE forums&lt;/a&gt; have a partial list of ones that don’t.&lt;/p&gt; &lt;h2&gt;Step One: Preparing the Windows XP Setup Files&lt;/h2&gt; &lt;p&gt;For this procedure to work correctly, you’ll need Windows XP to be at Service Pack 1 or Service Pack 2. Many newer Windows XP CDs already have either one included.&lt;/p&gt; &lt;p&gt;You can check by inserting the CD-ROM and looking at the files in the top folder. There should be a file named &lt;code&gt;WIN51P.SP1&lt;/code&gt; or &lt;code&gt;WIN51P.SP2&lt;/code&gt;. If you see either one, fast forward to step two.If there is no such file, or you’ve got a SP1 CD that you would like to update to SP2, proceed as follows:&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Copy the Windows XP CD-ROM to a location on your hard drive. We’ll be assuming &lt;code&gt;C:\winxpcd&lt;/code&gt;. &lt;em&gt;I strongly advise you to use such a vanilla CD. Users have reported strange happenings with custom XP distributions.&lt;/em&gt;&lt;/li&gt;&lt;li&gt;Download the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=049C9DBE-3B8E-4F30-8245-9E368D3CDB5A&amp;amp;displaylang=en"&gt;Windows XP Service Pack 2 Network Installation Package&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Unpack Windows XP SP2 by running &lt;code&gt;WindowsXP-KB835935-SP2-ENU.exe -x&lt;/code&gt;. Note the &lt;code&gt;-x&lt;/code&gt; parameter that will allow you to specify a location to unpack to. We’ll be assuming &lt;code&gt;C:\winxpsp2&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Integrate SP2 into the setup files by running &lt;code&gt;C:\winxpsp2\i386\update\update.exe /integrate:c:\winxpcd&lt;/code&gt;.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;If your system needs special drivers to operate, this would be the time to include them (called “slipstreaming”). Doing so isn’t exactly trivial and should only be necessary if you, say, require non-standard &lt;a href="http://en.wikipedia.org/wiki/SATA"&gt;SATA&lt;/a&gt; support. The process is beyond the scope of this article, but fortunately &lt;a href="http://www.google.nl/search?q=slipstreaming+drivers"&gt;Google&lt;/a&gt; is your friend.&lt;/p&gt; &lt;h2&gt;Step Two: Prepping BartPE&lt;/h2&gt; &lt;p&gt;First we’ll prep the USB drive we’ll be using for booting. This is by far the largest step in the process, though it shouldn’t be difficult for anyone to follow. It requires a functional Windows system.&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Install BartPE. We’ll be assuming that you install to &lt;code&gt;C:\pebuilder&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Unpack PE2USB to &lt;code&gt;C:\pebuilder&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Unpack Windows 2003 SP1 by running &lt;code&gt;WindowsServer2003-KB889101-SP1-x86-ENU.exe -x&lt;/code&gt; (that’s assuming that you downloaded the English version). Note the &lt;code&gt;-x&lt;/code&gt; parameter that will allow you to specify a location to unpack to. We’ll be assuming &lt;code&gt;C:\server2003sp1&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Create a folder named &lt;code&gt;C:\pebuilder\srsp1&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Copy &lt;code&gt;C:\server2003sp1\i386\setupldr.bin&lt;/code&gt; to &lt;code&gt;C:\pebuilder\srsp1&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Expand and copy &lt;code&gt;ramdisk.sys&lt;/code&gt; by running &lt;code&gt;expand -r C:\server2003sp1\i386\ramdisk.sy_ C:\pebuilder\srsp1&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Start PE Builder from the Start Menu. Point “Source:” to the location of your Windows XP setup files containing SP1 or SP2.&lt;/li&gt;&lt;li&gt;Make sure the “Output:” is set to “BartPE”. &lt;em&gt;If using SP2:&lt;/em&gt; go into the Plugins configuration dialog and enable “RpcSS needs to launch DComLaunch Service First - SP2 only”.&lt;/li&gt;&lt;li&gt;Hit “Build”.&lt;/li&gt;&lt;li&gt;When it’s done building, insert the USB drive you intend to boot from and run &lt;code&gt;C:\pebuilder\pe2usb -f [drive:]&lt;/code&gt;, replacing [drive:] with the location of your USB drive. &lt;strong&gt;This will destroy any data on your USB drive!&lt;/strong&gt; The drive shouldn’t be partitioned any larger than 1 GB. If it is, then repartition it using Computer Management in the Control Panel.&lt;/li&gt;&lt;li&gt;Copy the Windows XP setup files to the USB drive (or another USB device if you have insufficient space left). You’ll only need the &lt;code&gt;i386&lt;/code&gt; folder.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;If no errors occured in the process, you should now be all set to boot from USB!&lt;/p&gt; &lt;p&gt;&lt;em&gt;Note: it’s possible to use Windows 2003 Server as the operating system to boot from, but I don’t recommend it. Many of BartPE’s included utilities won’t work properly.&lt;/em&gt;&lt;/p&gt; &lt;h2&gt;Step Three: Configuring the BIOS&lt;/h2&gt; &lt;p&gt;You should now reboot and go into the BIOS configuration to boot from USB. Instructions for doing so wildly from system to system, but generally entail the following:&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Reboot the system.&lt;/li&gt;&lt;li&gt;While booting (before Windows starts loading), get into the BIOS configuration screen by hitting something like F1, F2, Delete or Escape. Hotkey instructions are generally provided on the screen.&lt;/li&gt;&lt;li&gt;Go to the section that contains your boot devices.&lt;/li&gt;&lt;li&gt;With your USB drive plugged in, the USB drive should be listed. If it isn’t, your system might not support booting from USB. Assuming that it is supported (as is the case with virtually all modern hardware), promote your USB drive to the primary boot device.&lt;/li&gt;&lt;li&gt;Exit from the BIOS configuration, saving all changes.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;If you’re completely new to BIOS configuration, &lt;a href="http://www.tomshardware.com/2005/09/22/bios_for_beginners/"&gt;BIOS for Beginners&lt;/a&gt; over at Tom’s Hardware might be a good primer. Be aware though, that you can seriously screw up your system by providing incorrect settings!&lt;/p&gt; &lt;h2&gt;Step Four: Booting into BartPE&lt;/h2&gt; &lt;p&gt;Assuming that you properly configured your BIOS and your USB device supports booting, BartPE should now load. Depending on the speed of your USB device, this may take a while.&lt;/p&gt; &lt;p&gt;If it isn’t working, then double-check the following before making a scene:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Is your BIOS properly configured for booting from the USB disk? (Is the USB device listed and does it have top priority?)&lt;/li&gt;&lt;li&gt;Have you correctly prepared the USB disk in step two? (Restart the procedure.)&lt;/li&gt;&lt;li&gt;Does your USB stick properly support being booted from? (Try another one!)&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;Step Five: Prepping the Hard Disk&lt;/h2&gt; &lt;p&gt;You need to make sure that your hard drive is partitioned and formatted properly. Especially if you’ve had Linux or some other operating system on it, you’ll need to repartition and format it. BartPE contains &lt;a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/diskpart.mspx?mfr=true"&gt;DiskPart&lt;/a&gt; for disk partitioning and &lt;a href="http://www.shawneelink.net/%7Ebgmiller/"&gt;A43 File Manager&lt;/a&gt; to format your drive.&lt;/p&gt; &lt;p&gt;If you are sure that your hard drive is set up properly (i.e. it has only run Windows, it contains a valid FAT or NTFS partition) then you can safe yourself the hassle and skip this step.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;This procedure will destroy any data on the hard drive.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;To repartition:&lt;/p&gt; &lt;ol&gt;&lt;li&gt;From the Go menu, navigate to DiskPart.&lt;/li&gt;&lt;li&gt;Enter the commands needed to repartition your drive. For example, try the following: &lt;code&gt;select disk 0&lt;/code&gt; (select the first disk), &lt;code&gt;clean&lt;/code&gt; (purges the entire drive, essentially resetting it), &lt;code&gt;create partition primary&lt;/code&gt; (creates a single partition from the entire disk), &lt;code&gt;assign&lt;/code&gt; (assign the partition a drive letter), &lt;code&gt;exit&lt;/code&gt; (quits DiskPart).&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;strong&gt;This procedure will destroy any data on the hard drive.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;To format:&lt;/p&gt; &lt;ol&gt;&lt;li&gt;From the Go menu, navigate to the A43 File Manager.&lt;/li&gt;&lt;li&gt;Right-click on the target drive (e.g. &lt;code&gt;C:&lt;/code&gt;) and click Format. Should be self-explanatory.&lt;/li&gt;&lt;/ol&gt; &lt;h2&gt;Step Six: Launching Windows XP Setup&lt;/h2&gt; &lt;p&gt;With your drive all ready, you can now launch the Windows XP setup with a few custom parameters. Let’s assume that the files are available at &lt;code&gt;D:\i386&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;&lt;em&gt;Plugging in a device now won’t work. Remember that all USB devices will need to be plugged in right from the start while using BartPE.&lt;/em&gt;&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Run &lt;code&gt;D:\i386\winnt32.exe /syspart:C: /tempdrive:C: /makelocalsource&lt;/code&gt;. Replace &lt;code&gt;C:&lt;/code&gt; with the drive you want to install Windows to.&lt;/li&gt;&lt;li&gt;Proceed with the installation. When asked to convert the installation volume to NTFS, answer No. The setup program incorrectly believes that your USB drive (which is formatted as FAT) needs conversion.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;The setup program will then silently close, which might make you think that something went wrong. Don’t worry though. Reboot your system, remove the USB drive(s) and – if all went well – you can now finish setting up Windows XP. Congratulations!&lt;/p&gt; &lt;p&gt;All comments are highly welcome. Hope to have helped some of you out!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-2453855006443166784?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/2453855006443166784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=2453855006443166784' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/2453855006443166784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/2453855006443166784'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2008/12/windows-installation-using-usb-key.html' title='Windows Installation using USB key device'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-2599023350219740347</id><published>2008-12-05T13:06:00.000-08:00</published><updated>2008-12-05T13:07:02.990-08:00</updated><title type='text'>Xen PCI passthrough</title><content type='html'>&lt;span class="actionbar"&gt; &lt;a href="http://www.wlug.org.nz/XenPciPassthrough?action=edit" class="wikiaction" rel="nofollow"&gt;Edit&lt;/a&gt;&lt;a href="http://www.wlug.org.nz/XenPciPassthrough?action=PageHistory" class="wikiaction" rel="nofollow"&gt;PageHistory&lt;/a&gt;&lt;a href="http://www.wlug.org.nz/XenPciPassthrough?action=diff" class="wikiaction" rel="nofollow"&gt;Diff&lt;/a&gt;&lt;a href="http://www.wlug.org.nz/XenPciPassthrough?action=PageInfo" class="wikiaction" rel="nofollow"&gt;Info&lt;/a&gt;&lt;a href="http://www.wlug.org.nz/XenPciPassthrough?action=LikePages" class="rightmost" rel="nofollow"&gt;LikePages&lt;/a&gt;&lt;/span&gt;                           &lt;p class="tightenable top"&gt;Xen has a feature which lets you pass a &lt;a href="http://www.wlug.org.nz/PCI" class="wiki"&gt;PCI&lt;/a&gt; device through to an unpriviledged domain. Only the unpriviledged domain has access to this specific &lt;a href="http://www.wlug.org.nz/PCI" class="wiki"&gt;PCI&lt;/a&gt; device – the priviledged domain binds to the &lt;a href="http://www.wlug.org.nz/PCI" class="wiki"&gt;PCI&lt;/a&gt; device with a dummy drive that stops the dom0 from accessing it as well.&lt;/p&gt; &lt;p class="tightenable"&gt;This could be used for passing a &lt;a href="http://www.wlug.org.nz/SCSI" class="wiki"&gt;SCSI&lt;/a&gt; controller or &lt;a href="http://www.wlug.org.nz/NIC" class="wiki"&gt;NIC&lt;/a&gt; through to one domain, eg. for a file server or &lt;a href="http://www.wlug.org.nz/FireWall" class="wiki"&gt;FireWall&lt;/a&gt; domU.&lt;/p&gt; &lt;h3&gt;What you'll need&lt;/h3&gt; &lt;p class="tightenable"&gt;You'll have to compile in the right &lt;a href="http://www.wlug.org.nz/PCI" class="wiki"&gt;PCI&lt;/a&gt; backend driver for &lt;a href="http://www.wlug.org.nz/Xen" class="wiki"&gt;Xen&lt;/a&gt;.&lt;/p&gt; &lt;pre class="tightenable"&gt;    CONFIG_XEN_PCIDEV_FRONTEND=y (for DomU kernels)&lt;br /&gt;   CONFIG_XEN_PCIDEV_BACKEND=y (for Dom0 kernels)&lt;/pre&gt; &lt;p class="tightenable"&gt;You'll also need the &lt;a href="http://www.wlug.org.nz/PCI" class="wiki"&gt;PCI&lt;/a&gt; ID of the device in question, in the &lt;tt&gt;xx:xx:x&lt;/tt&gt; notation displayed by &lt;a href="http://www.wlug.org.nz/lspci%288%29" class="wiki"&gt;lspci(8)&lt;/a&gt;. Note that the formatting is important – don't drop or add leading 0's!&lt;/p&gt; &lt;p class="tightenable"&gt;In some cases it is required to set the &lt;tt&gt;pciback.permissive&lt;/tt&gt; option – this is for drivers which need to write to registers on the &lt;a href="http://www.wlug.org.nz/PCI" class="wiki"&gt;PCI&lt;/a&gt; device itself. Apparently some &lt;a href="http://www.wlug.org.nz/NIC" class="wiki"&gt;NIC&lt;/a&gt;s will fail to operate without this, and from what I've read it doesn't hurt to have it enabled regardless.&lt;/p&gt; &lt;h3&gt;Kernel options&lt;/h3&gt; &lt;p class="tightenable"&gt;In &lt;tt&gt;grub.conf&lt;/tt&gt;, add something like the following to your &lt;tt&gt;module&lt;/tt&gt; line corresponding to the dom0 kernel.&lt;/p&gt; &lt;pre class="tightenable"&gt;pciback.permissive pciback.hide=(03:00.0)&lt;/pre&gt; &lt;p class="tightenable"&gt;This assumes the device we are passing through has a &lt;a href="http://www.wlug.org.nz/PCI" class="wiki"&gt;PCI&lt;/a&gt; ID of &lt;tt&gt;03:00.0&lt;/tt&gt;.&lt;/p&gt; &lt;h3&gt;&lt;a href="http://www.wlug.org.nz/Xen" class="wiki"&gt;Xen&lt;/a&gt; config file&lt;/h3&gt; &lt;p class="tightenable"&gt;In your &lt;a href="http://www.wlug.org.nz/Xen" class="wiki"&gt;Xen&lt;/a&gt; config file for the domain, add a line that looks like the following, again assuming a &lt;a href="http://www.wlug.org.nz/PCI" class="wiki"&gt;PCI&lt;/a&gt; ID of &lt;tt&gt;03:00.0&lt;/tt&gt;:&lt;/p&gt; &lt;pre class="tightenable"&gt;pci = ['03:00.0']&lt;/pre&gt; &lt;p class="tightenable"&gt;Note that if this is a network interface, it will come up in addition to any you specify with your &lt;tt&gt;vif&lt;/tt&gt; config option.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-2599023350219740347?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/2599023350219740347/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=2599023350219740347' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/2599023350219740347'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/2599023350219740347'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2008/12/xen-pci-passthrough.html' title='Xen PCI passthrough'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-2347691980440735363</id><published>2008-12-05T12:57:00.000-08:00</published><updated>2008-12-05T12:58:05.542-08:00</updated><title type='text'>Xen DomU creation</title><content type='html'>&lt;h2&gt; Creating a Virtual Server - domU &lt;/h2&gt; &lt;p&gt;There are 3 options of what to run DomU on: &lt;/p&gt; &lt;ol&gt;&lt;li&gt; File Based Image &lt;/li&gt;&lt;li&gt; LVM Based &lt;/li&gt;&lt;li&gt; Physical Partition &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;1. A file based image is the quickest to setup, however has poor/terrible IO performance. The &lt;a id="KonaLink0" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://wiki.kartbuilding.net/index.php/Create_DomU#"&gt;&lt;span style="color: orange ! important; font-family: sans-serif; font-weight: 400; font-size: 12.7px; position: static;color:orange;" &gt;&lt;span class="kLink" style="color: orange ! important; font-family: sans-serif; font-weight: 400; font-size: 12.7px; position: static;"&gt;virtual &lt;/span&gt;&lt;span class="kLink" style="color: orange ! important; font-family: sans-serif; font-weight: 400; font-size: 12.7px; position: static;"&gt;server&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; is limited to the initial size of the image created also. The file based Image can however be easily mounted in a rescue &lt;a id="KonaLink1" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://wiki.kartbuilding.net/index.php/Create_DomU#"&gt;&lt;span style="color: orange ! important; font-family: sans-serif; font-weight: 400; font-size: 12.7px; position: static;color:orange;" &gt;&lt;span class="kLink" style="color: orange ! important; font-family: sans-serif; font-weight: 400; font-size: 12.7px; position: static;"&gt;system&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;, and easily backed-up. &lt;/p&gt;&lt;p&gt;2. LVM for domU is the industry standard. After the initial setup of LVM, as described &lt;a href="http://wiki.kartbuilding.net/index.php/LVM_on_XEN_%28dom0%29" title="LVM on XEN (dom0)"&gt;here&lt;/a&gt;, it is a dream to manage. &lt;b&gt;LVM partitions can be resized afterwards!!!&lt;/b&gt; Due to this "resizing" capability and flexibility, its use for Xen Virtual &lt;a id="KonaLink2" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://wiki.kartbuilding.net/index.php/Create_DomU#"&gt;&lt;span style="color: orange ! important; font-family: sans-serif; font-weight: 400; font-size: 12.7px; position: static;color:orange;" &gt;&lt;span class="kLink" style="color: orange ! important; font-family: sans-serif; font-weight: 400; font-size: 12.7px; position: static;"&gt;Servers&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; is ideal. They also have much better IO performance than file-based. I dont know about mounting these partitions however in a rescue system. Something to try out... -). &lt;/p&gt;&lt;p&gt;3. Physical Partitions have the best IO, but are difficult to alter and inflexible. &lt;/p&gt; &lt;div class="editsection" style="float: right; margin-left: 5px;"&gt;[&lt;a href="http://wiki.kartbuilding.net/index.php?title=Create_DomU&amp;amp;action=edit&amp;amp;section=2" title="Create DomU"&gt;edit&lt;/a&gt;]&lt;/div&gt;&lt;a name="File_Based_Setup_of_Virtual_Disk"&gt;&lt;/a&gt;&lt;h3&gt; File Based Setup of Virtual Disk &lt;/h3&gt; &lt;pre&gt;mkdir -p /xens/burkesys/&lt;br /&gt;dd if=/dev/zero of=/xens/burkesys/diskimage.img bs=1024k count=5000&lt;br /&gt;dd if=/dev/zero of=/xens/burkesys/swapimage.img bs=1024k count=512&lt;br /&gt;&lt;br /&gt;mkfs.ext3 /xens/burkesys/diskimage.img&lt;br /&gt;mkswap /xens/burkesys/swapimage.img&lt;br /&gt;&lt;br /&gt;mount -o loop /xens/burkesys/diskimage.img /mnt&lt;br /&gt;&lt;/pre&gt; &lt;div class="editsection" style="float: right; margin-left: 5px;"&gt;[&lt;a href="http://wiki.kartbuilding.net/index.php?title=Create_DomU&amp;amp;action=edit&amp;amp;section=3" title="Create DomU"&gt;edit&lt;/a&gt;]&lt;/div&gt;&lt;a name="LVM_Based_Setup_of_Virtual_Disk"&gt;&lt;/a&gt;&lt;h3&gt; LVM Based Setup of Virtual Disk &lt;/h3&gt;  &lt;pre&gt;lvcreate -n twister --size 2g main-vol2&lt;br /&gt;lvcreate -n twisterswp --size 512m main-vol2&lt;br /&gt;&lt;br /&gt;mkfs.ext3 /dev/main-vol2/twister&lt;br /&gt;mkswap /dev/main-vol2/twisterswp&lt;br /&gt;&lt;br /&gt;mount -o loop /dev/main-vol2/twister /mnt&lt;br /&gt;&lt;/pre&gt; &lt;div class="editsection" style="float: right; margin-left: 5px;"&gt;[&lt;a href="http://wiki.kartbuilding.net/index.php?title=Create_DomU&amp;amp;action=edit&amp;amp;section=4" title="Create DomU"&gt;edit&lt;/a&gt;]&lt;/div&gt;&lt;a name="Debootstrap_New_OS_onto_Virtual_Disk"&gt;&lt;/a&gt;&lt;h3&gt; Debootstrap New OS onto Virtual Disk &lt;/h3&gt; &lt;pre&gt;debootstrap --arch i386 sarge /mnt &lt;a href="http://ftp.de.debian.org/debian/" class="external free" title="http://ftp.de.debian.org/debian/" rel="nofollow"&gt;http://ftp.de.debian.org/debian/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;mv /mnt/lib/tls /mnt/lib/tls.disabled&lt;br /&gt;&lt;br /&gt;cp /etc/apt/sources.list /mnt/etc/apt/&lt;br /&gt;vi /mnt/etc/apt/sources.list&lt;br /&gt;&lt;br /&gt;cp -a /lib/modules/2.6.16-1-xen-k7/ /mnt/lib/modules/&lt;br /&gt;&lt;br /&gt;cp /etc/resolve.conf /mnt/etc/&lt;br /&gt;&lt;br /&gt;cp /etc/network/interfaces /mnt/etc/network/&lt;br /&gt;vi /mnt/etc/network/interfaces&lt;br /&gt;&lt;br /&gt;#To use Specific IP address - edit the /mnt/etc/network/interfaces manually.&lt;br /&gt;#To use DHCP, edit and include the following:&lt;br /&gt;   # The loopback network interface&lt;br /&gt;  auto lo&lt;br /&gt;  iface lo inet loopback&lt;br /&gt;  # The primary network interface&lt;br /&gt;  auto eth0&lt;br /&gt;  iface eth0 inet dhcp&lt;br /&gt;&lt;br /&gt;vi /mnt/etc/hostname&lt;br /&gt;&lt;br /&gt;vi /mnt/etc/fstab&lt;br /&gt;proc            /proc       proc    defaults    0 0&lt;br /&gt;/dev/sda1       /           ext3    defaults,errors=remount-ro    0 1&lt;br /&gt;/dev/sda2       none        swap    sw          0 0&lt;br /&gt;&lt;/pre&gt; &lt;div class="editsection" style="float: right; margin-left: 5px;"&gt;[&lt;a href="http://wiki.kartbuilding.net/index.php?title=Create_DomU&amp;amp;action=edit&amp;amp;section=5" title="Create DomU"&gt;edit&lt;/a&gt;]&lt;/div&gt;&lt;a name="Setup_domU_Xen_Config"&gt;&lt;/a&gt;&lt;h3&gt; Setup domU Xen Config &lt;/h3&gt; &lt;pre&gt;umount /mnt&lt;br /&gt;&lt;br /&gt;vi /etc/xen/burkesys&lt;br /&gt;kernel = "/boot/vmlinuz-2.6.16-1-xen-k7"&lt;br /&gt;ramdisk = "/boot/initrd.img-2.6.16-1-xen-k7"&lt;br /&gt;memory = 192&lt;br /&gt;name = "burkesys"&lt;br /&gt;vif = ['bridge=xenbr0']&lt;br /&gt;#File Based:# disk = ['file:/xens/burkesys/diskimage.img,sda1,w','file:/xens/burkesys/swapimage.img,sda2,w']&lt;br /&gt;#LVM Based:# disk = ['phy:/dev/main-vol2/twister,sda1,w', 'phy:/dev/main-vol2/twister,sda2,w']&lt;br /&gt;#DHCP - remove the ip, gateway and netmask lines, and include:# dhcp = "dhcp"&lt;br /&gt;ip = "ip add"&lt;br /&gt;gateway = "ip add"&lt;br /&gt;netmask = "255.255.0.0"&lt;br /&gt;root = "/dev/sda1 ro"&lt;br /&gt;extra = '4'&lt;br /&gt;&lt;br /&gt;ln -s /etc/xen/burkesys /etc/xen/auto/burkesys&lt;br /&gt;//link in the config file so that the Virtal Machine starts on Bootup of Dom0&lt;br /&gt;&lt;/pre&gt; &lt;div class="editsection" style="float: right; margin-left: 5px;"&gt;[&lt;a href="http://wiki.kartbuilding.net/index.php?title=Create_DomU&amp;amp;action=edit&amp;amp;section=6" title="Create DomU"&gt;edit&lt;/a&gt;]&lt;/div&gt;&lt;a name="Run_and_Update_DomU"&gt;&lt;/a&gt;&lt;h3&gt; Run and Update DomU &lt;/h3&gt; &lt;pre&gt;xm create burkesys -c&lt;br /&gt;// CTRL + ]  Gets out of the Console&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;All going well you should see domU booting up. Login as "root" with no password. Execute the following commands to update: &lt;/p&gt; &lt;pre&gt;passwd&lt;br /&gt;pwconv         #Very important. See explaination below.&lt;br /&gt;&lt;br /&gt;apt-get update&lt;br /&gt;apt-get upgrade&lt;br /&gt;&lt;br /&gt;apt-get install module-init-tools   //for iptables&lt;br /&gt;apt-get install iptables&lt;br /&gt;&lt;br /&gt;iptables -L&lt;br /&gt;&lt;/pre&gt; &lt;div class="editsection" style="float: right; margin-left: 5px;"&gt;[&lt;a href="http://wiki.kartbuilding.net/index.php?title=Create_DomU&amp;amp;action=edit&amp;amp;section=7" title="Create DomU"&gt;edit&lt;/a&gt;]&lt;/div&gt;&lt;a name="Fix_for_passwd_and_shadow_with_Debootstrap_install"&gt;&lt;/a&gt;&lt;h3&gt; Fix for passwd and shadow with Debootstrap install &lt;/h3&gt; &lt;p&gt;By default, when a system is installed using debootstrap, it does *not* create /etc/shadow, and simply creates /etc/passwd with the root password hashed. Looking at /etc/passwd after a debootstrap'ed system is running, you will see the root user and the root's password hashed. If there were other users installed on the same system, they could read the root's password hash, because /etc/passwd is world readable. &lt;/p&gt;&lt;p&gt;A more secure method is to store only the usernames in /etc/passwd and to store the password hash in /etc/shadow which has special permissions. Therefore any user won't be able to access the password hashes for other users. To convert passwd to shadow, its really very simple, just run: &lt;/p&gt; &lt;pre&gt;pwconv&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;Take a look at /etc/passwd before and after, and also at /etc/shadow. Thanks to davisc for pointing out this oversight to me :) &lt;/p&gt; &lt;div class="editsection" style="float: right; margin-left: 5px;"&gt;[&lt;a href="http://wiki.kartbuilding.net/index.php?title=Create_DomU&amp;amp;action=edit&amp;amp;section=8" title="Create DomU"&gt;edit&lt;/a&gt;]&lt;/div&gt;&lt;a name="Bug_Fix_for_XEN3_and_File_Based_Images"&gt;&lt;/a&gt;&lt;h3&gt; Bug Fix for XEN3 and File Based Images &lt;/h3&gt; &lt;p&gt;When the base machine dom0 is rebooted - the xen machines (xm create vm01 -c) wont work and will complain. A manual fix is to mount -o loop /xens/image.img /xens/mnt and then umount. &lt;/p&gt;&lt;p&gt;However if you add this line into /etc/init.d/xend &lt;/p&gt; &lt;pre&gt;modprobe loop max_loop=64&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;before echo -n "Starting $DESC: " It will work automatically. Note - this seems to be only for file based storage :-\ &lt;/p&gt;&lt;p&gt;URLS at: &lt;a href="http://lists.alioth.debian.org/pipermail/pkg-xen-devel/2006-June/000563.html" class="external free" title="http://lists.alioth.debian.org/pipermail/pkg-xen-devel/2006-June/000563.html" rel="nofollow"&gt;http://lists.alioth.debian.org/pipermail/pkg-xen-devel/2006-June/000563.html&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;a href="http://lists.xensource.com/archives/html/xen-users/2006-04/msg00968.html" class="external free" title="http://lists.xensource.com/archives/html/xen-users/2006-04/msg00968.html" rel="nofollow"&gt;http://lists.xensource.com/archives/html/xen-users/2006-04/msg00968.html&lt;/a&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-2347691980440735363?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/2347691980440735363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=2347691980440735363' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/2347691980440735363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/2347691980440735363'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2008/12/xen-domu-creation.html' title='Xen DomU creation'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-7133590152870935975</id><published>2008-12-05T12:45:00.000-08:00</published><updated>2008-12-05T12:48:13.062-08:00</updated><title type='text'>Grub installation</title><content type='html'>&lt;h1&gt; 3. Installation &lt;/h1&gt; &lt;!--docid::SEC7::--&gt; &lt;p&gt;  In order to install GRUB as your boot loader, you need to first install the GRUB system and utilities under your UNIX-like operating system (see section &lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_20.html#SEC118"&gt;A. How to obtain and build GRUB&lt;/a&gt;). You can do this either from the source tarball, or as a package for your OS. &lt;/p&gt; &lt;p&gt;  After you have done that, you need to install the boot loader on a drive (floppy or hard disk). There are two ways of doing that - either using the utility &lt;code&gt;grub-install&lt;/code&gt; (see section &lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_16.html#SEC114"&gt;16. Invoking grub-install&lt;/a&gt;) on a UNIX-like OS, or by running GRUB itself from a floppy. These are quite similar, however the utility might probe a wrong BIOS drive, so you should be careful. &lt;/p&gt; &lt;p&gt;  Also, if you install GRUB on a UNIX-like OS, please make sure that you have an emergency boot disk ready, so that you can rescue your computer if, by any chance, your hard drive becomes unusable (unbootable). &lt;/p&gt; &lt;p&gt;  GRUB comes with boot images, which are normally put in the directory `&lt;tt&gt;/usr/share/grub/i386-pc&lt;/tt&gt;'. If you do not use grub-install, then you need to copy the files `&lt;tt&gt;stage1&lt;/tt&gt;', `&lt;tt&gt;stage2&lt;/tt&gt;', and `&lt;tt&gt;*stage1_5&lt;/tt&gt;' to the directory `&lt;tt&gt;/boot/grub&lt;/tt&gt;'. Hereafter, the directory where GRUB images are initially placed (normally `&lt;tt&gt;/usr/share/grub/i386-pc&lt;/tt&gt;') will be called the &lt;em&gt;image directory&lt;/em&gt;, and the directory where the boot loader needs to find them (usually `&lt;tt&gt;/boot/grub&lt;/tt&gt;') will be called the &lt;em&gt;boot directory&lt;/em&gt;. &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table border="0" cellspacing="0"&gt; &lt;tbody&gt;&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC8"&gt;3.1 Creating a GRUB boot floppy&lt;/a&gt;&lt;/td&gt;&lt;td&gt;  &lt;/td&gt;&lt;td align="left" valign="top"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC9"&gt;3.2 Installing GRUB natively&lt;/a&gt;&lt;/td&gt;&lt;td&gt;  &lt;/td&gt;&lt;td align="left" valign="top"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC10"&gt;3.3 Installing GRUB using grub-install&lt;/a&gt;&lt;/td&gt;&lt;td&gt;  &lt;/td&gt;&lt;td align="left" valign="top"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC11"&gt;3.4 Making a GRUB bootable CD-ROM&lt;/a&gt;&lt;/td&gt;&lt;td&gt;  &lt;/td&gt;&lt;td align="left" valign="top"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;  &lt;a name="Creating a GRUB boot floppy"&gt;&lt;/a&gt; &lt;/p&gt;&lt;hr size="6"&gt; &lt;a name="SEC8"&gt;&lt;/a&gt; &lt;table border="0" cellpadding="1" cellspacing="1"&gt; &lt;tbody&gt;&lt;tr&gt;&lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC7"&gt; &lt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC9"&gt; &gt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC7"&gt; &lt;&lt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC7"&gt; Up &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_4.html#SEC12"&gt; &gt;&gt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub.html#SEC_Top"&gt;Top&lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_toc.html#SEC_Contents"&gt;Contents&lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_24.html#SEC133"&gt;Index&lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_abt.html#SEC_About"&gt; ? &lt;/a&gt;]&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;h2&gt; 3.1 Creating a GRUB boot floppy &lt;/h2&gt; &lt;!--docid::SEC8::--&gt; &lt;p&gt;  To create a GRUB boot floppy, you need to take the files `&lt;tt&gt;stage1&lt;/tt&gt;' and `&lt;tt&gt;stage2&lt;/tt&gt;' from the image directory, and write them to the first and the second block of the floppy disk, respectively. &lt;/p&gt; &lt;p&gt;  &lt;strong&gt;Caution:&lt;/strong&gt; This procedure will destroy any data currently stored on the floppy. &lt;/p&gt; &lt;p&gt;  On a UNIX-like operating system, that is done with the following commands: &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;# &lt;kbd&gt;cd /usr/share/grub/i386-pc&lt;/kbd&gt;&lt;br /&gt;# &lt;kbd&gt;dd if=stage1 of=/dev/fd0 bs=512 count=1&lt;/kbd&gt;&lt;br /&gt;1+0 records in&lt;br /&gt;1+0 records out&lt;br /&gt;# &lt;kbd&gt;dd if=stage2 of=/dev/fd0 bs=512 seek=1&lt;/kbd&gt;&lt;br /&gt;153+1 records in&lt;br /&gt;153+1 records out&lt;br /&gt;#&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  The device file name may be different. Consult the manual for your OS. &lt;/p&gt; &lt;p&gt;  &lt;a name="Installing GRUB natively"&gt;&lt;/a&gt; &lt;/p&gt;&lt;hr size="6"&gt; &lt;a name="SEC9"&gt;&lt;/a&gt; &lt;table border="0" cellpadding="1" cellspacing="1"&gt; &lt;tbody&gt;&lt;tr&gt;&lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC8"&gt; &lt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC10"&gt; &gt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC7"&gt; &lt;&lt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC7"&gt; Up &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_4.html#SEC12"&gt; &gt;&gt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub.html#SEC_Top"&gt;Top&lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_toc.html#SEC_Contents"&gt;Contents&lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_24.html#SEC133"&gt;Index&lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_abt.html#SEC_About"&gt; ? &lt;/a&gt;]&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;h2&gt; 3.2 Installing GRUB natively &lt;/h2&gt; &lt;!--docid::SEC9::--&gt; &lt;p&gt;  &lt;strong&gt;Caution:&lt;/strong&gt; Installing GRUB's stage1 in this manner will erase the normal boot-sector used by an OS. &lt;/p&gt; &lt;p&gt;  GRUB can currently boot GNU Mach, Linux, FreeBSD, NetBSD, and OpenBSD directly, so using it on a boot sector (the first sector of a partition) should be okay. But generally, it would be a good idea to back up the first sector of the partition on which you are installing GRUB's stage1. This isn't as important if you are installing GRUB on the first sector of a hard disk, since it's easy to reinitialize it (e.g. by running `&lt;samp&gt;FDISK /MBR&lt;/samp&gt;' from DOS). &lt;/p&gt; &lt;p&gt;  If you decide to install GRUB in the native environment, which is definitely desirable, you'll need to create a GRUB boot disk, and reboot your computer with it. Otherwise, see &lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC10"&gt;3.3 Installing GRUB using grub-install&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;  Once started, GRUB will show the command-line interface (see section &lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_12.html#SEC38"&gt;12.1 The flexible command-line interface&lt;/a&gt;). First, set the GRUB's &lt;em&gt;root device&lt;/em&gt;&lt;a name="DOCF4" href="http://orgs.man.ac.uk/documentation/grub/grub_fot.html#FOOT4"&gt;(4)&lt;/a&gt; to the partition containing the boot directory, like this: &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;grub&gt; &lt;kbd&gt;root (hd0,0)&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  If you are not sure which partition actually holds this directory, use the command &lt;code&gt;find&lt;/code&gt; (see section &lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_13.html#SEC78"&gt;13.3.11 find&lt;/a&gt;), like this: &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;grub&gt; &lt;kbd&gt;find /boot/grub/stage1&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  This will search for the file name `&lt;tt&gt;/boot/grub/stage1&lt;/tt&gt;' and show the devices which contain the file. &lt;/p&gt; &lt;p&gt;  Once you've set the root device correctly, run the command &lt;code&gt;setup&lt;/code&gt; (see section &lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_13.html#SEC101"&gt;13.3.34 setup&lt;/a&gt;): &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;grub&gt; &lt;kbd&gt;setup (hd0)&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  This command will install the GRUB boot loader on the Master Boot Record (MBR) of the first drive. If you want to put GRUB into the boot sector of a partition instead of putting it in the MBR, specify the partition into which you want to install GRUB: &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;grub&gt; &lt;kbd&gt;setup (hd0,0)&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  If you install GRUB into a partition or a drive other than the first one, you must chain-load GRUB from another boot loader. Refer to the manual for the boot loader to know how to chain-load GRUB. &lt;/p&gt; &lt;p&gt;  After using the setup command, you will boot into GRUB without the GRUB floppy. See the chapter &lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_4.html#SEC12"&gt;4. Booting&lt;/a&gt; to find out how to boot your operating systems from GRUB. &lt;/p&gt; &lt;p&gt;  &lt;a name="Installing GRUB using grub-install"&gt;&lt;/a&gt; &lt;/p&gt;&lt;hr size="6"&gt; &lt;a name="SEC10"&gt;&lt;/a&gt; &lt;table border="0" cellpadding="1" cellspacing="1"&gt; &lt;tbody&gt;&lt;tr&gt;&lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC9"&gt; &lt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC11"&gt; &gt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC7"&gt; &lt;&lt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC7"&gt; Up &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_4.html#SEC12"&gt; &gt;&gt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub.html#SEC_Top"&gt;Top&lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_toc.html#SEC_Contents"&gt;Contents&lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_24.html#SEC133"&gt;Index&lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_abt.html#SEC_About"&gt; ? &lt;/a&gt;]&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;h2&gt; 3.3 Installing GRUB using grub-install &lt;/h2&gt; &lt;!--docid::SEC10::--&gt; &lt;p&gt;  &lt;strong&gt;Caution:&lt;/strong&gt; This procedure is definitely less safe, because there are several ways in which your computer can become unbootable. For example, most operating systems don't tell GRUB how to map BIOS drives to OS devices correctly--GRUB merely &lt;em&gt;guesses&lt;/em&gt; the mapping. This will succeed in most cases, but not always. Therefore, GRUB provides you with a map file called the &lt;em&gt;device map&lt;/em&gt;, which you must fix if it is wrong. See section &lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_15.html#SEC113"&gt;15.3 The map between BIOS drives and OS devices&lt;/a&gt;, for more details. &lt;/p&gt; &lt;p&gt;  If you still do want to install GRUB under a UNIX-like OS (such as GNU), invoke the program &lt;code&gt;grub-install&lt;/code&gt; (see section &lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_16.html#SEC114"&gt;16. Invoking grub-install&lt;/a&gt;) as the superuser (&lt;em&gt;root&lt;/em&gt;). &lt;/p&gt; &lt;p&gt;  The usage is basically very simple. You only need to specify one argument to the program, namely, where to install the boot loader. The argument can be either a device file (like `&lt;samp&gt;/dev/hda&lt;/samp&gt;') or a partition specified in GRUB's notation. For example, under Linux the following will install GRUB into the MBR of the first IDE disk: &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;# &lt;kbd&gt;grub-install /dev/hda&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  Likewise, under GNU/Hurd, this has the same effect: &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;# &lt;kbd&gt;grub-install /dev/hd0&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  If it is the first BIOS drive, this is the same as well: &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;# &lt;kbd&gt;grub-install '(hd0)'&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  Or you can omit the parentheses: &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;# &lt;kbd&gt;grub-install hd0&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  But all the above examples assume that GRUB should use images under the root directory. If you want GRUB to use images under a directory other than the root directory, you need to specify the option `&lt;samp&gt;--root-directory&lt;/samp&gt;'. The typical usage is that you create a GRUB boot floppy with a filesystem. Here is an example: &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;# &lt;kbd&gt;mke2fs /dev/fd0&lt;/kbd&gt;&lt;br /&gt;# &lt;kbd&gt;mount -t ext2 /dev/fd0 /mnt&lt;/kbd&gt;&lt;br /&gt;# &lt;kbd&gt;grub-install --root-directory=/mnt fd0&lt;/kbd&gt;&lt;br /&gt;# &lt;kbd&gt;umount /mnt&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  Another example is when you have a separate boot partition which is mounted at `&lt;tt&gt;/boot&lt;/tt&gt;'. Since GRUB is a boot loader, it doesn't know anything about mountpoints at all. Thus, you need to run &lt;code&gt;grub-install&lt;/code&gt; like this: &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;# &lt;kbd&gt;grub-install --root-directory=/boot /dev/hda&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  By the way, as noted above, it is quite difficult to guess BIOS drives correctly under a UNIX-like OS. Thus, &lt;code&gt;grub-install&lt;/code&gt; will prompt you to check if it could really guess the correct mappings, after the installation. The format is defined in &lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_15.html#SEC113"&gt;15.3 The map between BIOS drives and OS devices&lt;/a&gt;. Please be quite careful. If the output is wrong, it is unlikely that your computer will be able to boot with no problem. &lt;/p&gt; &lt;p&gt;  Note that &lt;code&gt;grub-install&lt;/code&gt; is actually just a shell script and the real task is done by the grub shell &lt;code&gt;grub&lt;/code&gt; (see section &lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_15.html#SEC110"&gt;15. Invoking the grub shell&lt;/a&gt;). Therefore, you may run &lt;code&gt;grub&lt;/code&gt; directly to install GRUB, without using &lt;code&gt;grub-install&lt;/code&gt;. Don't do that, however, unless you are very familiar with the internals of GRUB. Installing a boot loader on a running OS may be extremely dangerous. &lt;/p&gt; &lt;p&gt;  &lt;a name="Making a GRUB bootable CD-ROM"&gt;&lt;/a&gt; &lt;/p&gt;&lt;hr size="6"&gt; &lt;a name="SEC11"&gt;&lt;/a&gt; &lt;table border="0" cellpadding="1" cellspacing="1"&gt; &lt;tbody&gt;&lt;tr&gt;&lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC10"&gt; &lt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_4.html#SEC12"&gt; &gt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC7"&gt; &lt;&lt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html#SEC7"&gt; Up &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_4.html#SEC12"&gt; &gt;&gt; &lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;   &lt;/td&gt;&lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub.html#SEC_Top"&gt;Top&lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_toc.html#SEC_Contents"&gt;Contents&lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_24.html#SEC133"&gt;Index&lt;/a&gt;]&lt;/td&gt; &lt;td align="left" valign="middle"&gt;[&lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_abt.html#SEC_About"&gt; ? &lt;/a&gt;]&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;h2&gt; 3.4 Making a GRUB bootable CD-ROM &lt;/h2&gt; &lt;!--docid::SEC11::--&gt; &lt;p&gt;  GRUB supports the &lt;em&gt;no emulation mode&lt;/em&gt; in the El Torito specification&lt;a name="DOCF5" href="http://orgs.man.ac.uk/documentation/grub/grub_fot.html#FOOT5"&gt;(5)&lt;/a&gt;. This means that you can use the whole CD-ROM from GRUB and you don't have to make a floppy or hard disk image file, which can cause compatibility problems. &lt;/p&gt; &lt;p&gt;  For booting from a CD-ROM, GRUB uses a special Stage 2 called `&lt;tt&gt;stage2_eltorito&lt;/tt&gt;'. The only GRUB files you need to have in your  bootable CD-ROM are this `&lt;tt&gt;stage2_eltorito&lt;/tt&gt;' and optionally a config file `&lt;tt&gt;menu.lst&lt;/tt&gt;'. You don't need to use `&lt;tt&gt;stage1&lt;/tt&gt;' or `&lt;tt&gt;stage2&lt;/tt&gt;', because El Torito is quite different from the standard boot process. &lt;/p&gt; &lt;p&gt;  Here is an example of procedures to make a bootable CD-ROM image. First, make a top directory for the bootable image, say, `&lt;samp&gt;iso&lt;/samp&gt;': &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;$ &lt;kbd&gt;mkdir iso&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  Make a directory for GRUB: &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;$ &lt;kbd&gt;mkdir -p iso/boot/grub&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  Copy the file `&lt;tt&gt;stage2_eltorito&lt;/tt&gt;': &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;$ &lt;kbd&gt;cp /usr/share/grub/i386-pc/stage2_eltorito iso/boot/grub&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  If desired, make the config file `&lt;tt&gt;menu.lst&lt;/tt&gt;' under `&lt;tt&gt;iso/boot/grub&lt;/tt&gt;' (see section &lt;a href="http://orgs.man.ac.uk/documentation/grub/grub_5.html#SEC25"&gt;5. Configuration&lt;/a&gt;), and copy any files and directories for the disc to the directory `&lt;tt&gt;iso/&lt;/tt&gt;'. &lt;/p&gt; &lt;p&gt;  Finally, make a ISO9660 image file like this: &lt;/p&gt; &lt;p&gt;  &lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td class="example"&gt;&lt;pre&gt;$ &lt;kbd&gt;mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \&lt;br /&gt;   -boot-load-size 4 -boot-info-table -o grub.iso iso&lt;/kbd&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;  This produces a file named `&lt;tt&gt;grub.iso&lt;/tt&gt;', which then can be burned into a CD (or a DVD).  &lt;kbd&gt;mkisofs&lt;/kbd&gt; has already set up the disc to boot from the &lt;kbd&gt;boot/grub/stage2_eltorito&lt;/kbd&gt; file, so there is no need to  setup GRUB on the disc.  (Note that the &lt;kbd&gt;-boot-load-size 4&lt;/kbd&gt; bit is required for compatibility with the BIOS on many older machines.) &lt;/p&gt; &lt;p&gt;  You can use the device `&lt;samp&gt;(cd)&lt;/samp&gt;' to access a CD-ROM in your config file. This is not required; GRUB automatically sets the root device  to `&lt;samp&gt;(cd)&lt;/samp&gt;' when booted from a CD-ROM. It is only necessary to refer to  `&lt;samp&gt;(cd)&lt;/samp&gt;' if you want to access other drives as well.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;Also dont forget to change the root partition that you get during find of stage 2 in the grub.conf or menu.lst file so that your partitions are accessible while booting.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-7133590152870935975?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/7133590152870935975/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=7133590152870935975' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/7133590152870935975'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/7133590152870935975'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2008/12/grub-installation.html' title='Grub installation'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7866664100757442128.post-8467288146057302766</id><published>2008-11-09T09:59:00.000-08:00</published><updated>2008-11-12T21:50:22.943-08:00</updated><title type='text'>xen networking configuration</title><content type='html'>http://wiki.xensource.com/xenwiki/XenNetworking&lt;br /&gt;&lt;pre&gt;iptables -A FORWARD -m physdev --physdev-in eth0&lt;br /&gt;--physdev-out '!' eth0  -j ACCEPT&lt;br /&gt;&lt;br /&gt;iptables -A FORWARD -m physdev --physdev-out eth0&lt;br /&gt;--physdev-in '!' eth0  -j ACCEPT&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="line862"&gt;you can change the bridge name from &lt;tt&gt;xenbr0&lt;/tt&gt; using: &lt;span class="anchor" id="line-87"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-88"&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;(network-script 'network-bridge bridge=mybridge')&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;ul&gt;&lt;li&gt;&lt;p class="line862"&gt;you can change the bridge name from &lt;tt&gt;xenbr0&lt;/tt&gt; using: &lt;span class="anchor" id="line-87"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-88"&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;(network-script 'network-bridge bridge=mybridge')&lt;br /&gt;&lt;span class="anchor" id="line-89"&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span class="anchor" id="line-90"&gt;&lt;/span&gt;&lt;p class="line862"&gt;in &lt;tt&gt;xend-config.sxp&lt;/tt&gt; and rebooting or restarting &lt;tt&gt;xend&lt;/tt&gt; &lt;span class="anchor" id="line-91"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;remember to configure the bridge to attach to in the domU's config file using: &lt;span class="anchor" id="line-92"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-93"&gt;&lt;/span&gt;&lt;pre&gt;vif=[ 'bridge=mybridge' ]&lt;br /&gt;&lt;span class="anchor" id="line-94"&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span class="anchor" id="line-95"&gt;&lt;/span&gt;or perhaps something like: &lt;span class="anchor" id="line-96"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-97"&gt;&lt;/span&gt;&lt;pre&gt;vif=[ 'mac=00:16:3e:01:01:01,bridge=mybridge' ]&lt;br /&gt;&lt;span class="anchor" id="line-98"&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span class="anchor" id="line-99"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;you can create multiple network interfaces, and attach them to different bridges using: &lt;span class="anchor" id="line-100"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-101"&gt;&lt;/span&gt;&lt;pre&gt;vif=[ 'mac=00:16:3e:70:01:01,bridge=br0', 'mac=00:16:3e:70:02:01,bridge=br1' ]&lt;br /&gt;&lt;span class="anchor" id="line-102"&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span class="anchor" id="line-103"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;p class="line862"&gt;if you want to use multiple bridges, you must create them yourself, either manually, or via your own startup script, or via a custom script to replace &lt;tt&gt;network-bridge&lt;/tt&gt;.  For example: &lt;span class="anchor" id="line-104"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-105"&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;$ cd /etc/xen/scripts&lt;br /&gt;&lt;span class="anchor" id="line-106"&gt;&lt;/span&gt;$ cp network-bridge network-custom&lt;br /&gt;&lt;span class="anchor" id="line-107"&gt;&lt;/span&gt;$ cp vif-bridge vif-custom&lt;br /&gt;&lt;span class="anchor" id="line-108"&gt;&lt;/span&gt;$ vi /etc/xen/xend-config.sxp&lt;br /&gt;&lt;span class="anchor" id="line-109"&gt;&lt;/span&gt;        (network-script network-custom)&lt;br /&gt;&lt;span class="anchor" id="line-110"&gt;&lt;/span&gt;        (vif-script vif-custom)&lt;br /&gt;&lt;span class="anchor" id="line-111"&gt;&lt;/span&gt;$ vi network-custom&lt;br /&gt;&lt;span class="anchor" id="line-112"&gt;&lt;/span&gt;        # whatever you want&lt;br /&gt;&lt;span class="anchor" id="line-113"&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span class="anchor" id="line-114"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;before you connect a physical interface to a bridge, remember to reset it's mac and turn arp off.  For example: &lt;span class="anchor" id="line-115"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-116"&gt;&lt;/span&gt;&lt;pre&gt;# ip link set eth1 down&lt;br /&gt;&lt;span class="anchor" id="line-117"&gt;&lt;/span&gt;# ip link set eth1 mac fe:ff:ff:ff:ff:ff arp off&lt;br /&gt;&lt;span class="anchor" id="line-118"&gt;&lt;/span&gt;# brctl addif br1 eth1&lt;br /&gt;&lt;span class="anchor" id="line-119"&gt;&lt;/span&gt;# ip link set eth1 up&lt;br /&gt;&lt;span class="anchor" id="line-120"&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span class="anchor" id="line-121"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;p class="line862"&gt;With Xen 3.0 the best method for additional bridges is to use the default Xen scripts with a slight modification. Following the &lt;a class="http" href="http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=332"&gt;XenBug #332&lt;/a&gt;. For example in a two bridge network with eth0 and eth1. Create /etc/xen/scripts/my-network-script with &lt;span class="anchor" id="line-122"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-123"&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;#!/bin/sh&lt;br /&gt;&lt;span class="anchor" id="line-124"&gt;&lt;/span&gt;dir=$(dirname "$0")&lt;br /&gt;&lt;span class="anchor" id="line-125"&gt;&lt;/span&gt;"$dir/network-bridge" "$@" vifnum=0&lt;br /&gt;&lt;span class="anchor" id="line-126"&gt;&lt;/span&gt;"$dir/network-bridge" "$@" vifnum=1&lt;br /&gt;&lt;span class="anchor" id="line-127"&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span class="anchor" id="line-128"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-129"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="gap"&gt;With Xen 3.2.1 (tested on Debian Etch 4.0r3), here is a script example that creates two virtual interfaces corresponding to the 2 physical network interfaces &lt;span class="anchor" id="line-130"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-131"&gt;&lt;/span&gt;&lt;pre&gt;# xemacs /etc/xen/scripts/network-bridge-wrapper&lt;br /&gt;&lt;span class="anchor" id="line-132"&gt;&lt;/span&gt;#!/bin/sh&lt;br /&gt;&lt;span class="anchor" id="line-133"&gt;&lt;/span&gt;/etc/xen/scripts/network-bridge $1 netdev=eth0&lt;br /&gt;&lt;span class="anchor" id="line-134"&gt;&lt;/span&gt;/etc/xen/scripts/network-bridge $1 netdev=eth1&lt;br /&gt;&lt;span class="anchor" id="line-135"&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span class="anchor" id="line-136"&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class="line874"&gt;The $1 will use the argument of xend (in the /etc/xen/xend-config.sxp configuration file). If there is a default physical network interface, the standard network-bridge script of Xen will create a vif for this interface, and not the other ones also. &lt;span class="anchor" id="line-137"&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;(Additional note by steve_from_moreover - May be stating the obvious but remember to do - chmod 755 /etc/xen/scripts/my-network-script or when you reboot it will silently not be able to run this script). &lt;span class="anchor" id="line-138"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;On SuSE Linux (at least), each interface requires an ifcfg script in /etc/sysconfig/network, e.g. /etc/sysconfig/network/ifcfg-eth1. Otherwise, network-bridge will create the bridge with no interfaces attached. &lt;span class="anchor" id="line-139"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Then change /etc/xen/xend-config.sxp with the following (network-script my-network-script). &lt;span class="anchor" id="line-140"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;The same principle can apply to networks without a physical ethernet device. Use a dummy interface with &lt;span class="anchor" id="line-141"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-142"&gt;&lt;/span&gt;&lt;pre&gt;"$dir/network-bridge" "$@" vifnum=2 netdev=dummy0&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7866664100757442128-8467288146057302766?l=cercsresearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cercsresearch.blogspot.com/feeds/8467288146057302766/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7866664100757442128&amp;postID=8467288146057302766' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/8467288146057302766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7866664100757442128/posts/default/8467288146057302766'/><link rel='alternate' type='text/html' href='http://cercsresearch.blogspot.com/2008/11/xen-networking-configuration.html' title='xen networking configuration'/><author><name>Pranay Bharatkumar Kolakkar</name><uri>http://www.blogger.com/profile/13625455849469115114</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_jvvGtLIs87Y/SLd3obrOKlI/AAAAAAAAAO8/AuwjqZULujM/S220/newfinal.bmp'/></author><thr:total>0</thr:total></entry></feed>
