exception emask 0x0 sact 0x0 serr 0x0 action 0x0

The following error might occur while the system boots.

exception emask 0x0 sact 0x0 serr 0x0 action 0x0

To get around this we will need a live cd or a bootable usb. We can create a bootable usb using unetbootin. After booting using the live cd or the bootable usb, open a terminal and run the command

$ sudo fdisk -l /dev/sda1 1 6713 53914624 83 Linux

This will list all the disks available in the system. Choose the on in which linux is installed, assume it to be /dev/sda1. Now run the command

$ fsck /dev/sda1

Answer yes for any repair related uestions thrown during the system check.

Once the check is over, reboot the system and try booting back into the ususal system. The error should no longer appear .

Category: Linux | Comments Off on exception emask 0x0 sact 0x0 serr 0x0 action 0x0

Creation of proc entrt using proc_create_data in kernel version 3.10 and above.

In the post “Creating read only proc entry in kernel versions above 3.10. ” we saw how to create a proc entry using the function proc_create.

Note: The following module is valid only of kernel version 3.10 and above.

Another function available in kernel version 3.10 and above for creation of proc entry is proc_create_data which is defined in proc_fs.hs as

struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,struct proc_dir_entry *parent,const struct file_operations *proc_fops,void *data);

Where

name: The name of the proc entry
mode: The access mode for proc entry
parent: The name of the parent directory under /proc
proc_fops: The structure in which the file operations for the proc entry will be created.
data: If any data needs to be passed to the proc entry.

For example to create a proc entry by the name “hello” under /proc the above functions will be defined are

proc=proc_create_data(“hello”,0,NULL,&proc_fops,msg);

Along with creation of the entry we are also passing a function to the proc entry in using the porinter “msg”.

Now we need to create file_operations structure proc_fops in which we can map the read function for the proc entry.

struct file_operations proc_fops = { read: read_proc };

Next we need to add the function read_proc which will give to the user space the data that we want to export from the kernel space.

int read_proc(struct file *filp,char *buf,size_t count,loff_t *offp ) { char *data; data=PDE_DATA(file_inode(filp)); if(!(data)){ printk(KERN_INFO “Null data”); return 0; } if(count>temp) { count=temp; } temp=temp-count; copy_to_user(buf,data, count); if(count==0) temp=len; return count; }

To access the data in the proc_dir_structure we need to make use of the function PDE_DATA to which we pass the file pointer. The function in turn returs a pointer to the data that was passed during the creation of the proc entry.

The message that we want to display will be defined in the function create_new_proc_entry in which we will also call the fuction for creation of proc entry.

void create_new_proc_entry() { msg=”Hello World “; proc=proc_create_data(“hello”,0,NULL,&proc_fops,msg); len=strlen(msg); temp=len; }

The init and clean up functions for the module are

int proc_init (void) { create_new_proc_entry(); return 0; } void proc_cleanup(void) { remove_proc_entry(“hello”,NULL); }

The full code for creation of proc entry using proc_create_data is

proc_read_data.c

#include #include #include #include #include #include #include #include struct proc_dir_entry *proc; int len,temp; char *msg; int read_proc(struct file *filp,char *buf,size_t count,loff_t *offp ) { char *data; data=PDE_DATA(file_inode(filp)); if(!(data)){ printk(KERN_INFO “Null data”); return 0; } if(count>temp) { count=temp; } temp=temp-count; copy_to_user(buf,data, count); if(count==0) temp=len; return count; } struct file_operations proc_fops = { read: read_proc }; void create_new_proc_entry() { msg=”Hello World “; proc=proc_create_data(“hello”,0,NULL,&proc_fops,msg); len=strlen(msg); temp=len; } int proc_init (void) { create_new_proc_entry(); return 0; } void proc_cleanup(void) { remove_proc_entry(“hello”,NULL); } MODULE_LICENSE(“GPL”); module_init(proc_init); module_exit(proc_cleanup);

The makefile for the compilation of the modules are

ifneq ($(KERNELRELEASE),) obj-m := proc_read_data_3_10.o else #KERNELDIR ?= /lib/modules/$(shell uname -r)/build KERNELDIR ?= /home/nitin/Desktop/src/linux-3.11.1/ PWD := $(shell pwd) default: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules endif clean: $(MAKE) -C $(KERNELDIR) M=$(PWD) clean

Compile and load the module using

$ make $ sudo insmod proc_read_3_10.ko

We can see the output by using the cat command $ cat /proc/hello Hello World

Related Posts:

Creating read only proc entry in kernel versions above 3.10.

For kernel version before 3.10

Creating a proc entry – 1

Creating a proc read entry

Category: Linux | Comments Off on Creation of proc entrt using proc_create_data in kernel version 3.10 and above.

Creating read only proc entry in kernel versions above 3.10.

The creation of proc entries has undergone a considerable change in kernel version 3.10 and above. In this post we will see one of the methods we can use in linux kernel version 3.10 and above let us see how we can create proc entries in version 3.10 and above.

The function is defined in proc_fs.h as

static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,struct proc_dir_entry *parent, const struct file_operations *proc_fops)

Where:

name: The name of the proc entry
mode: The access mode for proc entry
parent: The name of the parent directory under /proc
proc_fops: The structure in which the file operations for the proc entry will be created.

For example to create a proc entry by the name “hello” under /proc the above function will be defined are

proc_create(“hello”,0,NULL,&proc_fops);

Now we need to create file_operations structure proc_fops in which we can map the read function for the proc entry.

struct file_operations proc_fops = { read: read_proc };

Next we need to add the function read_proc which will give to the user space the data that we want to export from the kernel space.

int read_proc(struct file *filp,char *buf,size_t count,loff_t *offp ) { if(count>temp) { count=temp; } temp=temp-count; copy_to_user(buf,msg, count); if(count==0) temp=len; return count; }

The message that we want to display will be defined in the function create_new_proc_entry in which we will also call the fuction for creation of proc entry.

void create_new_proc_entry() { proc_create(“hello”,0,NULL,&proc_fops); msg=” Hello World “; len=strlen(msg); temp=len; printk(KERN_INFO “1.len=%d”,len); }

The init and clean up functions for the module are

int proc_init (void) { create_new_proc_entry(); return 0; } void proc_cleanup(void) { remove_proc_entry(“hello”,NULL); }

The full code of module for creation of proc entry using proc_create is

#include #include #include #include#include int len,temp; char *msg; int read_proc(struct file *filp,char *buf,size_t count,loff_t *offp ) { if(count>temp) { count=temp; } temp=temp-count; copy_to_user(buf,msg, count); if(count==0) temp=len; return count; } struct file_operations proc_fops = { read: read_proc }; void create_new_proc_entry() { proc_create(“hello”,0,NULL,&proc_fops); msg=” Hello World “; len=strlen(msg); temp=len; printk(KERN_INFO “1.len=%d”,len); } int proc_init (void) { create_new_proc_entry(); return 0; } void proc_cleanup(void) { remove_proc_entry(“hello”,NULL); } MODULE_LICENSE(“GPL”); module_init(proc_init); module_exit(proc_cleanup);

The makefile for the compilation of the module is

ifneq ($(KERNELRELEASE),) obj-m := proc_read_3_10.o else #KERNELDIR ?= /lib/modules/$(shell uname -r)/build KERNELDIR ?= /home/nitin/Desktop/src/linux-3.11.1/ PWD := $(shell pwd) default: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules endif clean: $(MAKE) -C $(KERNELDIR) M=$(PWD) clean

Compile and load the module using

$ make $ sudo insmod proc_read_3_10.ko

We can see the output by using the cat command $ cat /proc/hello Hello World

We can see that the message that we passed in the read function of the module is being displayed when the proc entry is read.

Related Posts : For kernel version before 3.10 Creating a proc entry – 1 Creating a proc read entry

Category: Linux | Comments Off on Creating read only proc entry in kernel versions above 3.10.

Adding a designer frame to an image using gimp in linx

We can add a designer frame to any photo using gimp by using following steps.

Open gimp and open the photo for which we need to add a frame by clicking on

file->open

We will use the following example image to add a frame to.

 photo linux.jpg

Now click on

FX-Foundry->Image effects->Add Frame

As shown below.

 photo add_frame_select.png

This will pop a window with options for the frame as shown below.

 photo add_frame_options.png

The various options are

Frame Width : The width of the frame to added
Frame Fill: We can choose the fill the frame with
Color of our choise or, the same color as the background, the same color as the foreground or we can select any of the patterns available in gimp.
Texture Frame: We can add a texture from the various options of texture available. Texture Bump Map and Bump interactively are advanced options which we can explore once we are comfortable with the basics.
Bevel Index: How much slope needs to be added to the frame
Inner Shadow width : Width of the shadow of the frame
Innter Shadow Opacity :Opacity of the inner shadow.
Use layers : To retain the layers gimp creates for adding the frame, if the box is not checked gimp merges all the layers and creates a single layered image.

Now click on ok and we can see gimp will uickly add the frame as selected by the various options. The following is the result of addition of a frame to the above image.

 photo linux_with_frame.jpg

Category: Linux | Comments Off on Adding a designer frame to an image using gimp in linx

To find if cpu is 32bit or 64 bit in linux

Here are two ways of finding out,using linux, whether a processor on a system is 32bit or 64 bit.

1. Using proc entry.

Run the command

$ cat /proc/cpuinfo | grep address\ sizes address sizes : 40 bits physical, 32 bits virtual

The above output clearly indicates that the address size of the cpu is 32 bits and hence does not support 64 bit.

2. Using the command cpuid.

For this we will have to install the package cpuid

$ sudo apt-get install cpuid

After the installation run the command

cpuid | grep address Maximum linear address: 32; maximum phys address 40

From the above output too we can conclude that the cpu is a 32bit architecture.

Category: Linux | Comments Off on To find if cpu is 32bit or 64 bit in linux

Binary clock on linux terminal

Here is how we can create a binary clock on the Linux terminal. We will need to install the package binclock which can be done in the debian based systems

$ sudo apt-get install binclock

Now launch a terminal and run the command

$ binclock

 photo binclock.png

To understand the output add the option “-n”

$ binclock -n

 photo binclock_2.png

The binary time is in the format HH:MM:SS. The first column represents the first number of HH the second column the second number of HH and so on.

binclock by default provides the output in color which can be turned of by adding the option –color=off

$ binclock –color=off

 photo binclock3.png

Category: Linux | Comments Off on Binary clock on linux terminal

Creating pencil sketch of an image in linux using pinta

Here is how we can create the pencil skethc of any image using the software pinta in linux.

If you do not have pinta installed, you can install it using the package manager. In debian based systems we can run

apt-get install pinta

Now launch pinta, In debian it would be listed under Applications->graphics, might be different for other distros.

Now click on

file->open

 photo open.png

Browse the image for which the pencil sketch is need to be made, and click on open. Let us take the image of our beloved tux for creation of a pencil sketch.

 photo tux.png

Now click on

Effects->Artistic->Pencil Sketch.

 photo menu.png

The following menu will pop.

 photo pencil_menu.png

Pencil tip size: Higher this value more dark the image looks.
Color range: Higher the value more mix of white and balck will appear in the image.

As the change in these options are done, the changes in the image can be seen in the backgroud. Which ever values are satisfctory click ok for those and the pencil sketch image is ready. Here is the pencil sketch image of tux.

 photo tux_pencil.png

Category: Linux | Comments Off on Creating pencil sketch of an image in linux using pinta

Adding fog effect using gimp

Here is how we can add the fog effect to any image, using gimp.

Lunch gimp and click on

file->open

Browse to the photo that is to which the fog effect has to be added and click on open.

In the example we will use the following image to add the fog effect.

 photo DSC00302-1.jpg

Now click on

filter->render->cloud->fog

 photo 2_fog_select.jpg

This will launch a window as shown below.

 photo fog_menu.jpg

The options available are

Name: Layer Name Color: The color of the fog Turbulence: How much fog should be added to the image Opacity: How opaque should the fog be.

Click on OK and wait for gimp to do the magic.

After applying the fog, the above image looks as below.

 photo fogged_pic.jpg

Category: Linux | Comments Off on Adding fog effect using gimp

Quiz based on chapter-4 of book linux device drivers 3rd ed

Quiz on chapter-4 of book linux device drivers 3rd ed body {margin: 10px;} Quiz on chapter-4 of book linux device drivers 3rd ed Which of the following config options need to be enabled to be able to debug kernel.
CONFIG_DEBUG_KERNEL
CONFIG_USB
CONFIG_EXT4
CONFIG_DBG

The first argument passed to printk specifies the
loglevel for the message to be printed
terminal number for the message to be printed
userid of the current user
line number in which the message has to be printed

The command that can be used to view the kernel logs from user space is
kmesg
dmesg
kmsg
dmsg

The function create_proc_read_entry returns a pointer to
struct proc_dir
struct proc_entry
struct proc_dir_entry
struct proc

The seq file interface is used for
logging errors in kernel space
Creating a /proc entry
Passing user information to kernel
Passing kernel information to user space

output of strace shows
The function calls made by user applications
The system calls made by a user appliction
The kernel modules used by a user application
The various applications running in the user space.

In a kernel oops message EIP points to
The address of the faulty instruction
The faulty instruction
The faulty line in the user code
The faulty user application

While using gdb for kernel debugging the kernel core file used passed to gdb is
/proc/core
/proc/kcore
/dev/core
/dev/kcore

Which of the following keys will launch the kdb
sysrq
pause
shift
del

To use kgdb we need two systems connected by a serial cable
True
False
depends on kernel version
depends on kgdb version

Category: Linux | Comments Off on Quiz based on chapter-4 of book linux device drivers 3rd ed

Script to download the latest linux kernel

Here is a script that will download the latest kernel source kernel.org. THe script works on the current html page of kernel.org and might break if anything is changed in the page of kernel.org.

latest_kernel:

#!/bin/bash latest_kernel () { latest_link=$(grep -A 1 “latest_link” page | tail -1 | cut -d “\”” -f 2 | cut -d “.” -f 2-) prefix=https://www.kernel.org link=$prefix$latest_link for((i=0;i] 17,430 27.8K/s in 0.6s 2013-08-01 22:23:20 (27.8 KB/s) – “page” saved [17430/17430] FINISHED –2013-08-01 22:23:20– Downloaded: 1 files, 17K in 0.6s (27.8 KB/s) downloading from https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.10.4.tar.xz –2013-08-01 22:23:20– https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.10.4.tar.xz Resolving www.kernel.org… 149.20.4.69, 198.145.20.140 Connecting to www.kernel.org|149.20.4.69|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 73187712 (70M) [application/x-xz] Saving to: “linux-3.10.4.tar.xz” 100%[===================================================================================>] 73,187,712 97.3K/s in 11m 18s 2013-08-01 22:34:40 (105 KB/s) – “linux-3.10.4.tar.xz” saved [73187712/73187712] Download complete

Thus we can see from the ouput that the latest kernel 3.10.4 has been downloaded. In case the download gets interrupted then the script will retry the download 3 times before quitting with the message of “Download Failed”.

Category: Linux | Comments Off on Script to download the latest linux kernel