Legacy Development and Integration Guide
From RidgeRun Developer Connection
Linux Application Development
This section targets software developers with a little background on Linux software development, presenting some basic concepts about Linux applications that may be unfamiliar to developers with experience in real time operating systems (RTOS).
Linux application development is more like standard PC application development and less like RTOS focused development. The main differences is the clear separation between the applications and the operating system and also that applications are stored on a file system.
This section doesn't replace a good book on Linux/Unix software development, but introduces the minimal concepts that will be useful when porting applications.
Kernel and User Space
Linux is a multi-tasking operating system with protection between executing processes.Therefore applications run in their own address-space which is provided by the kernel using the hardware memory management unit (MMU).
Since applications are separate from the kernel, they live on some file system, therefore Linux needs a least one file system holding the initial applications: the root file system.
The File System
Linux file system is based on Unix file system concepts, and therefore it is composed of a tree of files that are located on some physical storage. The physical storage should provide the root of the tree (the root file system) and other devices can be “mounted” at directories in the file system tree.
Following the Unix mindset, most of the computer universe is represented like a file: files are data containers for more than binary executable files or raw data stored on memory devices, files are also used to represent device drivers, interprocess pipes, or system status.
Unix file system layout is also important, as there are standard locations for configuration files, shared libraries, binaries, shared data, etc.
Pseudo file systems
Linux has several pseudo file systems that when mounted doesn't reflect actual stored files on some memory device, but file handlers that can provide information about the system, a process, a driver, etc. This pseudo file systems generate the file entries and contents dynamically, based on the system status.
The two more common pseudo-file systems are procfs, and sysfs. More information on those can be found on the next section.
Linux File System Layout
Understanding the Linux file system layout is important for the porting process. The following table explains what's the propose for most common locations and give you an idea or where to store the contents of your application.
|/bin||Intended for executable binaries required for the basic system.|
|/sbin||Intended for executable binaries required for the basic system that should be available only to the super (root) user.|
|/lib||Shared libraries for the basic system.|
|/etc||Text configuration files of the basic system.|
|/tmp||Temporary files: on most embedded systems this directory contents are lost between power cycles.|
|/var||Intended to store data from system programs: web server pages, log files, mail server data, etc.|
|/proc||This is the typical mount point of Linux's pseudo file system procfs, which creates a set of files that contain different aspects of the running system, processes, drivers, etc.|
|/sys||This is the typical mount point of Linux's pseudo file system sysfs, which provides information on, and control of, devices drivers and kernel objects.|
|/opt||Intended for applications that don't form part of the standard system provided by the vendor. These are usually third-party applications. Most of the applications at this location don't conform to the bin/lib separation of the Unix file systems.|
|/usr/bin||Intended for executable binaries that are not required for the basic system.|
|/usr/sbin||Intended for executable binaries that are not required for the basic system that should be available only to the super user.|
|/usr/lib||Shared libraries not required for the basic system.|