Gas operation in a firearm refers to the cycling of the action though the use of propellant gas tapped from the barrel: if the propellant gas remains in the barrel and acts on the cartridge, it is a blowback operating system.
Gas-operated firearms are operated by the gas pressure produced by the propellant in the cartridge. The gas is routed through a gas port into a gas tube, which is linked back to the action.
Gas operation is defined in two ways regarding the location of the force being exerted: Inline, in which the gas pressure exerts force upon the entirety of the front of the bolt carrier group evenly, which forces it back in a straight line; and Offset, in which the gas pressure exerts pressure on one side (typically top or bottom, dependent upon the location of the gas tube and actuator rod), relying on outside forces (usually rails inside the receiver) to keep the bolt carrier group straight.
Bang & Gas Trap
The earliest system of gas operation tapped gas at the weapon's muzzle. The "Bang" system used a muzzle section that was forced forward, converting this to rearward motion to operate the action using a seesaw linkage. The later gas trap system simplified this to a stationary muzzle trap which bled propellant gas to the rear, having them act against a gas piston.
The gas block is the part of the firearm that regulates how much gas from the fired cartridge gets back to the action in the receiver, in order to cycle the weapon. This part is only found in gas-operated weapons, and is always installed on the barrel. It may feature an adjustable gas regulator.
Wherever the gas block is installed, there is always a gas port drilled into the barrel to allow gas into the gas block, and a gas tube (or actuator rod, connected to the bolt carrier, in long-stroke piston gas systems) installed to allow the gas back into the action. The diameter of this port can vary widely due to the cartridge fired, wear and tear on the weapon (as more rounds are fired, the gas port becomes wider; this is referred to as gas port erosion), and the use of an adjustable gas regulator, which can mitigate the effects of gas port erosion. The port should be drilled wide enough so that the firearm is able to cycle, but the amount of gas being let through isn't beating up the action and its components due to excessive pressure.
The gas port should, generally speaking, be wider if it is drilled further down the barrel, as there is less gas pressure at that point. If using a suppressor (or building a weapon meant only for suppressor usage), the port should be narrower; suppressors send a lot of gas back into the action, causing premature parts wear due to the pressure spike.
Most semi-automatic, select-fire, and fully automatic firearms are piston operated. The piston rings are often located on the bolt (this is especially true of rotating bolt designs), and the bolt carrier functions as a piston cylinder. This section will detail some of the better known gas-operated systems that feature pistons.
Short-stroke piston operation
This mode of piston operation features a gas tube, which feeds gas back to the action. A short actuator rod (usually spring-loaded) is located at the rear of the gas tube, in the action itself. When the gas pressure is great enough, the pressure forces the actuator rod rearward, pushing the bolt carrier back and unlocking the bolt, allowing the firearm to cycle.
Long-stroke piston operation
This is very similar to short-stroke piston operation; however, the actuator rod is much longer, and may be connected to the bolt carrier itself.
Expanding gas piston operation
Commonly mistaken for direct impingement, this mode of piston operation does away with the actuator rod, instead using the gas pressure itself to cycle the action. It does this by routing the gas into the interior chamber of the bolt carrier, which is vented to bleed off excess gas as the pressure rises. When the pressure rises high enough, it forces the bolt carrier rearward, unlocking the bolt and cycling the action.
For the pressure to stay high enough long enough to cycle the action, there must be enough dwell time; just long enough to keep the action adequately pressurized. Dwell time is determined by the amount of barrel after the gas port and the speed of the bullet traveling down the bore past the gas port before it exits the barrel.
This mode of gas operation does away with the piston completely. The bolt is designed in such a way so that the gas acts directly upon the bolt (hence the name) to cycle the action.
This is featured in the MAS-49 rifle.
Fluted chamber direct impingement
This form of direct impingement uses a fluted chamber as a gas port. When firing, the gas is channeled around the chambered cartridge through the grooves of the chamber fluting surpassing the locking lugs into the front of the bolt carrier that acts as a gas piston to unlock the bolt and cycle the weapons operation.