simple ioctl problem

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

 



I'm sorry! I've replied to another message instead of create a new discussion. 
I resend the whole message
                      --------------------------------------------------------------------------
Hi all, 
I've some problems with the implementation of the ioctl in kernel module I'm 
developing.
I've create three files:

1) the header "device.h ":

#define MTPMC_IOC_MAGIC 254
#define MTPMC_IOC_WRITE_USER_PID _IOW(MTPMC_IOC_MAGIC, 0, pid_t)
#define MTPMC_IOC_WRITE_THREAD_PID _IOW(MTPMC_IOC_MAGIC, 1, pid_t)
#define MTPMC_IOC_READ_INITIALIZE _IOR(MTPMC_IOC_MAGIC, 2, int)
#define MTPMC_IOC_READ_NUM_THREAD _IOR(MTPMC_IOC_MAGIC, 3, int)
#define MTPMC_IOC_RESTORE_NOT_WRITABLE _IO(MTPMC_IOC_MAGIC, 4)
#define MTPMC_IOC_RESTORE_WRITABLE _IO(MTPMC_IOC_MAGIC, 5)
#define MTPMC_IOC_TIMER_FUNCTION _IOW(MTPMC_IOC_MAGIC, 6, int)

#define MTPMC_IOC_MAXNR 7

2) the kernel-space driver "device.c" which includes the header and implements 
a switch as follows:

   switch(cmd){
 case MTPMC_IOC_WRITE_USER_PID: /* nr == 1 */
  mtpmc_user = arg;
  break;

 case MTPMC_IOC_WRITE_THREAD_PID: /* nr == 2 */
  mtpmc_pid = arg;
  break;

 case MTPMC_IOC_READ_INITIALIZE: /* nr == 3 */
  return mtpmc_initialize();
     }

3) the user-space file "user.c" which includes the header and calls ioctl in 
this way:

 ioctl(fd, MTPMC_IOC_WRITE_USER_PID, getpid()); /
 ioctl(fd, MTPMC_IOC_WRITE_THREAD_PID, thread_pid); 
 r = ioctl(fd, MTPMC_IOC_READ_INITIALIZE); 


Now! When I compile device.c things go well but when I try to compile the 
user-space programm with the command

     gcc -g -o user user.c

occurre the errors:

     user.c:51: error: parse error before "pid_t"
     user.c:52: error: parse error before "pid_t"
     user.c:53: error: parse error before "int"

Where I'm wrong?
Thanks.
Vincenzo Mallozzi

	

	
		
___________________________________ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it


--
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