yesterday i was completed the scull and trimming and today i am working on the write operation in the character driver.
yesterday i was completed the scull and trimming and today i am working on the write operation in the character driver.
can anyone explain the output of
y>>=3; printf(“%d\n”y);
thanks
i have done initialization,registration,open,release,trim.
i have successfully implemented scull trimming .
scull_triming and maping of scull_write has been done
please write appropriate comment………………
//this function only remove last node of the scull_dev because it has not any reverencing function for deleting previous nodes till the fist node.
//sir has taken one previous pointer but it also deletes only one node that is just before the last node but we want to delete or free every node…….how it will done……
// if we uses the recursion till the first will not deleted………….
int trim(struct scull_dev *start)
{
int i;
if(start)
{ if(start->data)
{
while(start->data->next)
start->data=start->data->next;
if(start->data->data)
{
for(i=QSET;i>=0;i–)
{
start->data->data[i]=NULL;
}
start->data->data=NULL;
}
else
printk(KERN_INFO”\nThere is No Qset”);
}
else start->data=NULL;
printk(KERN_INFO “\n NO Qset available”);
}
else
printk(KERN_INFO “\n There Is No Scull_dev”);
return 0;
}
i have completed multiple data compression and Decompression using 4 bit
i have completed registration, initialization, open, release, and working on trim.
I have completed registration,initilazation and open,release in the character driver and now i am work out on the scull and decompression of a string.
Char device driver ->done
compression -> left with last part of comparing and uncompressed data
SCULL -> done for the scull size of 16 and limited data flow
Well, upto date with the char device driver module
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/stat.h>
//#include<fcntl.h>
//#include<unistd.h>
#include<string.h>
#define QSET 3 //size of the pointer array ,points to quantum.
#define QUANTUM 4 //size of quantum.
struct scull_dev
{
struct scull_qset *data; //points to scull qset
int qset; //qset size
int quantum; // quantum size
};
struct scull_qset // link list structure
{
struct scull_qset *next;
char **data;
};
int data(struct scull_dev*); //entering data.
void display(struct scull_dev*); // to display data.
int main()
{
struct scull_dev *link; //link list pointer
link=(struct scull_dev *)malloc(sizeof(struct scull_dev));
//....................scull data.......
data(link);
//.........distplay.....................
display(link);
return 0;
}
//.......entering into the 2D array .............
int data(struct scull_dev *start)
{ int i;
start->data=(struct scull_qset*)malloc(sizeof(struct scull_qset));
start->data->next=NULL;
start->data->data=malloc(sizeof(char)*QSET);
for(i=0;i<QSET;i++)
{
start->data->data[i]=malloc(sizeof(char)*QUANTUM);
start->data->data[i]="abcd";
} //quantum end
return 0;
}
//........display function.................
void display(struct scull_dev *start)
{
int i;
for(i=0;i<QSET;i++)
{
printf("\n%s", start->data->data[i]);
} //quantum end
}
#include <stdio.h>
int find_substr(char *listPointer, char *itemPointer);
int main(void)
{
if(find_substr(“C is fun”, “is”) != -1)
printf(“Substring is found.”);
else
printf(“not found”);
return 0;
}
/* Return index of first match of itemPointer in listPointer. */
int find_substr(char *listPointer, char *itemPointer)
{
int t;
char *p, *p2;
for(t=0; listPointer[t]; t++) {
p = &listPointer[t];
p2 = itemPointer;
while(*p2 && *p2==*p) {
p++;
p2++;
}
if(!*p2) return t; /* 1st return */
}
return -1; /* 2nd return */
}