Inappropriate ioctl for device

2010-12-24 Thread Mohammad Hedayati
I'm writing a simple char device. So far everything went so good
(read/write), but here I'm going to add support for ioctl.

int
ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td)
{
 int error = 0;
 uprintf(Here...\n);
 return(error);
}
and I'm calling it here:

len = ioctl(cd, 0);
perror(ioctl);

but when runnig it says:

ioctl: Inappropriate ioctl for device
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Inappropriate ioctl for device

2010-12-24 Thread Gary Jennejohn
On Fri, 24 Dec 2010 18:17:18 +0330
Mohammad Hedayati hedayati...@gmail.com wrote:

 I'm writing a simple char device. So far everything went so good
 (read/write), but here I'm going to add support for ioctl.
 
 int
 ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread 
 *td)
 {
  int error = 0;
  uprintf(Here...\n);
  return(error);
 }
 and I'm calling it here:
 
 len = ioctl(cd, 0);
 perror(ioctl);
 
 but when runnig it says:
 
 ioctl: Inappropriate ioctl for device

Carefully read ioctl(2) and consider that you're passing in 0 as the cmd.
If you still don't understand your error, post again.

Hint: look at /sys/kern/sys_generic.c:^ioctl

-- 
Gary Jennejohn
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Inappropriate ioctl for device

2010-12-24 Thread Mohammad Hedayati
On Fri, Dec 24, 2010 at 7:31 PM, Gary Jennejohn
gljennj...@googlemail.comwrote:

 On Fri, 24 Dec 2010 18:17:18 +0330
 Mohammad Hedayati hedayati...@gmail.com wrote:

  I'm writing a simple char device. So far everything went so good
  (read/write), but here I'm going to add support for ioctl.
 
  int
  ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct
 thread *td)
  {
   int error = 0;
   uprintf(Here...\n);
   return(error);
  }
  and I'm calling it here:
 
  len = ioctl(cd, 0);
  perror(ioctl);
 
  but when runnig it says:
 
  ioctl: Inappropriate ioctl for device

 Carefully read ioctl(2) and consider that you're passing in 0 as the cmd.
 If you still don't understand your error, post again.

 Hint: look at /sys/kern/sys_generic.c:^ioctl

 --
 Gary Jennejohn


It was a misspelling, I'm doing as bellow, if you mean the u_long.

unsinged long cmd = 0;
len = ioctl(cd, cmd);
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Inappropriate ioctl for device

2010-12-24 Thread Gary Jennejohn
On Fri, 24 Dec 2010 19:37:37 +0330
Mohammad Hedayati hedayati...@gmail.com wrote:

 On Fri, Dec 24, 2010 at 7:31 PM, Gary Jennejohn
 gljennj...@googlemail.comwrote:
 
  On Fri, 24 Dec 2010 18:17:18 +0330
  Mohammad Hedayati hedayati...@gmail.com wrote:
 
   I'm writing a simple char device. So far everything went so good
   (read/write), but here I'm going to add support for ioctl.
  
   int
   ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct
  thread *td)
   {
int error = 0;
uprintf(Here...\n);
return(error);
   }
   and I'm calling it here:
  
   len = ioctl(cd, 0);
   perror(ioctl);
  
   but when runnig it says:
  
   ioctl: Inappropriate ioctl for device
 
  Carefully read ioctl(2) and consider that you're passing in 0 as the cmd.
  If you still don't understand your error, post again.
 
  Hint: look at /sys/kern/sys_generic.c:^ioctl
 
  --
  Gary Jennejohn
 
 
 It was a misspelling, I'm doing as bellow, if you mean the u_long.
 
 unsinged long cmd = 0;
 len = ioctl(cd, cmd);


No, that isn't what I meant.  Read the kernel code - cmd = 0 is not
legal.

-- 
Gary Jennejohn
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Inappropriate ioctl for device

2010-12-24 Thread Mohammad Hedayati
On Fri, Dec 24, 2010 at 7:37 PM, Mohammad Hedayati hedayati...@gmail.comwrote:



 On Fri, Dec 24, 2010 at 7:31 PM, Gary Jennejohn gljennj...@googlemail.com
  wrote:

 On Fri, 24 Dec 2010 18:17:18 +0330
 Mohammad Hedayati hedayati...@gmail.com wrote:

  I'm writing a simple char device. So far everything went so good
  (read/write), but here I'm going to add support for ioctl.
 
  int
  ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct
 thread *td)
  {
   int error = 0;
   uprintf(Here...\n);
   return(error);
  }
  and I'm calling it here:
 
  len = ioctl(cd, 0);
  perror(ioctl);
 
  but when runnig it says:
 
  ioctl: Inappropriate ioctl for device

 Carefully read ioctl(2) and consider that you're passing in 0 as the cmd.
 If you still don't understand your error, post again.

 Hint: look at /sys/kern/sys_generic.c:^ioctl

 --
 Gary Jennejohn


 It was a misspelling, I'm doing as bellow, if you mean the u_long.

 unsinged long cmd = 0;
 len = ioctl(cd, cmd);


Thanks, Problem is solved!
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org