Linux script to create colorful 2013 on the terminal

Here is a script with which you can create the number 2013, on your terminal using any character of your choice. The colors of the numbers will change randomly on every run of hte script.

2013.sh:

#!/bin/bash str_dwn() { rows=$1 s_start=$2 char=$4 str_st_row=$3 rows_end=$((str_st_row+rows)) for((i=str_st_row;i

Category: Linux | Comments Off on Linux script to create colorful 2013 on the terminal

Sad Love Shayari in Hindi

Shayari

Badalna aata nahi humko mausmon ki tarah
Har ek rut mein tera intejar karte hain
Na tum samet sakogi jise qyamat tak
Kasam tumhari tumhe itna pyar karte hain…

Category: Uncategorized | Comments Off on Sad Love Shayari in Hindi

Sad Love Shayari in Hindi

Shayari

Badalna aata nahi humko mausmon ki tarah
Har ek rut mein tera intejar karte hain
Na tum samet sakogi jise qyamat tak
Kasam tumhari tumhe itna pyar karte hain…

Category: Uncategorized | Comments Off on Sad Love Shayari in Hindi

Implementing an ioctl call (for kernel versions above 2.6.39)

In the post “Creating an ioctl command in linux ” we saw the basics of ioctl, and how we can create our own ioctl commands. The functions used to create ioctls have undergone a change from the kernel version 2.6.39,and the previous functions are no longer valid.

Before 2.6.39, the ioctl calls would lock the BKL (Big kernel lock) and then execute the required functions. This was unnecessary with the new fine grained locking available in the kernel. Thus to improve the implementation of ioctl, a new operation called unlocked_ioctl was introduced and all the existing ioctls were migrated to this new implementation.

Thus stating 2.6.39 the older implementation is no longer available.

The changes required in implementation of the ioctl are.

The function in the driver has changed from

int ioctl_funcs(struct inode *inode, struct file *filp,unsigned int cmd, unsigned long arg)

long ioctl(struct file *filp,unsigned int cmd, unsigned long arg)

The inode is no longer passed as an argument.
The fops uses the name unlocked_ioctl

struct file_operations fops = { open: open, unlocked_ioctl: ioctl_funcs, release: release };

The basic working of ioctl remains same.
Here is a code that implements the above mentioned changes if the kernel version is more than 2.6.39, else uses the older interface.

Module: ioctl_basic.c

#include #include #include // required for various structures related to files liked fops. #include #include #include “ioctl_basic.h” #include static int Major; #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36) #define UNLOCKED 1 #endif int open(struct inode *inode, struct file *filp) { printk(KERN_INFO “Inside open \n”); return 0; } int release(struct inode *inode, struct file *filp) { printk (KERN_INFO “Inside close \n”); return 0; } #ifdef UNLOCKED long ioctl_funcs(struct file *filp,unsigned int cmd, unsigned long arg) { int ret=0; switch(cmd) { case IOCTL_HELLO: printk(KERN_INFO “Hello ioctl world”); break; } return ret; } struct file_operations fops = { open: open, unlocked_ioctl: ioctl_funcs, release: release }; #else int ioctl_funcs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { int data=10,ret; switch(cmd) { case IOCTL_HELLO: printk(KERN_INFO “Hello ioctl world”); break; } return ret; } struct file_operations fops = { open: open, ioctl: ioctl_funcs, release: release }; #endif struct cdev *kernel_cdev; int char_arr_init (void) { int ret; dev_t dev_no,dev; kernel_cdev = cdev_alloc(); kernel_cdev->ops = &fops; kernel_cdev->owner = THIS_MODULE; printk (” Inside init module\n”); ret = alloc_chrdev_region( &dev_no , 0, 1,”char_arr_dev”); if (ret < 0) { printk("Major number allocation is failed\n"); return ret; } Major = MAJOR(dev_no); dev = MKDEV(Major,0); printk (" The major number for your device is %d\n", Major); ret = cdev_add( kernel_cdev,dev,1); if(ret < 0 ) { printk(KERN_INFO "Unable to allocate cdev"); return ret; } return 0; } void char_arr_cleanup(void) { printk(KERN_INFO " Inside cleanup_module\n"); cdev_del(kernel_cdev); unregister_chrdev_region(Major, 1); } MODULE_LICENSE("GPL"); module_init(char_arr_init); module_exit(char_arr_cleanup); The steps of compiling and testing the module are same as shown in the post “Creating an ioctl command in linux ”

Category: Linux | Comments Off on Implementing an ioctl call (for kernel versions above 2.6.39)

Send Me SMS in Hindi

Sher Shayari

Diya hai upar wale ne mobile
tou thoda yaad tou kiya karo,
Baat karo ya na karo aap ki marzi,
Par dil se doo chaar sweet se msg to kiya karo..

Category: Uncategorized | Comments Off on Send Me SMS in Hindi

Send Me SMS in Hindi

Sher Shayari

Diya hai upar wale ne mobile
tou thoda yaad tou kiya karo,
Baat karo ya na karo aap ki marzi,
Par dil se doo chaar sweet se msg to kiya karo..

Category: Uncategorized | Comments Off on Send Me SMS in Hindi

Bewafa Shayari SMS

Bewafa Shayari

Duniya me koi kisi ke liye kuch nahi karta,
Marne wale ke saath har koi nahi marta,
Are Marne ki baat to door rahi,
Yaha to zindgi hai phir b koi yaad nahi karta…

Category: Uncategorized | Comments Off on Bewafa Shayari SMS

colorful Christmas Tree on linux terminal

Here is a version 2 of the Christmas tree creation script. The script will create a colorful Christmas tree on the terminal. The colors of the tree will change on every run.

The script will take as input the character with which the tree has to be drawn, and any two characters that have to be used to decorated the tree.

Christmas_tree:

#!/bin/bash backslash() { b_st_row=$1 b_st_cols=$2 b_char=$3 deco=$5 b_r_end=$((b_st_row + 5 )) for((p=b_st_row;p

Category: Linux | Comments Off on colorful Christmas Tree on linux terminal

Missing You Shayari

Missing You Shayari

Jaha dekhu samne nazaar ati ho tum,
Pyaar ki parichayiyo se hamesha yaad ati ho tum,
Mere Khwaboo ki duniya me rehti ho tum,
Mere pass ake muskurati ho tum,
Mohabat ki in raho me ake tadapati ho tum,
Pyaar hume de kar door cheli jati ho tum…

Category: Uncategorized | Comments Off on Missing You Shayari

Missing You Shayari

Missing You Shayari

Jaha dekhu samne nazaar ati ho tum,
Pyaar ki parichayiyo se hamesha yaad ati ho tum,
Mere Khwaboo ki duniya me rehti ho tum,
Mere pass ake muskurati ho tum,
Mohabat ki in raho me ake tadapati ho tum,
Pyaar hume de kar door cheli jati ho tum…

Category: Uncategorized | Comments Off on Missing You Shayari