Monday, November 24, 2008

A basic look on Inodes

Inode stores basic information about a regular file, directory, or other file system object. The inode number is a unique integer assigned to the device upon which it is stored. All files are hard links to inodes.
n the Linux kernel, there are three storage areas where inodes are saved. First, there are two lists (both maintained as doubly linked lists). One of these lists saves used inodes, while another stores unused inodes. There is a hash table that stores all used inodes as well, since hash tables makes searching for inodes faster. The hash value is based on super block address and inode number of the index. And then, finally, there is a structure that stores the number of used and unused inodes. This structure resembles the following:

struct{
int nr_inodes;
int nr_free-inodes;
}inodes_stat;


nr_inodes variable stores the number of inodes, while nr_free_inodes stores the number of unused inodes.

The inodes structure is widely used in file system implementation. This structure is defined in /include/linux/fs.h

Now that we have looked into the inode structure, how should we create and destroy inodes? Linux kernel implementers provide two functions for this:
Iget() and iput()

A file's inode number can be found using the ls -i command, while the ls -l command will retrieve inode information.

Wednesday, July 9, 2008

Building linux kernel source for fedora

As fedora installation doesn't come with the kernel source, for kernel hackers source is a must and below are the steps to compile the kernel source
  • Download the corresponding kernel.src.rpm file from www.sourceforge.com

  • # rpm –ivh kernel-2.6.10-1.741.src.rpm

  • # rpmbuild –bp –target=norarch /usr/src/redhat/SPECS/kernel-2.6.spec

  • cd /usr/src

  • ln -s redhat/BUILD/kernel-2.6.10/linux-2.6.10/ linux

  • ln -s redhat/BUILD/kernel-2.6.10/linux-2.6.10/ linux-2.6.10

  • cd /linux-2.6.17.7

  • make mrproper

Tuesday, July 8, 2008

Linux on Windows

I was always looking for "Linux on Windows" and finally found this.
andLinux a Ubuntu based distro takes cooperation with Windows to a whole new level that requires no virtualization. andLinux integrates coLinux kernel. The coLinux project takes a stable release of the Linux kernel and ports it to run on Windows. That means that, unlike virtualization software, andLinux installs on Windows like any other application.
andLinux is available in two flavours -- a 665MB version that uses KDE and takes up 4.5GB of disk space, and a lightweight 143MB version with Xfce that uses 2.5GB on a hard drive. The developers recommend earmarking at least 192MB of RAM during installation for andLinux, but make sure you have enough memory left for Windows itself. andLinux will run only on 32-bit versions of Windows 2000, XP, 2003, and Vista, and your hard drive needs to be formatted using the NTFS filesystem.

Friday, March 7, 2008

Flex Module for Apache & Installing Flex SDK

Steps to install flex module for apache on linux.
-------------------------------------------------

Pre-requisities

1. Flex SDK 2.0.1 or later (can download from http://download.macromedia.com/pub/flex/sdk/flex2_sdk_hf1.zip)
2. JRE 1.4.2 or later (can download a self extracting jre file and install)
3. Java enabled browser
$cd /plugins
$ln -s /plugins/i386/ns7/libjavaplugin_oji.so
Restart firefox

Installing Flex-SDK
1. unzip the downloaded flex_sdk_hf1.zip
$unzip flex_sdk_hf1.zip
2. cd fles_sdk/bin
3. chmod 777 mxmlc
4. vi mxmlc
On line 34 change "java $VMARGS -jar "$FLEX_HOME/lib/mxmlc.jar" +flexlib="$FLEX_HOME/frameworks" $*" to "_INSTALLED_DIR>/bin/java $VMARGS -jar "$FLEX_HOME/lib/mxmlc.jar" +flexlib="$FLEX_HOME/frameworks" $*"

Installing Flex module for apache
1. Download flex module for apache(http://download.macromedia.com/pub/labs/flex_mod_apache/flex_module_manual_install_050107.
zip)
2. unzip flex_module_manual_install_050107.zip
$unzip flex_module_manual_install_050107.zip
3. Inside the /usr/bin folder create a new file named compiler.sh and add (a copy of this in dir)
#!/bin/sh
java -Djava.awt.headless=true -ms128M -mx256M -jar "//flexc.jar" ${*}
4. grant execution permissions on the compiler.sh file.
$ chmod 777 /usr/bin/compiler.sh
5. Open the Apache configuration file (httpd.conf) and add the following
LoadModule flex_module /modules/apache///mod_flex.so
AddHandler flex .mxml
6. configuring the compiler.conf
set the path to flex-config.xml (flex_config=/frameworks/flex-config.xml)
set the path to fles lib (flex_lib=/frameworks)
7. Restart apache server

Note: To compile .mxml file use mxmlc -o .swf .mxml

Friday, February 29, 2008

Install uClibc

Download root_fs_i386.bz2
mkdir /uclibc/root_fs
su root
e2fsck -f /home/xyz/root_fs_i386.ext2
resize2fs /home/xyz/root_fs_i386.ext2 2G
mount -o loop root_fs_i386.ext2 /ulibc/root_fs/
chroot root_fs /bin/su -

Thursday, February 28, 2008

How Catalytic Converters Work

To help reduce the emissions further, they have developed an interesting device called a catalytic converter, which treats the exhaust before it leaves the car and removes a lot of the pollution.

Pollutants Produced by a Car Engine

In order to reduce emissions, modern car engines carefully control the amount of fuel they burn. They try to keep the air-to-fuel ratio very close to the stoichiometric point, which is the calculated ideal ratio of air to fuel. Theoretically, at this ratio, all of the fuel will be burned using all of the oxygen in the air. For gasoline, the stoichiometric ratio is about 14.7:1, meaning that for each pound of gasoline, 14.7 pounds of air will be burned. The fuel mixture actually varies from the ideal ratio quite a bit during driving.

The main emissions of a car engine are:

  • Nitrogen gas (N2) - Air is 78-percent nitrogen gas, and most of this passes right through the car engine.

  • Carbon dioxide (CO2) - This is one product of combustion. The carbon in the fuel bonds with the oxygen in the air.

  • Water vapor (H2O) - This is another product of combustion. The hydrogen in the fuel bonds with the oxygen in the air.

The combustion process is never perfect, some smaller amounts of more harmful emissions are also produced in car engines:

  • Carbon monoxide (CO) - a poisonous gas that is colorless and odorless

  • Hydrocarbons or volatile organic compounds (VOCs) - produced mostly from unburned fuel that evaporates

Sunlight breaks these down to form oxidants, which react with oxides of nitrogen to cause ground level ozone (O3), a major component of smog.

  • Nitrogen oxides (NO and NO2, together called NOx) - contributes to smog and acid rain, and also causes irritation to human mucus membranes

These are the three main regulated emissions, and also the ones that catalytic converters are designed to reduce.

How Catalytic Converters Reduce Pollution

Most modern cars are equipped with three-way catalytic converters. "Three-way" refers to the three regulated emissions it helps to reduce -- carbon monoxide, VOCs and NOx molecules. The converter uses two different types of catalysts, a reduction catalyst and an oxidation catalyst. Both types consist of a ceramic structure coated with a metal catalyst, usually platinum, rhodium and/or palladium. The idea is to create a structure that exposes the maximum surface area of catalyst to the exhaust stream, while also minimizing the amount of catalyst required (they are very expensive).




A three-way catalytic converter: Note the two separate catalysts.

There are two main types of structures used in catalytic converters -- honeycomb and ceramic beads. Most cars today use a honeycomb structure.


Ceramic honeycomb catalyst structure



Engine Cotrol Unit (ECU)

An Engine Control Unit (ECU) also known as Engine Management System (EMS) is an electronic system which controls various aspects of an internal combustion engine's operation. The most simple ECUs simply control the quantity of fuel injected into each cylinder each engine cycle. More advanced ECUs found on most modern cars also control the Ignition timing, Variable Cam Timing (VCT), the level of Boost maintained by the turbocharger (in turbocharged cars), and control other peripherals.

ECUs determine the quantity of fuel, ignition timing and other parameters by monitoring the engine through sensors. These can include, MAP sensor, Throttle position sensor, Air temperature sensor, Engine coolant temperature sensor and many others.

Before ECUs most engine parameters were fixed. The quantity of fuel per cylinder per engine cycle was determined by a Carburetot.



ECU Operation

Control of Fuel Injection

For an engine with fuel injection, an ECU will determine the quantity of fuel to inject based on a number of parameters. If the throttle pedal is pressed further down, the ECU will inject more fuel. If the engine has not warmed up yet, more fuel will be injected (causing the engine to run slightly 'rich' until the engine warms up).

Control of Ignition Timing

A spark ignition engine requires a spark to initiate combustion in the combustion chamber. An ECU can adjust the exact timing of the spark (called ignition timing) to provide better power and economy. If the ECU detects knock, a condition which is potentially destructive to engines, it can delay (retard) the timing of the spark to prevent this.

Control of Variable Cam Timing

Some engines have Variable Cam Timing. In such an engine, the ECU controls the time in the engine cycle that the cams open. At higher speed the cams are usually opened later than at lower speed. This can optimise the flow of air into the cylinder, increasing power and economy.

Programmable ECUs

A special category of ECUs are those which are programmable. These units do not have a fixed behavior, but can be reprogrammed by the user.

Programmable ECUs are required where significant aftermarket modifications have been made to a vehicles engine. Examples include, adding or changing of turbocharger, adding or changing of intercooler, changing of exhaust system, conversion to run on alternative fuel. As a consequence of these changes, the old ECU may not provide appropriate control for the new configuration.

In these situations, a programmable ECU can be wired in. These can be programmed/mapped while the engine is running by connecting a laptop to it using a serial or USB cable.

For example the programmable ECU may control the amount of fuel to be injected into each cylinder. This varies depending on the engine's RPM and the position of the gas pedal (or the manifold air pressure). The engine tuner can adjust this by bringing up a spreadsheet-like page on the laptop where each cell represents an intersection between a specific RPM value and a gas pedal position (or the throttle position, as it is called). In this cell a number corresponding to the amount of fuel to be injected is entered.

By modifying these values while monitoring the exhausts using a wide band lambda probe to see if the engine runs rich or lean, the tuner can find the optimal amount of fuel to inject to the engine at every different combination of RPM and throttle position. This process is often carried out at a dynamometer, giving the tuner a controlled environment to work in.

Other parameters that are often mappable are:

  • Ignition : Defines when the spark plug should fire for a cylinder

  • Rev limit : Defines the max RPM that the engine is allowed to rev to. After this fuel and/or ignition is cut.

  • Water temperature correction : Allows for additional fuel to be added when the engine is cold (choke).

  • Transient fueling : Tells the ECU to add a specific amount of fuel when throttle is applied.

  • Low fuel pressure modifier : Tells the ECU to increase the injector fire time to compensate for a loss of fuel pressure.

  • Closed loop lambda : Lets the ECU monitor a permanently installed lambda probe and modify the fueling to achieve stoichiometric (ideal) combustion.

Some of the more advanced race ECUs include functionality such as launch control, limiting the power of the engine in first gear to avoid burnouts. Other examples of advanced functions are:

  • Waste gate control : Sets up the behavior of a turbo waste gate, controlling boost.

  • Banked injection : Sets up the behavior of double injectors per cylinder, used to get a finer fuel injection control and atomization over a wide RPM range.

  • Variable cam timing : Tells the CPU how to control variable intake and exhaust cams.

  • Gear control : Tells the ECU to cut ignition during (sequential gearbox) upshifts or blip the throttle during downshifts.

A race ECU is often equipped with a data logger recording all sensors for later analysis using special software in a PC. This can be useful to track down engine stalls, misfires or other undesired behaviors during a race by downloading the log data and looking for anomalies after the event. The data logger usually has a capacity between 0.5 and 16 Mbytes.

In order to communicate with the driver, a race ECU can often be connected to a "data stack", which is a simple dash board presenting the driver with the current RPM, speed and other basic engine data. These race stacks, which are almost always digital, talk to the ECU using one of several proprietary protocols running over RS232, CANbus or ethernet.

ECU 'flashing'

Many recent (around 1996 or newer) cars use OBD-II ECUs that are sometimes capable of having their programming changed through the OBD port. Automotive enthusiasts with modern cars take advantage of this technology when tuning their engines. Rather than use an entire new engine management system, one can use the appropriate software to adjust the factory equipped computer. By doing so, it is possible to retain all stock functions and wiring while using a custom tuned program. This should not be confused with "chip tuning", where the owner has ECU ROM physically replaced with a different one -- no hardware modification is (usually) involved with flashing ECUs, although special equipment is required.

Factory engine management systems often have similar controls as aftermarket units intended for racing, such as 3-dimensional timing and fuel control maps. They generally do not have the ability to control extra ancillary devices, such as variable valve timing if the factory vehicle was a fixed geometry camshaft or boost control if the factory car was not turbocharged.