EmbLogic's Blog

module code to show how an open operation is performed on the device file when an application calls ” open() function”.

RCS file: header.h,v
Working file: header.h
head: 1.16
branch:
locks: strict
root: 1.16
access list:
symbolic names:
keyword substitution: kv
total revisions: 16;    selected revisions: 16
description:
Base header file that includes the definitions of all the macros,structures and contains the necessary header files required by the module code.
—————————-
revision 1.16    locked by: root;
date: 2014/02/28 17:13:48;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/types.h> is added to support dev_t type.
—————————-
revision 1.15
date: 2014/02/28 16:58:15;  author: root;  state: Exp;  lines: +6 -0
Two macros are defined called MAJOR_NO and MINOR_NO.
—————————-
revision 1.14
date: 2014/02/28 15:44:56;  author: root;  state: Exp;  lines: +2 -2
The macro DEVICE_NAME is changed to DRIVER_NAME and the header file:<string.h> is removed.
—————————-
revision 1.13
date: 2014/02/28 15:41:31;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/cdev.h> is added to support a cdev structure.The cdev structure is used to register the driver with the kernel.
—————————-
revision 1.12
date: 2014/02/28 15:33:59;  author: root;  state: Exp;  lines: +1 -0
Header file:<string.h> is added to support memset() function.
—————————-
revision 1.11
date: 2014/02/28 15:18:15;  author: root;  state: Exp;  lines: +16 -0
Four macros are defined namely:DEVICE_SIZE , DATA_SIZE , QUANTUM and QSET.
These macros are used to initialize the fields inside the Scull_Dev structure.
—————————-
revision 1.10
date: 2014/02/28 15:10:35;  author: root;  state: Exp;  lines: +16 -0
Two structures are defined of type Sculldev and Scullqset.Sculldev is a structure that is used to hold device information.Scullqset is a structure that holds a pointer to the qset array and another pointer to a structure of Scullqset type.
—————————-
revision 1.9
date: 2014/02/27 21:07:42;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/slab.h> is added to support kmalloc() and kfree() functions.
—————————-
revision 1.8
date: 2014/02/27 20:02:53;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/moduleparam.h> is added to support the module_param() macro.With the help of this macro parameters can be passed to a module while loading it.
—————————-
revision 1.7
date: 2014/02/27 19:28:38;  author: root;  state: Exp;  lines: +4 -0
A macro called DEVICE_NAME is defined using #define.
—————————-
revision 1.6
date: 2014/02/27 19:20:01;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/fs.h> is added to the base header file to support various functions like alloc_chrdev_region(),unregister_chrdev_region(),etc.
—————————-
revision 1.5
date: 2014/02/27 18:44:36;  author: root;  state: Exp;  lines: +4 -0
A macro called DEBUG is defined using #define.
—————————-
revision 1.4
date: 2014/02/27 18:41:13;  author: root;  state: Exp;  lines: +2 -0
A special macro called MODULE_LICENSE is used to tell the kernel that the module bears a free license without such a decleration the kernel complains.
—————————-
revision 1.3
date: 2014/02/27 18:38:11;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/module.h> is added to the base header file to provide support for a great many number of macros like:MODULE_LICENSE , MODULE_AUTHOR,etc.
—————————-
revision 1.2
date: 2014/02/27 18:36:07;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/init.h> is added to the base header file to provide support for module_init() and module_exit() macros.
—————————-
revision 1.1
date: 2014/02/27 18:35:18;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: initial.c,v
Working file: initial.c
head: 1.13
branch:
locks: strict
root: 1.13
access list:
symbolic names:
keyword substitution: kv
total revisions: 13;    selected revisions: 13
description:
File containing the module’s initialization function that is called at module insertion time.
—————————-
revision 1.13    locked by: root;
date: 2014/02/28 18:56:45;  author: root;  state: Exp;  lines: +1 -1
Fixed the warning by giving void as an argument inside the initialize_parameters() function.
Compilation is successfull.
Checking the functionality by calling application……….
—————————-
revision 1.12
date: 2014/02/28 17:59:59;  author: root;  state: Exp;  lines: +1 -0
Header file:”file_opr.h” is added to include the file_operations structure.The file_operations structure is used to access the driver’s functions.
—————————-
revision 1.11
date: 2014/02/28 17:49:26;  author: root;  state: Exp;  lines: +15 -4
After a device number range has been obtained,the device needs to be activated by adding it to the character device database.This requires initializing an instance of cdev_init() followed by a call to cdev_add().cdev_add() tells te kernel about the cdev data structure.
—————————-
revision 1.10
date: 2014/02/28 17:16:31;  author: root;  state: Exp;  lines: +16 -0
Both the major and minor numbers are initialized to 0 inside the initialize_parameters() function.Macros like MAJOR() and MINOR() are used to extract the major and minor number from dev type variable.Another macro called MKDEV is used to create the device number.
Checking……
—————————-
revision 1.9
date: 2014/02/28 16:50:22;  author: root;  state: Exp;  lines: +25 -0
From the initialization function,another function is called to initialize the parameters such as device size, quantum_size ,qset_size and data_size.

Status:The parameters are initialized successfully.
Now before the kernel calls the device’s operations,a cdev structure must be initialized with cdev_init() and the kernel is being told about the initialization with cdev_add().Implementing this task….
—————————-
revision 1.8
date: 2014/02/28 15:46:09;  author: root;  state: Exp;  lines: +1 -1
Inside the alloc_chrdev_region(),the fourth argument is changed from DEVICE_NAME to DRIVER_NAME.
—————————-
revision 1.7
date: 2014/02/28 15:32:31;  author: root;  state: Exp;  lines: +1 -0
memset() is used to fill the memory allocated using kmalloc() function with ”.
—————————-
revision 1.6
date: 2014/02/28 15:26:38;  author: root;  state: Exp;  lines: +12 -1
kmalloc() function is used to allocate memory.kmalloc() function takes two arguments:
1.size ,and
2.set of flags.
On success,kmalloc returns a pointer to the allocated memory otherwise it returns NULL.
In the flag field,GFP_KERNEL is used.
—————————-
revision 1.5
date: 2014/02/27 20:12:29;  author: root;  state: Exp;  lines: +7 -1
module_param() macro is used.With the help of this macro parameters can be passed to the module while loading it,when using “insmod”.
module_param() macro takes three arguments:
1.The name of the variable,
2.The type of the variable,
3.Permissions.
—————————-
revision 1.4
date: 2014/02/27 19:58:09;  author: root;  state: Exp;  lines: +1 -1
alloc_chrdev_region() function is used to allocate dynamically a major number.On success,the first parameter of this function stores the first device number.
—————————-
revision 1.3
date: 2014/02/27 19:31:39;  author: root;  state: Exp;  lines: +11 -0
Header file: “decleration.h” is added to include all the variable declerations.
—————————-
revision 1.2
date: 2014/02/27 18:50:37;  author: root;  state: Exp;  lines: +7 -0
module_init() macro is used to define which function is called during module’s insertion time.
__init token hints to the kernel that the function is used only at the initialization time.
The function specified by the module_init() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:49:06;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.6
branch:
locks: strict
root: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
File that contains the cleanup function which returns all the resources back to the system.
—————————-
revision 1.6    locked by: root;
date: 2014/02/28 15:35:01;  author: root;  state: Exp;  lines: +1 -0
kfree() function is used for freeing the memory.
—————————-
revision 1.5
date: 2014/02/27 20:15:39;  author: root;  state: Exp;  lines: +3 -1
A variable of type int representing the number of devices is included here using extern.
—————————-
revision 1.4
date: 2014/02/27 19:36:03;  author: root;  state: Exp;  lines: +1 -0
A variable dev of type dev_t storing the device number is included here using extern.
—————————-
revision 1.3
date: 2014/02/27 19:33:49;  author: root;  state: Exp;  lines: +3 -1
Called unregister_chrdev_region() which is having 2 arguments: device number and the total number of device numbers to unregister.
—————————-
revision 1.2
date: 2014/02/27 18:58:02;  author: root;  state: Exp;  lines: +14 -0
module_exit() macro is used to define which function is to be called at module removal time.\
The function specified by the module_exit() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:55:42;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: openf.c,v
Working file: openf.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
The functionality of chardev_open() is implemented here inside this file.Whenever the application calls the open function,this is always the first operation performed on the device file.
—————————-
revision 1.3    locked by: root;
date: 2014/02/28 18:51:08;  author: root;  state: Exp;  lines: +2 -0
Included the prototype of chardev_open() using extern.
—————————-
revision 1.2
date: 2014/02/28 18:42:56;  author: root;  state: Exp;  lines: +15 -0
Two printk statements are used to test that whether the open function is actually begin and ended.\
—————————-
revision 1.1
date: 2014/02/28 18:33:28;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: decleration.h,v
Working file: decleration.h
head: 1.7
branch:
locks: strict
root: 1.7
access list:
symbolic names:
keyword substitution: kv
total revisions: 7;    selected revisions: 7
description:
All the variable declerations are done inside this header file.
—————————-
revision 1.7    locked by: root;
date: 2014/02/28 18:48:17;  author: root;  state: Exp;  lines: +2 -0
Gave prototype of chardev_open() function.
—————————-
revision 1.6
date: 2014/02/28 17:05:32;  author: root;  state: Exp;  lines: +1 -0
A variable of type dev_t is declared that is used to store the updated device number obtained from mkdev.
—————————-
revision 1.5
date: 2014/02/28 16:59:40;  author: root;  state: Exp;  lines: +3 -0
Two variables are declared inside this file that will hold the information about major and minor numbers.
—————————-
revision 1.4
date: 2014/02/28 16:39:07;  author: root;  state: Exp;  lines: +4 -0
Variables quantum_size,qset_size,data_size and device_size are declared that will get initialized by the macros defined in header.h.
—————————-
revision 1.3
date: 2014/02/28 15:30:46;  author: root;  state: Exp;  lines: +1 -0
A variable of type Sculldev is declared in this file.
—————————-
revision 1.2
date: 2014/02/27 20:06:26;  author: root;  state: Exp;  lines: +1 -0
A variable of type int is declared representing the number of devices.
—————————-
revision 1.1
date: 2014/02/27 19:30:54;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Character Driver, Device Drivers | Leave a comment

linklist implementation using functions.

RCS file: lll.c,v
Working file: lll.c
head: 1.8
branch:
locks: strict
saurabh: 1.8
access list:
symbolic names:
keyword substitution: kv
total revisions: 8; selected revisions: 8
description:
created a linklist program where diff aspects are being done.
first created new linklist
second add a new node to the linklist which is already been created.
so far a new node in inserted from the begining
and from the end .

—————————-
revision 1.8 locked by: saurabh;
date: 2014/02/28 14:16:42; author: saurabh; state: Exp; lines: +3 -4
sorting function working properly
insertion at nth node is working well.
while deletion at the nth node is too working well
—————————-
revision 1.7
date: 2014/02/28 13:49:08; author: saurabh; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.6
date: 2014/02/28 13:46:44; author: saurabh; state: Exp; lines: +1 -1
problem in function insert at nth solved .
—————————-
revision 1.5
date: 2014/02/28 13:42:50; author: saurabh; state: Exp; lines: +33 -15
function called sort_ has been implemented in program .
but there are some problem in function “insert_nth”.
will solve later on
—————————-
revision 1.4
date: 2014/02/27 20:03:10; author: saurabh; state: Exp; lines: +26 -2
sorting not working :(
—————————-
revision 1.3
date: 2014/02/27 19:10:54; author: saurabh; state: Exp; lines: +19 -3
implemented function called deletition from end .
:)
—————————-
revision 1.2
date: 2014/02/27 18:17:33; author: saurabh; state: Exp; lines: +159 -30
created function called insertion at the end
created function insertion at the nth node
created function deletion
implemented all above function the are working well
implemented deletion from begining node using function
implemented deletion from the nth node successflly
prior to all such functions ,defined display function too .
:)
—————————-
revision 1.1
date: 2014/02/24 21:09:57; author: saurabh; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Tagged , , , , | Leave a comment

module code to show how to initialize a cdev data structure with cdev_init() and tell the kernel about it with cdev_add().

RCS file: header.h,v
Working file: header.h
head: 1.16
branch:
locks: strict
root: 1.16
access list:
symbolic names:
keyword substitution: kv
total revisions: 16;    selected revisions: 16
description:
Base header file that includes the definitions of all the macros,structures and contains the necessary header files required by the module code.
—————————-
revision 1.16    locked by: root;
date: 2014/02/28 17:13:48;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/types.h> is added to support dev_t type.
—————————-
revision 1.15
date: 2014/02/28 16:58:15;  author: root;  state: Exp;  lines: +6 -0
Two macros are defined called MAJOR_NO and MINOR_NO.
—————————-
revision 1.14
date: 2014/02/28 15:44:56;  author: root;  state: Exp;  lines: +2 -2
The macro DEVICE_NAME is changed to DRIVER_NAME and the header file:<string.h> is removed.
—————————-
revision 1.13
date: 2014/02/28 15:41:31;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/cdev.h> is added to support a cdev structure.The cdev structure is used to register the driver with the kernel.
—————————-
revision 1.12
date: 2014/02/28 15:33:59;  author: root;  state: Exp;  lines: +1 -0
Header file:<string.h> is added to support memset() function.
—————————-
revision 1.11
date: 2014/02/28 15:18:15;  author: root;  state: Exp;  lines: +16 -0
Four macros are defined namely:DEVICE_SIZE , DATA_SIZE , QUANTUM and QSET.
These macros are used to initialize the fields inside the Scull_Dev structure.
—————————-
revision 1.10
date: 2014/02/28 15:10:35;  author: root;  state: Exp;  lines: +16 -0
Two structures are defined of type Sculldev and Scullqset.Sculldev is a structure that is used to hold device information.Scullqset is a structure that holds a pointer to the qset array and another pointer to a structure of Scullqset type.
—————————-
revision 1.9
date: 2014/02/27 21:07:42;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/slab.h> is added to support kmalloc() and kfree() functions.
—————————-
revision 1.8
date: 2014/02/27 20:02:53;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/moduleparam.h> is added to support the module_param() macro.With the help of this macro parameters can be passed to a module while loading it.
—————————-
revision 1.7
date: 2014/02/27 19:28:38;  author: root;  state: Exp;  lines: +4 -0
A macro called DEVICE_NAME is defined using #define.
—————————-
revision 1.6
date: 2014/02/27 19:20:01;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/fs.h> is added to the base header file to support various functions like alloc_chrdev_region(),unregister_chrdev_region(),etc.
—————————-
revision 1.5
date: 2014/02/27 18:44:36;  author: root;  state: Exp;  lines: +4 -0
A macro called DEBUG is defined using #define.
—————————-
revision 1.4
date: 2014/02/27 18:41:13;  author: root;  state: Exp;  lines: +2 -0
A special macro called MODULE_LICENSE is used to tell the kernel that the module bears a free license without such a decleration the kernel complains.
—————————-
revision 1.3
date: 2014/02/27 18:38:11;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/module.h> is added to the base header file to provide support for a great many number of macros like:MODULE_LICENSE , MODULE_AUTHOR,etc.
—————————-
revision 1.2
date: 2014/02/27 18:36:07;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/init.h> is added to the base header file to provide support for module_init() and module_exit() macros.
—————————-
revision 1.1
date: 2014/02/27 18:35:18;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: initial.c,v
Working file: initial.c
head: 1.12
branch:
locks: strict
root: 1.12
access list:
symbolic names:
keyword substitution: kv
total revisions: 12;    selected revisions: 12
description:
File containing the module’s initialization function that is called at module insertion time.
—————————-
revision 1.12    locked by: root;
date: 2014/02/28 17:59:59;  author: root;  state: Exp;  lines: +1 -0
Header file:”file_opr.h” is added to include the file_operations structure.The file_operations structure is used to access the driver’s functions.
—————————-
revision 1.11
date: 2014/02/28 17:49:26;  author: root;  state: Exp;  lines: +15 -4
After a device number range has been obtained,the device needs to be activated by adding it to the character device database.This requires initializing an instance of cdev_init() followed by a call to cdev_add().cdev_add() tells te kernel about the cdev data structure.
—————————-
revision 1.10
date: 2014/02/28 17:16:31;  author: root;  state: Exp;  lines: +16 -0
Both the major and minor numbers are initialized to 0 inside the initialize_parameters() function.Macros like MAJOR() and MINOR() are used to extract the major and minor number from dev type variable.Another macro called MKDEV is used to create the device number.
Checking……
—————————-
revision 1.9
date: 2014/02/28 16:50:22;  author: root;  state: Exp;  lines: +25 -0
From the initialization function,another function is called to initialize the parameters such as device size, quantum_size ,qset_size and data_size.

Status:The parameters are initialized successfully.
Now before the kernel calls the device’s operations,a cdev structure must be initialized with cdev_init() and the kernel is being told about the initialization with cdev_add().Implementing this task….
—————————-
revision 1.8
date: 2014/02/28 15:46:09;  author: root;  state: Exp;  lines: +1 -1
Inside the alloc_chrdev_region(),the fourth argument is changed from DEVICE_NAME to DRIVER_NAME.
—————————-
revision 1.7
date: 2014/02/28 15:32:31;  author: root;  state: Exp;  lines: +1 -0
memset() is used to fill the memory allocated using kmalloc() function with ”.
—————————-
revision 1.6
date: 2014/02/28 15:26:38;  author: root;  state: Exp;  lines: +12 -1
kmalloc() function is used to allocate memory.kmalloc() function takes two arguments:
1.size ,and
2.set of flags.
On success,kmalloc returns a pointer to the allocated memory otherwise it returns NULL.
In the flag field,GFP_KERNEL is used.
—————————-
revision 1.5
date: 2014/02/27 20:12:29;  author: root;  state: Exp;  lines: +7 -1
module_param() macro is used.With the help of this macro parameters can be passed to the module while loading it,when using “insmod”.
module_param() macro takes three arguments:
1.The name of the variable,
2.The type of the variable,
3.Permissions.
—————————-
revision 1.4
date: 2014/02/27 19:58:09;  author: root;  state: Exp;  lines: +1 -1
alloc_chrdev_region() function is used to allocate dynamically a major number.On success,the first parameter of this function stores the first device number.
—————————-
revision 1.3
date: 2014/02/27 19:31:39;  author: root;  state: Exp;  lines: +11 -0
Header file: “decleration.h” is added to include all the variable declerations.
—————————-
revision 1.2
date: 2014/02/27 18:50:37;  author: root;  state: Exp;  lines: +7 -0
module_init() macro is used to define which function is called during module’s insertion time.
__init token hints to the kernel that the function is used only at the initialization time.
The function specified by the module_init() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:49:06;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.6
branch:
locks: strict
root: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
File that contains the cleanup function which returns all the resources back to the system.
—————————-
revision 1.6    locked by: root;
date: 2014/02/28 15:35:01;  author: root;  state: Exp;  lines: +1 -0
kfree() function is used for freeing the memory.
—————————-
revision 1.5
date: 2014/02/27 20:15:39;  author: root;  state: Exp;  lines: +3 -1
A variable of type int representing the number of devices is included here using extern.
—————————-
revision 1.4
date: 2014/02/27 19:36:03;  author: root;  state: Exp;  lines: +1 -0
A variable dev of type dev_t storing the device number is included here using extern.
—————————-
revision 1.3
date: 2014/02/27 19:33:49;  author: root;  state: Exp;  lines: +3 -1
Called unregister_chrdev_region() which is having 2 arguments: device number and the total number of device numbers to unregister.
—————————-
revision 1.2
date: 2014/02/27 18:58:02;  author: root;  state: Exp;  lines: +14 -0
module_exit() macro is used to define which function is to be called at module removal time.\
The function specified by the module_exit() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:55:42;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: decleration.h,v
Working file: decleration.h
head: 1.6
branch:
locks: strict
root: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
All the variable declerations are done inside this header file.
—————————-
revision 1.6    locked by: root;
date: 2014/02/28 17:05:32;  author: root;  state: Exp;  lines: +1 -0
A variable of type dev_t is declared that is used to store the updated device number obtained from mkdev.
—————————-
revision 1.5
date: 2014/02/28 16:59:40;  author: root;  state: Exp;  lines: +3 -0
Two variables are declared inside this file that will hold the information about major and minor numbers.
—————————-
revision 1.4
date: 2014/02/28 16:39:07;  author: root;  state: Exp;  lines: +4 -0
Variables quantum_size,qset_size,data_size and device_size are declared that will get initialized by the macros defined in header.h.
—————————-
revision 1.3
date: 2014/02/28 15:30:46;  author: root;  state: Exp;  lines: +1 -0
A variable of type Sculldev is declared in this file.
—————————-
revision 1.2
date: 2014/02/27 20:06:26;  author: root;  state: Exp;  lines: +1 -0
A variable of type int is declared representing the number of devices.
—————————-
revision 1.1
date: 2014/02/27 19:30:54;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Character Driver, Device Drivers | Leave a comment

Module code to show how to allocate and deallocate memory using kmalloc() and kfree() functions for Sculldev (i.e the data structure used to hold device information)respectively.

RCS file: header.h,v
Working file: header.h
head: 1.14
branch:
locks: strict
root: 1.14
access list:
symbolic names:
keyword substitution: kv
total revisions: 14;    selected revisions: 14
description:
Base header file that includes the definitions of all the macros,structures and contains the necessary header files required by the module code.
—————————-
revision 1.14    locked by: root;
date: 2014/02/28 15:44:56;  author: root;  state: Exp;  lines: +2 -2
The macro DEVICE_NAME is changed to DRIVER_NAME and the header file:<string.h> is removed.
—————————-
revision 1.13
date: 2014/02/28 15:41:31;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/cdev.h> is added to support a cdev structure.The cdev structure is used to register the driver with the kernel.
—————————-
revision 1.12
date: 2014/02/28 15:33:59;  author: root;  state: Exp;  lines: +1 -0
Header file:<string.h> is added to support memset() function.
—————————-
revision 1.11
date: 2014/02/28 15:18:15;  author: root;  state: Exp;  lines: +16 -0
Four macros are defined namely:DEVICE_SIZE , DATA_SIZE , QUANTUM and QSET.
These macros are used to initialize the fields inside the Scull_Dev structure.
—————————-
revision 1.10
date: 2014/02/28 15:10:35;  author: root;  state: Exp;  lines: +16 -0
Two structures are defined of type Sculldev and Scullqset.Sculldev is a structure that is used to hold device information.Scullqset is a structure that holds a pointer to the qset array and another pointer to a structure of Scullqset type.
—————————-
revision 1.9
date: 2014/02/27 21:07:42;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/slab.h> is added to support kmalloc() and kfree() functions.
—————————-
revision 1.8
date: 2014/02/27 20:02:53;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/moduleparam.h> is added to support the module_param() macro.With the help of this macro parameters can be passed to a module while loading it.
—————————-
revision 1.7
date: 2014/02/27 19:28:38;  author: root;  state: Exp;  lines: +4 -0
A macro called DEVICE_NAME is defined using #define.
—————————-
revision 1.6
date: 2014/02/27 19:20:01;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/fs.h> is added to the base header file to support various functions like alloc_chrdev_region(),unregister_chrdev_region(),etc.
—————————-
revision 1.5
date: 2014/02/27 18:44:36;  author: root;  state: Exp;  lines: +4 -0
A macro called DEBUG is defined using #define.
—————————-
revision 1.4
date: 2014/02/27 18:41:13;  author: root;  state: Exp;  lines: +2 -0
A special macro called MODULE_LICENSE is used to tell the kernel that the module bears a free license without such a decleration the kernel complains.
—————————-
revision 1.3
date: 2014/02/27 18:38:11;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/module.h> is added to the base header file to provide support for a great many number of macros like:MODULE_LICENSE , MODULE_AUTHOR,etc.
—————————-
revision 1.2
date: 2014/02/27 18:36:07;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/init.h> is added to the base header file to provide support for module_init() and module_exit() macros.
—————————-
revision 1.1
date: 2014/02/27 18:35:18;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: initial.c,v
Working file: initial.c
head: 1.8
branch:
locks: strict
root: 1.8
access list:
symbolic names:
keyword substitution: kv
total revisions: 8;    selected revisions: 8
description:
File containing the module’s initialization function that is called at module insertion time.
—————————-
revision 1.8    locked by: root;
date: 2014/02/28 15:46:09;  author: root;  state: Exp;  lines: +1 -1
Inside the alloc_chrdev_region(),the fourth argument is changed from DEVICE_NAME to DRIVER_NAME.
—————————-
revision 1.7
date: 2014/02/28 15:32:31;  author: root;  state: Exp;  lines: +1 -0
memset() is used to fill the memory allocated using kmalloc() function with ”.
—————————-
revision 1.6
date: 2014/02/28 15:26:38;  author: root;  state: Exp;  lines: +12 -1
kmalloc() function is used to allocate memory.kmalloc() function takes two arguments:
1.size ,and
2.set of flags.
On success,kmalloc returns a pointer to the allocated memory otherwise it returns NULL.
In the flag field,GFP_KERNEL is used.
—————————-
revision 1.5
date: 2014/02/27 20:12:29;  author: root;  state: Exp;  lines: +7 -1
module_param() macro is used.With the help of this macro parameters can be passed to the module while loading it,when using “insmod”.
module_param() macro takes three arguments:
1.The name of the variable,
2.The type of the variable,
3.Permissions.
—————————-
revision 1.4
date: 2014/02/27 19:58:09;  author: root;  state: Exp;  lines: +1 -1
alloc_chrdev_region() function is used to allocate dynamically a major number.On success,the first parameter of this function stores the first device number.
—————————-
revision 1.3
date: 2014/02/27 19:31:39;  author: root;  state: Exp;  lines: +11 -0
Header file: “decleration.h” is added to include all the variable declerations.
—————————-
revision 1.2
date: 2014/02/27 18:50:37;  author: root;  state: Exp;  lines: +7 -0
module_init() macro is used to define which function is called during module’s insertion time.
__init token hints to the kernel that the function is used only at the initialization time.
The function specified by the module_init() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:49:06;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.6
branch:
locks: strict
root: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
File that contains the cleanup function which returns all the resources back to the system.
—————————-
revision 1.6    locked by: root;
date: 2014/02/28 15:35:01;  author: root;  state: Exp;  lines: +1 -0
kfree() function is used for freeing the memory.
—————————-
revision 1.5
date: 2014/02/27 20:15:39;  author: root;  state: Exp;  lines: +3 -1
A variable of type int representing the number of devices is included here using extern.
—————————-
revision 1.4
date: 2014/02/27 19:36:03;  author: root;  state: Exp;  lines: +1 -0
A variable dev of type dev_t storing the device number is included here using extern.
—————————-
revision 1.3
date: 2014/02/27 19:33:49;  author: root;  state: Exp;  lines: +3 -1
Called unregister_chrdev_region() which is having 2 arguments: device number and the total number of device numbers to unregister.
—————————-
revision 1.2
date: 2014/02/27 18:58:02;  author: root;  state: Exp;  lines: +14 -0
module_exit() macro is used to define which function is to be called at module removal time.\
The function specified by the module_exit() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:55:42;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: decleration.h,v
Working file: decleration.h
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
All the variable declerations are done inside this header file.
—————————-
revision 1.3    locked by: root;
date: 2014/02/28 15:30:46;  author: root;  state: Exp;  lines: +1 -0
A variable of type Sculldev is declared in this file.
—————————-
revision 1.2
date: 2014/02/27 20:06:26;  author: root;  state: Exp;  lines: +1 -0
A variable of type int is declared representing the number of devices.
—————————-
revision 1.1
date: 2014/02/27 19:30:54;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Character Driver, Device Drivers | Leave a comment

project-1 multiple data compression & encryption using iterative techniques.

RCS file: fun.c,v
Working file: fun.c
head: 1.9
branch:
locks: strict
saurabh: 1.9
access list:
symbolic names:
keyword substitution: kv
total revisions: 9;     selected revisions: 9
description:
this is updated file of fun.c of project 1 dir.
here master array is passed in every fnction instead of declaring globally
which could create protection problem.
—————————-
revision 1.9    locked by: saurabh;
date: 2014/02/27 20:06:16;  author: saurabh;  state: Exp;  lines: +3 -1
updated
—————————-
revision 1.8
date: 2014/02/26 21:47:06;  author: saurabh;  state: Exp;  lines: +10 -6
updated ,errors solved :)
—————————-
revision 1.7
date: 2014/02/26 15:09:06;  author: saurabh;  state: Exp;  lines: +14 -55
updated
:)
but not working well :/
—————————-
revision 1.6
date: 2014/02/26 14:06:59;  author: saurabh;  state: Exp;  lines: +6 -7
error
—————————-
but not working well :/
—————————-
revision 1.6
date: 2014/02/26 14:06:59;  author: saurabh;  state: Exp;  lines: +6 -7
error

—————————-
revision 1.5
date: 2014/02/26 12:53:27;  author: saurabh;  state: Exp;  lines: +58 -4
created a decompressed function
where the file is decrypted back to orignal file using decompression_key addition to encryption_key
:)
—————————-
revision 1.4
date: 2014/02/26 09:49:56;  author: saurabh;  state: Exp;  lines: +12 -3
logical fault solved
previously marray ws compressed
but actually we want to compressed whole text file
so that it cud be retrieve easily
:)
—————————-
revision 1.3
date: 2014/02/26 06:38:48;  author: saurabh;  state: Exp;  lines: +20 -0
created a function encryption_ky
holding a file consisting a master array.
—————————-
revision 1.2
date: 2014/02/24 16:59:13;  author: saurabh;  state: Exp;  lines: +6 -14
warning issue solved
updated some other display issues.
—————————-
revision 1.1
date: 2014/02/24 16:41:32;  author: saurabh;  state: Exp;
Initial revision
=============================================================================
62,17         Bot
10,14         Top

Posted in Uncategorized | Leave a comment

Module code to show how parameters can be passed to a module while loading it with the help of macro called module_param().

RCS file: header.h,v
Working file: header.h
head: 1.8
branch:
locks: strict
root: 1.8
access list:
symbolic names:
keyword substitution: kv
total revisions: 8;    selected revisions: 8
description:
Base header file that includes the definitions of all the macros,structures and contains the necessary header files required by the module code.
—————————-
revision 1.8    locked by: root;
date: 2014/02/27 20:02:53;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/moduleparam.h> is added to support the module_param() macro.With the help of this macro parameters can be passed to a module while loading it.
—————————-
revision 1.7
date: 2014/02/27 19:28:38;  author: root;  state: Exp;  lines: +4 -0
A macro called DEVICE_NAME is defined using #define.
—————————-
revision 1.6
date: 2014/02/27 19:20:01;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/fs.h> is added to the base header file to support various functions like alloc_chrdev_region(),unregister_chrdev_region(),etc.
—————————-
revision 1.5
date: 2014/02/27 18:44:36;  author: root;  state: Exp;  lines: +4 -0
A macro called DEBUG is defined using #define.
—————————-
revision 1.4
date: 2014/02/27 18:41:13;  author: root;  state: Exp;  lines: +2 -0
A special macro called MODULE_LICENSE is used to tell the kernel that the module bears a free license without such a decleration the kernel complains.
—————————-
revision 1.3
date: 2014/02/27 18:38:11;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/module.h> is added to the base header file to provide support for a great many number of macros like:MODULE_LICENSE , MODULE_AUTHOR,etc.
—————————-
revision 1.2
date: 2014/02/27 18:36:07;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/init.h> is added to the base header file to provide support for module_init() and module_exit() macros.
—————————-
revision 1.1
date: 2014/02/27 18:35:18;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: initial.c,v
Working file: initial.c
head: 1.5
branch:
locks: strict
root: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;    selected revisions: 5
description:
File containing the module’s initialization function that is called at module insertion time.
—————————-
revision 1.5    locked by: root;
date: 2014/02/27 20:12:29;  author: root;  state: Exp;  lines: +7 -1
module_param() macro is used.With the help of this macro parameters can be passed to the module while loading it,when using “insmod”.
module_param() macro takes three arguments:
1.The name of the variable,
2.The type of the variable,
3.Permissions.
—————————-
revision 1.4
date: 2014/02/27 19:58:09;  author: root;  state: Exp;  lines: +1 -1
alloc_chrdev_region() function is used to allocate dynamically a major number.On success,the first parameter of this function stores the first device number.
—————————-
revision 1.3
date: 2014/02/27 19:31:39;  author: root;  state: Exp;  lines: +11 -0
Header file: “decleration.h” is added to include all the variable declerations.
—————————-
revision 1.2
date: 2014/02/27 18:50:37;  author: root;  state: Exp;  lines: +7 -0
module_init() macro is used to define which function is called during module’s insertion time.
__init token hints to the kernel that the function is used only at the initialization time.
The function specified by the module_init() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:49:06;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.5
branch:
locks: strict
root: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;    selected revisions: 5
description:
File that contains the cleanup function which returns all the resources back to the system.
—————————-
revision 1.5    locked by: root;
date: 2014/02/27 20:15:39;  author: root;  state: Exp;  lines: +3 -1
A variable of type int representing the number of devices is included here using extern.
—————————-
revision 1.4
date: 2014/02/27 19:36:03;  author: root;  state: Exp;  lines: +1 -0
A variable dev of type dev_t storing the device number is included here using extern.
—————————-
revision 1.3
date: 2014/02/27 19:33:49;  author: root;  state: Exp;  lines: +3 -1
Called unregister_chrdev_region() which is having 2 arguments: device number and the total number of device numbers to unregister.
—————————-
revision 1.2
date: 2014/02/27 18:58:02;  author: root;  state: Exp;  lines: +14 -0
module_exit() macro is used to define which function is to be called at module removal time.\
The function specified by the module_exit() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:55:42;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: decleration.h,v
Working file: decleration.h
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
All the variable declerations are done inside this header file.
—————————-
revision 1.2    locked by: root;
date: 2014/02/27 20:06:26;  author: root;  state: Exp;  lines: +1 -0
A variable of type int is declared representing the number of devices.
—————————-
revision 1.1
date: 2014/02/27 19:30:54;  author: root;  state: Exp;
Initial revision
=============================================================================

 

Posted in Character Driver, Device Drivers | Leave a comment

Module code to show how device numbers are allocated and deallocated using alloc_chrdev_region() and unregister_chrdev_region().

RCS file: header.h,v
Working file: header.h
head: 1.7
branch:
locks: strict
root: 1.7
access list:
symbolic names:
keyword substitution: kv
total revisions: 7;    selected revisions: 7
description:
Base header file that includes the definitions of all the macros,structures and contains the necessary header files required by the module code.
—————————-
revision 1.7    locked by: root;
date: 2014/02/27 19:28:38;  author: root;  state: Exp;  lines: +4 -0
A macro called DEVICE_NAME is defined using #define.
—————————-
revision 1.6
date: 2014/02/27 19:20:01;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/fs.h> is added to the base header file to support various functions like alloc_chrdev_region(),unregister_chrdev_region(),etc.
—————————-
revision 1.5
date: 2014/02/27 18:44:36;  author: root;  state: Exp;  lines: +4 -0
A macro called DEBUG is defined using #define.
—————————-
revision 1.4
date: 2014/02/27 18:41:13;  author: root;  state: Exp;  lines: +2 -0
A special macro called MODULE_LICENSE is used to tell the kernel that the module bears a free license without such a decleration the kernel complains.
—————————-
revision 1.3
date: 2014/02/27 18:38:11;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/module.h> is added to the base header file to provide support for a great many number of macros like:MODULE_LICENSE , MODULE_AUTHOR,etc.
—————————-
revision 1.2
date: 2014/02/27 18:36:07;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/init.h> is added to the base header file to provide support for module_init() and module_exit() macros.
—————————-
revision 1.1
date: 2014/02/27 18:35:18;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: initial.c,v
Working file: initial.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;    selected revisions: 4
description:
File containing the module’s initialization function that is called at module insertion time.
—————————-
revision 1.4    locked by: root;
date: 2014/02/28 00:49:11;  author: root;  state: Exp;  lines: +1 -1
alloc_chrdev_region() function is used to allocate dynamically a major number.On success the first device number is stored inside the first argument of this function.
—————————-
revision 1.3
date: 2014/02/27 19:31:39;  author: root;  state: Exp;  lines: +11 -0
Header file: “decleration.h” is added to include all the variable declerations.
—————————-
revision 1.2
date: 2014/02/27 18:50:37;  author: root;  state: Exp;  lines: +7 -0
module_init() macro is used to define which function is called during module’s insertion time.
__init token hints to the kernel that the function is used only at the initialization time.
The function specified by the module_init() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:49:06;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;    selected revisions: 4
description:
File that contains the cleanup function which returns all the resources back to the system.
—————————-
revision 1.4    locked by: root;
date: 2014/02/27 19:36:03;  author: root;  state: Exp;  lines: +1 -0
A variable dev of type dev_t storing the device number is included here using extern.
—————————-
revision 1.3
date: 2014/02/27 19:33:49;  author: root;  state: Exp;  lines: +3 -1
Called unregister_chrdev_region() which is having 2 arguments: device number and the total number of device numbers to unregister.
—————————-
revision 1.2
date: 2014/02/27 18:58:02;  author: root;  state: Exp;  lines: +14 -0
module_exit() macro is used to define which function is to be called at module removal time.\
The function specified by the module_exit() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:55:42;  author: root;  state: Exp;
Initial revision
=============================================================================

 

 

Posted in Character Driver, Device Drivers | Leave a comment

Decompression

I have completed data decompression with functions and get the actual data back from the compress file.

Posted in Uncategorized | Leave a comment

Completed data compression with making functions.

1 head 1.20;
2 access;
3 symbols;
4 locks
5 root:1.20; strict;
6 comment @ * @;
7
8
9 1.20
10 date 2014.02.24.18.01.15; author root; state Exp;
11 branches;
12 next 1.19;
13
14 1.19
15 date 2014.02.24.08.37.55; author root; state Exp;
16 branches;
17 next 1.18;
18
19 1.18
20 date 2014.02.23.07.20.48; author root; state Exp;
21 branches;
22 next 1.17;
23
24 1.17
25 date 2014.02.23.05.49.36; author root; state Exp;
26 branches;
27 next 1.16;
28
29 1.16
30 date 2014.02.23.05.14.59; author root; state Exp;
31 branches;
32 next 1.15;
33
34 1.15
35 date 2014.02.22.17.49.40; author root; state Exp;
36 branches;
37 next 1.14;
38
39 1.14
40 date 2014.02.22.17.26.29; author root; state Exp;
41 branches;
42 next 1.13;
43
44 1.13
45 date 2014.02.22.16.59.20; author root; state Exp;
46 branches;
47 next 1.12;
48
49 1.12
50 date 2014.02.22.04.00.20; author root; state Exp;
51 branches;
52 next 1.11;
53
54 1.11
55 date 2014.02.22.03.58.34; author root; state Exp;
56 branches;
57 next 1.10;
58
59 1.10
60 date 2014.02.22.03.03.06; author root; state Exp;
61 branches;
62 next 1.9;
63
64 1.9
65 date 2014.02.22.03.01.51; author root; state Exp;
66 branches;
67 next 1.8;
68
69 1.8
70 date 2014.02.22.02.58.57; author root; state Exp;
71 branches;
72 next 1.7;
73
74 1.7
75 date 2014.02.22.02.57.32; author root; state Exp;
76 branches;
77 next 1.6;
78
79 1.6
80 date 2014.02.22.02.56.24; author root; state Exp;
81 branches;
82 next 1.5;
83
84 1.5
85 date 2014.02.22.02.18.04; author root; state Exp;
86 branches;
87 next 1.4;
88
89 1.4
90 date 2014.02.22.02.16.24; author root; state Exp;
91 branches;
92 next 1.3;
93
94 1.3
95 date 2014.02.21.04.10.42; author root; state Exp;
96 branches;
97 next 1.2;
98
99 1.2
100 date 2014.02.21.03.35.59; author root; state Exp;
101 branches;
102 next 1.1;
103
104 1.1
105 date 2014.02.21.03.23.49; author root; state Exp;
106 branches;
107 next ;
108
109
110 desc

Posted in Uncategorized | Leave a comment

multiple data compression-decompression 4-bit

RCS file: ./mdcaeuit.c,v
Working file: ./mdcaeuit.c
head: 1.17
branch:
locks: strict
root: 1.17
access list:
logins
symbolic names:
keyword substitution: kv
total revisions: 17;    selected revisions: 17
description:
this is the initiated source file have to make ammendment
—————————-
revision 1.17    locked by: root;
date: 2014/02/26 17:58:27;  author: root;  state: Exp;  lines: +12 -12
code working fine with codelength of 4-bit
completed 4-bit compression and decompression
—————————-
revision 1.16
date: 2014/02/22 18:36:03;  author: root;  state: Exp;  lines: +33 -13
logic correction
—————————-
revision 1.15
date: 2014/02/13 07:33:42;  author: root;  state: Exp;  lines: +2 -3
decompression started
decompression function introduced in the program
—————————-
revision 1.14
date: 2014/02/11 18:31:52;  author: root;  state: Exp;  lines: +2 -3
compress_data function made
—————————-
revision 1.13
date: 2014/02/11 14:29:21;  author: root;  state: Exp;  lines: +4 -2
trobleshooting missed my file ie funct.h
—————————-
revision 1.12
date: 2014/02/11 14:05:49;  author: root;  state: Exp;  lines: +2 -2
trobleshooting
—————————-
revision 1.11
date: 2014/02/11 10:02:19;  author: root;  state: Exp;  lines: +11 -6
insert compress_4bit function to compress the dat
we need fd,codel and ndc for this fuction at the time of calling in the main function
to make this function to implement we need to find the index first
—————————-
revision 1.10
date: 2014/02/11 09:04:48;  author: root;  state: Exp;  lines: +4 -3
implement code_length function in function.h and implement the same in main
variable is codel
—————————-
revision 1.9
date: 2014/02/10 20:27:37;  author: root;  state: Exp;  lines: +5 -4
insert the distinct character string using functions
functions :distinct_characters(int,int),marray_create(int)
display() and opening(char*,int)
—————————-
revision 1.8
date: 2014/02/07 17:47:19;  author: root;  state: Exp;  lines: +7 -75
coming to enclose data in function
make marray_create(),opening() and display()
—————————-
revision 1.7
date: 2014/02/07 06:49:21;  author: root;  state: Exp;  lines: +11 -14
logical correction
—————————-
revision 1.6
date: 2014/02/05 16:32:43;  author: root;  state: Exp;  lines: +15 -3
add index and character array to get the array back
—————————-
revision 1.5
date: 2014/02/05 11:00:03;  author: root;  state: Exp;  lines: +2 -2
extra spaces in masterarray removed..
error:remove count and insert i
—————————-
revision 1.4
date: 2014/02/05 10:46:30;  author: root;  state: Exp;  lines: +15 -9
compress data in test.file
adding for loop,for checking whether the string contain repeated characters
display compress string in array.
—————————-
revision 1.3
date: 2014/02/05 09:38:02;  author: root;  state: Exp;  lines: +6 -5
use dynamic memmory allotation of masterarray
getting fine result
—————————-
revision 1.2
date: 2014/02/05 08:35:29;  author: root;  state: Exp;  lines: +26 -10
enterred commandline arguments
remove space at the end of the string
using if else in do while loop
—————————-
revision 1.1
date: 2014/01/20 08:02:46;  author: rahul;  state: Exp;
Initial revision
=============================================================================

Posted in Project 2: Multiple Data Compression and Encryption | Leave a comment

A FTP, client-server and networking based Project

PROJECT TITLE :

FTP based Client Server project using sockets and threads:

Abstract:
File Transfer Protocol is a standard network protocol used to transfer files from one host to another host over a TCP based network such as internet. This protocol can be used to upload or download files form one host to another. This protocol is based on cilent-server architecture and may use different control and data connections between the client and the server.
I tried to implement FTP to transfer files within and over the network(using internet) using C language.

Architecture:
There may be a server running and waiting for clients to log in(initiate communication). Once any client approaches the server to upload a file, it waits in a queue untill server accepts its request. The server may ask the client to login before further processing its request. Also the server may ask few times for correct password and failing to get that server may refuse to connect to that client.

Implementation:

SERVER-SIDE:
1. I implemented server and used socket() system call to make a socket on the server side.
This call makes a socket in the namespace(address family) but it has no address is assigned to it.
And it also provides mechanisms to communicate with network layer.
2. Then i named that socket using bind() system call.
This system call assignes the address specified by one of its arguments to the socket referred to by
file_descriptor returned by socket().
3. Then i used listen() system call, which implements a listening queue to take requests from various clients to be processed by the server.
4. Finally i used accept() system call to take requests from listening queue and implemented authentication functionality to provide access to the clients.
5. If clients enters correct credentials if may proceed to upload a file.
6. After getting the file server may proceed to handle another request from listening queue.

NOTE: I used accept() in a ‘forever’ loop so that server may be running all the time.
Once the client is successfully logged-in i implemented POSIX threads to take the any number of files(tested for 1000 files) fron that specific client.

CLIENT-SIDE:
1. I implemented client and used socket() system call to make a socket on the client side.
2. Then, i used connect() system call to send request to the server.
3. Now when server is ready to accept the request then client is promped to enter its details along with passwords.
4. Once the authentication is successfully done then client may send any number of files to the server in one go.
5. After successfully sending file client may terminate or re-request the server to send more files.

The above algorithm was implemented and tested using AF_INET (address family) to transfer file within a private network.
File can also be sent over the internet using the above algorithm but for that we may need to acquire the public ip address assigned to us.
Another method is to use a technique referred to as “PORT FORWARDING“.
This technique is only to be used at server’s side and it requires us to configure our router so that it may direct the incomming packets for a particular port address on server’s ip address.

Future scope:
If we are not allowed to change router’s configuration then we can establish a VPN, which is used to directly communicate with a particular machine without even going through the router associated with that machine.

Thank You
HARPREET SINGH
ece.harpreetsingh@gmail.com

Posted in Project 04: FTP based Client Server using Threads and Sockets | Leave a comment

LINKLIST-creation,insertion,deletion,sorting

RCS file: ./practicesession.c,v
Working file: ./practicesession.c
head: 1.13
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 13;    selected revisions: 13
description:
this is the initial file that contain 2 function create_linklist,create_node() and 1 structure named node
we are calling the create_linklist() in main
yet to compile just saving the rcs file
—————————-
revision 1.13
date: 2014/02/26 17:24:16;  author: root;  state: Exp;  lines: +11 -3
fully tested on all the menu items
Tested ok!!!
—————————-
revision 1.12
date: 2014/02/26 16:49:43;  author: root;  state: Exp;  lines: +39 -24
introduce sorting of linklist at case 5
menu is press 1 for creating linklist
press2 for insertion at end,begining and nth node
press3 for deleting at the nth node entered by user
press4 for display of link list
press5 for sorting the linkilist in assending order
code working fine!
—————————-
revision 1.11
date: 2014/02/24 09:39:11;  author: root;  state: Exp;  lines: +36 -1
insert case for sorting function for the sorting of linklist
error:logistic problem
—————————-
revision 1.10
date: 2014/02/24 05:43:13;  author: root;  state: Exp;  lines: +17 -10
added case 3 to delete a node from the enterred linklist .
user given option to enter node to delete and we have to go to a point 1 less than the node to be deleted and then adding logic to delete and
after that call case 4 to display the orinal node.
—————————-
revision 1.9
date: 2014/02/23 18:50:45;  author: root;  state: Exp;  lines: +24 -9
enterred the function for inserting node at a particular location,beggining and end
heading towards function to delete a node
—————————-
revision 1.8
date: 2014/02/23 17:47:33;  author: root;  state: Exp;  lines: +43 -13
enterred display function and insert function with menu
1.link at the end,end at the beggining of the link list
code working fine at this stage.
—————————-
revision 1.7
date: 2014/02/23 16:19:52;  author: root;  state: Exp;  lines: +84 -30
included display function in the menu at no.4location and display the value of info for each link
—————————-
revision 1.6
date: 2014/02/23 08:02:12;  author: root;  state: Exp;  lines: +25 -15
malloc failed condition includded in the create node and create linklist function
—————————-
revision 1.5
date: 2014/02/22 18:30:08;  author: root;  state: Exp;  lines: +9 -7
initialize one more pointer *hello instance of struct node and call it in create_linklist(hello),
it will create structure space and we are putting the address of hello in start->next and printf the address of meemory alloted by hello
—————————-
revision 1.4
date: 2014/02/22 18:22:26;  author: root;  state: Exp;  lines: +9 -5
a new structure pointer to struct node is defined and pass the hello pointer to create_linklist,
so the memory is alloted and hence create a new node
—————————-
revision 1.3
date: 2014/02/22 18:15:46;  author: root;  state: Exp;  lines: +21 -21
passing pointer of structure from mainto the create_linklist and alloting memory each time we pass a structure pointer from the main,we just have to pass the structure pointer to create_linklist the memory is alloted
—————————-
revision 1.2
date: 2014/02/22 17:55:23;  author: root;  state: Exp;  lines: +33 -22
included menu in the program in main 1:create linklist 2:insert 3:..and so on
enter 1 for creating linklist
if flag==0 then printing create linklist
—————————-
revision 1.1
date: 2014/02/22 17:25:42;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Data Structures with C | Leave a comment

Simplest driver module code to understand the macros module_init() and module_exit().

RCS file: header.h,v
Working file: header.h
head: 1.5
branch:
locks: strict
root: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;    selected revisions: 5
description:
Base header file that includes the definitions of all the macros,structure definitions and necessary header files.
—————————-
revision 1.5    locked by: root;
date: 2014/02/27 02:44:48;  author: root;  state: Exp;  lines: +4 -0
A special macro called DEBUG is created using #define.
—————————-
revision 1.4
date: 2014/02/27 02:28:52;  author: root;  state: Exp;  lines: +2 -0
A special macro called MODULE_LICENSE is used to tell the kernel that the module bears a free license without such a decleration the kernel complains.
—————————-
revision 1.3
date: 2014/02/27 02:26:08;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/module.h> is added to support a great many number of macros like:MODULE_LICENSE , MODULE_AUTHOR .
..
—————————-
revision 1.2
date: 2014/02/27 02:20:56;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/init.h> is added to support module_init() and module_exit() macros that specifies the module’s initialization and cleanup functions.
—————————-
revision 1.1
date: 2014/02/27 02:18:53;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: initial.c,v
Working file: initial.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;    selected revisions: 4
description:
File that contains the module’s initialization function that is called at the module insertion time.
—————————-
revision 1.4    locked by: root;
date: 2014/02/27 02:57:43;  author: root;  state: Exp;  lines: +3 -1
Error during compilation.
Bug fixed.Issue:return statement is not included.
—————————-
revision 1.3
date: 2014/02/27 02:47:22;  author: root;  state: Exp;  lines: +7 -0
printk() is used to mark the beginning and end of the initialization function.printk() sends the messages to the kernel log.
—————————-
revision 1.2
date: 2014/02/27 02:36:50;  author: root;  state: Exp;  lines: +7 -0
module_init() macro is used to define which function is called during module’s insertion time.
initialization function is declared static because it is not meant to be visible outside the file.
__init token in the definition hints to the kernel that the given function is used only at the initialization time.
—————————-
revision 1.1
date: 2014/02/27 02:18:58;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
File that contains the module’s cleanup function which unregisters interfaces and returns all resources to the system before the module is removed.
—————————-
revision 1.2    locked by: root;
date: 2014/02/27 02:51:54;  author: root;  state: Exp;  lines: +13 -0
module_exit() macro is used to define which function to call during module unloading.
__exit() token hints to the kernel that the given function is used only during module unloading.
—————————-
revision 1.1
date: 2014/02/27 02:19:00;  author: root;  state: Exp;
Initial revision
=============================================================================

 

 

Posted in Character Driver | Leave a comment

Code for finding out the middle node in a single linked list in C language.

RCS file: middle_of_linked_list.c,v
Working file: middle_of_linked_list.c
head: 1.15
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 15;    selected revisions: 15
description:
Code to demonstrate how to find the middle of a linked list in C langauge.
—————————-
revision 1.15
date: 2014/02/27 00:23:55;  author: root;  state: Exp;  lines: +9 -1
Two conditions are added inside the while which will return the control to the calling function with the address of the middle node.

Status : The program is working absolutely fine for any number of nodes in a single linked list.
—————————-
revision 1.14
date: 2014/02/26 23:23:30;  author: root;  state: Exp;  lines: +10 -0
Status:Program is working correctly for an odd number of nodes inside the linked list.

Developing the code to find the middle of the linked list containing an even number of nodes inside the linked list.
—————————-
revision 1.13
date: 2014/02/26 22:53:31;  author: root;  state: Exp;  lines: +1 -1
Changed the prototype of the middle_of_list() function.Inside it an argument is passed that holds the address of the count variable.
—————————-
revision 1.12
date: 2014/02/26 22:50:22;  author: root;  state: Exp;  lines: +30 -3
Implemted the middle_of_list() function till 2 nodes in the linked list.
Checking…..
—————————-
revision 1.11
date: 2014/02/26 22:28:00;  author: root;  state: Exp;  lines: +10 -4
Prototype of the middle_of_list() function is declared and changed the prototype of the display_nodes() function to return the total number of nodes in the linked list.
Also called the middle_of_list() function from within the main() function.Implementing the body of the middle_of_list() function.
—————————-
revision 1.10
date: 2014/02/26 22:21:41;  author: root;  state: Exp;  lines: +2 -2
Till display_nodes() function,the program is working absolutely fine.Now implementing a function that finds the middle of the linked list.
—————————-
revision 1.9
date: 2014/02/26 21:09:52;  author: root;  state: Exp;  lines: +12 -2
Prototype of the display_nodes() function is declared.
Also gave definition of the display_nodes() function.
Checking….
—————————-
revision 1.8
date: 2014/02/26 21:01:33;  author: root;  state: Exp;  lines: +23 -1
create_node() function is called that creates a node at the end of the linked list.Its prototype is also declared.
Gave definition of the create_node() function.
—————————-
revision 1.7
date: 2014/02/26 20:56:19;  author: root;  state: Exp;  lines: +8 -0
Gave definition of the create_list() function.
—————————-
revision 1.6
date: 2014/02/26 20:53:19;  author: root;  state: Exp;  lines: +1 -0
Prototype of the create_list() function is declared.
—————————-
revision 1.5
date: 2014/02/26 20:50:42;  author: root;  state: Exp;  lines: +18 -2
A flag variable is declared.create_list() function is called that will create the linked list by creating a start node.After creating the start node the flag variable is set to 1 so that in case the user next time wishes to create the list,then a message is displayed that the linked list is created successfully.
—————————-
revision 1.4
date: 2014/02/26 20:38:17;  author: root;  state: Exp;  lines: +6 -1
A structure is defined of type struct node having two members:info and a pointer to the structure of type struct node.
—————————-
revision 1.3
date: 2014/02/20 02:36:03;  author: root;  state: Exp;  lines: +21 -0
Header file:<stdlib.h> is included to support exit() function.This function helps the user to terminate the program.
—————————-
revision 1.2
date: 2014/02/20 02:32:19;  author: root;  state: Exp;  lines: +12 -1
Prepared the MAIN MENU for the user,so that the operations can be selected by the user easily.
—————————-
revision 1.1
date: 2014/02/20 02:27:22;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Data Structures with C | Leave a comment

Character_device driver : Implemented upto write opertion.

I am implemented successfully write operation in multiple quantum in kernel space from user space .

Now i am implementing reading operation in user space from kernel space.

Posted in Uncategorized | Leave a comment