ls ( -m option )

UNIX Command

$ls
AUTHORS  autom4te.cache  ChangeLog  CVS  cvs.sh  doc  po  README  src  TODO
$ls -m
AUTHORS, autom4te.cache, ChangeLog, CVS, cvs.sh, doc, po, README, src, TODO
$

UNIX Explanation

-m     fill width with a comma separated list of entries

Theory Drop

In computer science,  an array data structure or  simply array is a
data structure  consisting of a  collection of elements  (values or
variables),  each identified  by at  least one  index. An  array is
stored so  that the position of  each element can  be computed from
its index tuple by a mathematical formula.

source : http://en.wikipedia.org/wiki/Array_data_structure

ls ( -i option )

UNIX Command

$ls
bp  cfg.c  cfg.h  CVS  gtk  Makefile  sample.cfg  simpleproxy.c
$ls -i
5448322 bp     7569479 cfg.h  5448162 gtk	 925726 sample.cfg
7569478 cfg.c  5448150 CVS    8489600 Makefile	5448260 simpleproxy.c
$

UNIX Explanation

-i, --inode
              print the index number of each file

Theory Drop

In  computing, an  index-node  (inode)  is a  data  structure on  a
traditional Unix-style file system such as UFS. An inode stores all
the  information about  a regular  file, directory,  or  other file
system object, except its data and name.[1]

source : http://en.wikipedia.org/wiki/Inode

Follow Up : readdir ( A Prototype Of dirent.h )

bubble sort testing… 0.00007 Ver — 8000 No.'s related

$time php bubble.php

real	0m30.911s
user	0m28.362s
sys	0m0.268s
$time php bubble.php

real	0m32.206s
user	0m29.726s
sys	0m0.208s
$time php bubble.php

real	0m30.047s
user	0m28.366s
sys	0m0.220s
$time php bubble.php

real	0m30.306s
user	0m28.226s
sys	0m0.248s
$time php bubble.php

real	0m29.819s
user	0m28.258s
sys	0m0.252s
$time php bubble.php

real	0m30.567s
user	0m28.598s
sys	0m0.244s
$time php bubble.php

real	0m30.386s
user	0m28.322s
sys	0m0.264s
$

-S option . listing directory contents sorted by file size

GNU command

$ls -l -Gg
total 124
-rwxr-xr-x 1 54161 Dec 12 18:32 bp
-rw-r--r-- 1  8917 Sep 22  2006 cfg.c
-rw-r--r-- 1  1638 Sep 22  2006 cfg.h
drwxr-xr-x 2  4096 Oct 26 17:43 CVS
drwxr-xr-x 3  4096 Oct 26 00:48 gtk
-rw-r--r-- 1   104 Oct 26 00:49 Makefile
-rw-r--r-- 1   718 Dec 12 18:33 sample.cfg
-rw-r--r-- 1 32385 Oct 26 17:43 simpleproxy.c


$ls -l -Gg -S 

total 124
-rwxr-xr-x 1 54161 Dec 12 18:32 bp
-rw-r--r-- 1 32385 Oct 26 17:43 simpleproxy.c
-rw-r--r-- 1  8917 Sep 22  2006 cfg.c
drwxr-xr-x 2  4096 Oct 26 17:43 CVS
drwxr-xr-x 3  4096 Oct 26 00:48 gtk
-rw-r--r-- 1  1638 Sep 22  2006 cfg.h
-rw-r--r-- 1   718 Dec 12 18:33 sample.cfg
-rw-r--r-- 1   104 Oct 26 00:49 Makefile
$


GNU related Explanation

-S     sort by file size

ls (-t option) sort by modification time

GNU command

$ls -l
total 40
drwxr-xr-x  3 jeffrin jeffrin 4096 Aug 18 20:16 beautifulwork
drwxr-xr-x  5 jeffrin jeffrin 4096 Aug 18 20:16 books
drwxr-xr-x  2 jeffrin jeffrin 4096 Aug 18 20:16 bugs-general
drwxr-xr-x  2 jeffrin jeffrin 4096 Oct 13 20:27 config-files
drwxr-xr-x  3 jeffrin jeffrin 4096 Aug 24 22:03 debian-howtos
drwxr-xr-x  2 jeffrin jeffrin 4096 Oct 20 21:59 Docs
drwxr-xr-x  3 jeffrin jeffrin 4096 Oct 19 20:15 https:
drwxr-xr-x  6 jeffrin jeffrin 4096 Oct 21 01:00 language
drwxr-xr-x 10 jeffrin jeffrin 4096 Aug 18 20:16 linux
drwxr-xr-x  6 jeffrin jeffrin 4096 Aug 18 20:16 ovlfose
-rw-r--r--  1 jeffrin jeffrin    0 Aug 18 20:16 README
$ls -l -t
total 40
drwxr-xr-x  6 jeffrin jeffrin 4096 Oct 21 01:00 language
drwxr-xr-x  2 jeffrin jeffrin 4096 Oct 20 21:59 Docs
drwxr-xr-x  3 jeffrin jeffrin 4096 Oct 19 20:15 https:
drwxr-xr-x  2 jeffrin jeffrin 4096 Oct 13 20:27 config-files
drwxr-xr-x  3 jeffrin jeffrin 4096 Aug 24 22:03 debian-howtos
drwxr-xr-x  3 jeffrin jeffrin 4096 Aug 18 20:16 beautifulwork
drwxr-xr-x  5 jeffrin jeffrin 4096 Aug 18 20:16 books
drwxr-xr-x  2 jeffrin jeffrin 4096 Aug 18 20:16 bugs-general
drwxr-xr-x 10 jeffrin jeffrin 4096 Aug 18 20:16 linux
drwxr-xr-x  6 jeffrin jeffrin 4096 Aug 18 20:16 ovlfose
-rw-r--r--  1 jeffrin jeffrin    0 Aug 18 20:16 README
$

GNU Explanation

-t     sort by modification time, newest first

__generic_file_aio_write – write data to a file

1. __generic_file_aio_write – write data to a file

 ssize_t __generic_file_aio_write(struct kiocb * iocb, const struct iovec * iov, unsigned long nr_segs, loff_t * ppos);

iocb    IO state structure (file, offset, etc.)

iov     vector with data to write

nr_segs number of segments in the vector

ppos    position where to write


2. Classroom

Asynchronous I/O,  or non-blocking I/O,  is a form  of input/output
processing  that permits  other processing  to continue  before the
transmission has finished.  Input  and output (I/O) operations on a
computer  can  be extremely  slow  compared  to  the processing  of
data. An  I/O device can  incorporate mechanical devices  that must
physically move,  such as  a hard drive  seeking a trackto  read or
write; this is often orders  of magnitude slower than the switching
of  electric current.  For example,  during a  disk  operation that
takes ten milliseconds  to perform, a processor that  is clocked at
one     gigahertz    could     have    performed     ten    million
instruction-processing cycles.   A simple approach to  I/O would be
to start the  access and then wait for it to  complete. But such an
approach (called  synchronous I/O or blocking I/O)  would block the
progress  of a  program  while the  communication  is in  progress,
leaving  system  resources idle.  When  a  program  makes many  I/O
operations, this means  that the processor can spend  almost all of
its   time   idle  waiting   for   I/O   operations  to   complete.
Alternatively, it is possible,  but more complicated to predict, to
start the  communication and then perform processing  that does not
require  that  the  I/O  has  completed. This  approach  is  called
asynchronous input/output.  Any task  that actually depends  on the
I/O having completed (this includes both using the input values and
critical operations that claim to assure that a write operation has
been  completed) still  needs  to  wait for  the  I/O operation  to
complete, and thus is still blocked, but other processing that does
not have a dependency on the I/O operation can continue.

source : http://en.wikipedia.org/wiki/Asynchronous_I/O

readelf (-a option) Displays information about ELF files

UNIX Command

$cat hello.c
#include
main()
{
int d;
scanf("%d",d);
printf("%d",d);
}
$gcc hello.c
$ulimit -c unlimited
$./a.out
3
Segmentation fault (core dumped)
$readelf -s core
$readelf -a core
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              CORE (Core file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          0 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         17
  Size of section headers:           0 (bytes)
  Number of section headers:         0
  Section header string table index: 0

There are no sections in this file.

There are no sections to group in this file.

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  NOTE           0x00000000000003f8 0x0000000000000000 0x0000000000000000
                 0x0000000000000558 0x0000000000000000         0
  LOAD           0x0000000000001000 0x0000000000400000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  R E    1000
  LOAD           0x0000000000002000 0x0000000000600000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  RW     1000
  LOAD           0x0000000000003000 0x00007f1e480c7000 0x0000000000000000
                 0x0000000000001000 0x000000000017a000  R E    1000
  LOAD           0x0000000000004000 0x00007f1e48241000 0x0000000000000000
                 0x0000000000000000 0x0000000000200000         1000
  LOAD           0x0000000000004000 0x00007f1e48441000 0x0000000000000000
                 0x0000000000004000 0x0000000000004000  R      1000
  LOAD           0x0000000000008000 0x00007f1e48445000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  RW     1000
  LOAD           0x0000000000009000 0x00007f1e48446000 0x0000000000000000
                 0x0000000000005000 0x0000000000005000  RW     1000
  LOAD           0x000000000000e000 0x00007f1e4844b000 0x0000000000000000
                 0x0000000000001000 0x000000000001f000  R E    1000
  LOAD           0x000000000000f000 0x00007f1e48643000 0x0000000000000000
                 0x0000000000003000 0x0000000000003000  RW     1000
  LOAD           0x0000000000012000 0x00007f1e48667000 0x0000000000000000
                 0x0000000000003000 0x0000000000003000  RW     1000
  LOAD           0x0000000000015000 0x00007f1e4866a000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  R      1000
  LOAD           0x0000000000016000 0x00007f1e4866b000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  RW     1000
  LOAD           0x0000000000017000 0x00007f1e4866c000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  RW     1000
  LOAD           0x0000000000018000 0x00007fff27f53000 0x0000000000000000
                 0x0000000000022000 0x0000000000022000  RW     1000
  LOAD           0x000000000003a000 0x00007fff27fff000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  R E    1000
  LOAD           0x000000000003b000 0xffffffffff600000 0x0000000000000000
                 0x0000000000000000 0x0000000000001000  R E    1000

There is no dynamic section in this file.

There are no relocations in this file.

There are no unwind sections in this file.

No version information found in this file.

Notes at offset 0x000003f8 with length 0x00000558:
  Owner                 Data size	Description
  CORE                 0x00000150	NT_PRSTATUS (prstatus structure)
  CORE                 0x00000088	NT_PRPSINFO (prpsinfo structure)
  CORE                 0x00000130	NT_AUXV (auxiliary vector)
  CORE                 0x00000200	NT_FPREGSET (floating point registers)
$

UNIX Explanation

readelf displays  information about one  or more ELF  format object
files.  The options control what particular information to display.
elffile... are the object files  to be examined.  32-bit and 64-bit
ELF  files are  supported, as  are archives  containing  ELF files.
This program  performs a  similar function to  objdump but  it goes
into more detail and it exists independently of the BFD library, so
if there is a bug in BFD then readelf will not be affected.

vm_insert_page – insert single page into user vma

1. vm_insert_page - insert single page into user vma


int vm_insert_page(struct vm_area_struct * vma, unsigned long addr, struct page * page);

vma  user vma to map to

addr  target user address of this page

page  source kernel page


2. Classroom


The  virtual  memory  area   (VMA)  is  the  kernel  data
structure used to manage  distinct regions of a process's
address space.  A VMA represents a  homogeneous region in
the virtual  memory of a  process: a contiguous  range of
virtual addresses that have the same permission flags and
are backed  up by the same  object (a file,  say, or swap
space).  It  corresponds  loosely  to the  concept  of  a
"segment," although  it is better described  as "a memory
object  with its  own properties."  The memory  map  of a
process is made up of (at least) the following areas:

An area for the program's executable code (often called text)

Multiple areas for data, including initialized data (that
which has  an explicitly assigned value  at the beginning
of  execution),  uninitialized  data  (BSS),[3]  and  the
program stack

[3]  The name  BSS  is  a historical  relic  from an  old
assembly operator meaning  "block started by symbol." The
BSS segment of executable files isn't stored on disk, and
the kernel maps the zero page to the BSS address range.

One area for each active memory mapping

related source: http://www.makelinux.net/ldd3/chp-15-sect-1

grep ( -c option )

UNIX Command

$grep -c pack  resume.txt
0
$grep -c Linux  resume.txt
9
$grep -c Lin  resume.txt
9
$grep -c Li  resume.txt
9
$grep -c L  resume.txt
15
$grep -c engineer  resume.txt
2
$grep -c 1976  resume.txt
1
$grep -c GNU  resume.txt
5
$

UNIX Explanation For (grep -c)

Suppress normal output; instead print a count of matching lines for
each input  file.  With the -v, --invert-match  option (see below),
count non-matching lines.  (-c is specified by POSIX.)