Re: doubt about char drivers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tkz for the first clarifications..

If i use the dynamical allocation in the driver and
the script of the Rubini's book. They will catch the
same major number?!


Thank you in advance.

Atenciosamente, thr~~~


--- Ketan Mukadam <kmukadam@neomagic.com> escreveu: > 
> You can also use the following function to do the
> node creation during run 
> time. Call this function just before device open in
> the application.
> 
> #define MAX_COL 50
> int make_device_node(char* name)
> {
>          char s[MAX_COL];
>          FILE* fp;
>          char* p = s;
>          int major;
>          memset((void *)s,0,MAX_COL);
>                  snprintf((char *)s,MAX_COL,"cat
> /proc/devices | grep %s > 
> ketan.tmp",name);
>          system(s);
>          fp = fopen("ketan.tmp","r");
>          if(fp == NULL)
>                  printf("unable to open a temp
> file\n");
>          else
>          {
>                          memset((void
> *)s,0,MAX_COL);
>                          fgets(s,MAX_COL,fp);
>                          strtok(s," ");
>                          p=strtok(NULL, " ");
>                          printf("The Major No. is %s
> for Device : %s",s,p);
>                          major = atoi(s);
>                          system("rm -f ketan.tmp");
>                          snprintf((char
> *)s,MAX_COL,"mknod /dev/%s c %d 
> 0",name,major);
>                          printf(" Executing =
> %s\n",s);
>                          system(s);
>          }
> }
> 
> You can also improve it to include the minor number
> (which is assumed to be 
> 0 in this case)
> 
> Ketan
> 
> 
> At 05:30 AM 7/7/2004, you wrote:
> >Hello everybody
> >
> >I'm reading the "Linux Device Drivers" (Alessandro
> >Rubini), and i'm in chapter that we learn to build
> a
> >char driver. I'm necesarilly at the point where he
> >argues about dynamical allocation of major numbers
> but
> >i have one doubt (for the moment), if i use the
> >dynamical allocation, its because i dont have a one
> >major number exclusive of my char driver and then..
> >who will make the device nodes to my char driver?!
> I
> >have to guide my driver to print the major number
> that
> >it found dynamically and then make the nodes
> manually?
> >
> >
> >Forgive eventual english mistakes..
> >
> >Atenciosamente, thr~~
> >
> >
> >
> >
> >
>
>_______________________________________________________
> >Yahoo! Mail agora com 100MB, anti-spam e antivírus
> grátis!
> >http://br.info.mail.yahoo.com/
> >
> >--
> >Kernelnewbies: Help each other learn about the
> Linux kernel.
> >Archive:      
> http://mail.nl.linux.org/kernelnewbies/
> >FAQ:           http://kernelnewbies.org/faq/
> 
> 
>  


	
	
		
_______________________________________________________
Yahoo! Mail agora com 100MB, anti-spam e antivírus grátis!
http://br.info.mail.yahoo.com/

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux