Advance Tools and Technologies

October 29, 2016
Categorised in: Operating System Design
NEED OF MAKE TOOLS
Problems:
- Long files are harder to manage (for both programmers and machines)
- Every change requires long compilation
- Many programmers can not modify the same file simultaneously
Solution: divide project to multiple files
- Good division to components
- Minimum compilation when something is changed
- Easy maintenance of project structure, dependencies and creation
make
Make: productivity enhancement utility and a program management tool
Useful for managing the development of large-sized programs (very large number of functions and many developers)
For big projects- common definitions hold across all the functions under development
This is true regardless of number of persons involved in development
Make tool not only facilitates consistent usage of definitions in the large program but also helps to avoid wasteful re-compilation
What is a makefile?
Make is a program that looks for a file called “makefile” or “Makefile”, within the makefile are variables and things called dependencies.
Why are makefiles useful?
Makefiles can make the compilation procedure much faster.
The compilation is done using a single command
Only the files that must be compiled are compiled
Allows managing large programs with a lot of dependencies.
Done in Unix by the Makefile mechanism
Makefile is special format file that together with make utility helps you to automatically build and manage your projects
A makefile is a file (script) containing :
- Project structure (files, dependencies)
- Instructions for files creation
The make command reads a makefile, understands the project structure and makes up the executable
Note that the Makefile mechanism is not limited to C programs
Make helps in the management of programs that spread over several files
Make avoids unnecessary compilation
Project structure and dependencies can be represented as a DAG (= Directed Acyclic Graph)
A directed acyclic graph (DAG) is a directed graph that contains no cycles and a rooted tree is a special kind of DAG and a DAG is a special kind of directed graph.
Example :
- Program contains 3 files
- main.c., sum.c, sum.h
- sum.h included in both .c files
- Executable should be the file sum
nmake
namke utility is provided by Microsoft
Available in Visual Studio
It is handy tool for creating automated builds
Similar to the UNIX “make” command.
NMAKE however maintains state information for future executions
Syntax: nmake [options] [script…] [target…]
The makefiles are the main source of input to nmake
cmake
It is cross platform, free and open-source system for managing the build process of software using a compiler-independent method.
It is designed to support directory hierarchies and applications that depend on multiple libraries.
Used in conjunction with native build environments such as make, Apple’s Xcode, and Microsoft Visual Studio.
Developed by Kitware software company US
It is family of tools designed to build, test & package software
Controls software compilation process
Syntax for CMakeList.txt file contains comments, commands, and white space.
A comment is indicated by # and runs till the end of the line.
A command consists of the command name, opening parenthesis, white space separated arguments and a closing parenthesis.
A command can be either one of the built in commands like add_library, or a user defined macro function
The input to Cmake is a CMakeList.txt file in the source directory and that file in turn can use include or add subdirectory command to add additional input files.
Cmake advantages:
- CMakeList.txt file is readable and easier to understand
- Does not depend only on “Make” to build the project
- Supports multiple generators like Xcode, Eclipse, Visual Studio etc.
AWK Tools
AWK is designed for text processing and typically used as a data extraction and reporting tool.
It is a standard feature of most Unix-like operating systems.
AWK was created at Bell Labs in the 1970s, and its name is derived from the family names of its authors – Alfred Aho, Peter Weinberger, and Brian Kernighan.
It is mostly used for pattern scanning & processing
AWK preforms following operations:
- Scans a file line by line
- Splits each input line into fields
- Compares input line/fields to pattern
- Performs action on matched lines
Useful for:
- transform data files
- produce formatted reports
The essential organization of an AWK program follows the form:
- Pattern { action }
- The pattern specifies when the action is performed. Like most UNIX utilities, AWK is line oriented.
- The pattern specifies a test that is performed with each line read as input.
awk Scripts
awk scripts are divided into three major parts:
comment lines start with #
Grep
Where does the name come from?
- g/RE/p
- globally regular expression print
How it works?
- Search command for UNIX.
- Used to search for text strings and regular expressions within one or more files.
- man grep
- grep looks inside file(s) and returns any line that contains the string or expression
- prints lines matching a pattern to STDOUT
Grep and Regular Expressions
A “regular expression” is a pattern that describes a set of strings.
This command is used for searching plain text data and it searches the file for given text and prints the line in which given word found.
Regular expressions are used when you want to search for specific lines of text containing a particular pattern.
If grep cannot find a line in any of the specified files that contain the requested pattern, no output is produced.
SYNTAX
- The syntax for the grep command is:
- grep [options] pattern [files]
Grep options
Grep examples
grep Pattern
grep Pattern filename
Ex. grep ‘permission’ thisFile
grep pattern file1 file2
Ex. grep ‘permission’ file1 file2
file1:
file2:
If grep cannot find a line in any of the specified files that contain the requested pattern, no output is produced.
egrep
egrep is an acronym for “Extended Global Regular Expressions Print”
Egrep extends the syntax of the regular egrep command
Egrep [options] PATTERN FILE
Generally grep does not support the parentheses, the + operator, the | operator or ? Operator
Supports extended set of meta-characters, more expressive but slower
egrep examples
fgrep
fgrep is an acronym that stands for “Fixed-string Global Regular Expressions Print”.
fgrep (which is the same as grep -F) is fixed or fast grep and behaves as grep but does NOT recognize any regular expression meta-characters as being special.
The search will complete faster because it only processes a simple string rather than a complex pattern.
fgrep searches for many literal strings simultaneously and does not work with *
The Syntax:
fgrep [options] pattern [file]
Sorting tool
sort sorts the contents of a text file, line by line.
sort is a simple and very useful command which will rearrange the lines in a text file so that they are sorted, numerically and alphabetically.
By default, the rules for sorting are:
- lines starting with a number will appear before lines starting with a letter;
- lines starting with a letter that appears earlier in the alphabet will appear before lines starting with a letter that appears later in the alphabet;
- lines starting with a lowercase letter will appear before lines starting with the same letter in uppercase.
- The Syntax:
- sort [options] filename]
sort -r data.txt //Sorting In Reverse Order
UEFI BOOT
UEFI is a firmware interface specification
Standardized mechanism to bootstrap Operating
System (OS) launch
Next-generation replacement for
BIOS-based firmware
UEFI is a platform independent specification
UEFI ADVANTAGES
UEFI firmware provides several technical advantages over a traditional BIOS system:
- Ability to boot from large disks
- CPU-independent architecture
- CPU-independent drivers
- Flexible pre-OS environment, including network capability
- Modular design
- Secure boot facility
UEFI BOOTING
Unlike BIOS, UEFI does not rely on a boot sector, defining instead a boot manager as part of the UEFI specification.
When a computer is powered on, the boot manager checks the boot configuration and, based on its settings, loads and executes the specified operating system loader or operating system kernel.
Booting UEFI systems from GPT (GUID Partition Table)-partitioned disks is commonly called UEFI-GPT booting.
Additionally, it is common for an UEFI implementation to include a user interface to the boot manager, allowing the user to manually select the desired operating system (or system utility) from a list of available boot options, and load it.
U BOOT
Universal Bootstrap Loader
The U-Boot utility is a multi-platform, open-source, universal boot-loader with comprehensive support for loading and managing boot images, such as the Linux kernel.
U-Boot supports interactive commands, environment variables, command scripting and booting from external media
U-Boot supports a large variety of popular CPUs and CPU families used today, and much larger collection of reference boards based on these processor
U-Boot initialize the CPU and several peripherals located on board, create some critical data structures which will be used by kernel
Information Commands
- bdinfo – list board information on console
- coninfo – list console information
- flinfo – list flash memory information
- iminfor – list application image information
- help – lists commands , for help on specific command type help command
Memory Commands
- base – print or set base address
- cp – copy memory
- md – display memory
- mm – modify memory
- mtest – simple memory test
- mw – memory write
- nm – memory modify
USB BOOT
Generally booting is done from some bootable media like CD, DVD, Hard disk etc.
USB boot is the process of using a USB storage device to boot or start a computer’s operating system
It enables computer hardware to use a USB storage stick to get all essential system booting information and files
Most of the operating system support the creation of a bootable USB drive that can be plugged into a USB slot to boot a computer, server or laptop
CASE STUDY OF FEDORA-19
Gcdx64.efi – unsigned version of GRUB
Grubx64.efi – this is main GRUB executable, signed with Fedora’s key
Grub.cfg – configuration file which maintains GRUB details
MokManager.efi – mok means machine owner key. This program enables you to add keys to MOK list from the EFI
Shim.efi – this is version of shim signed with Microsoft’s key
Shim-fedora.efi – this is unsigned version of shim
Gcdx64.efi and Grubx64.efi:
- Both files are used in booting process
- Supports secure booting
- Generally used with 64-bit operating system
- Boot menu is created in many operating systems by using these files
Grub.cfg – configuration file which maintains GRUB details
- It is at /boot/grub2/grub.cfg
- Used to crate list of operating system to boot in GRUB’s main menu
- Allows to select desired operating system to boot from
- Also considered as menu configuration file
- With the help of configuration file, we can change display name of the operating system also
MokManager.efi – MOK- Machine Owner Key
- It returns key management back to the user and sys-admin
- Provides uniformly with the same interface and same key formats on all systems
- Main purpose of secure boot is to prevent malware from gaining control to computer
- Components of the boot process can be replaced by machine owner keys
- MOK provides security with key based authentication
Shim.efi – used in secure boot
- Provides authentication to Linux kernel
- Also called pre-bootloader
- Provides secure boot with three different types of keys:
- Secure boot keys- Shim is able to identify the keys which are built into the firmware, or that users create themselves
- Shim keys- compiled with its own build in keys, similar to secure boot keys
- MOKs- a machine owner key is type of key that user generates and uses to sign an EFI (Extensible Firmware Interface) binary
Shim-fedora.efi – first stage boot loader
- Used to verify the GRUB and UEFI
- Before boot process starts GRUB2 calls shim
- Shim is cryptographically signed software
- Supports Microsoft keys for verification
- Allows continuing booting in secure mode
- Verifies the kernel and GRUB using cryptographic verification
- Uses different keys like shim, secure boot keys and machine user keys
Pratik Kataria is currently learning Springboot and Hibernate.
Technologies known and worked on: C/C++, Java, Python, JavaScript, HTML, CSS, WordPress, Angular, Ionic, MongoDB, SQL and Android.
Softwares known and worked on: Adobe Photoshop, Adobe Illustrator and Adobe After Effects.