Results 1 to 6 of 6
hi,
#include <stdio.h>
#include <linux/usbdevice_fs.h>
#include <fcntl.h>
int main() {
int fd;
fd=open("/proc/bus/usb/005/007", O_RDONLY);
struct usb_connectinfo usbinfo;
int err;
if((err=ioctl(fd, USB_CONNECTINFO, &usbinfo))==<0){
perror("ioctl error");
return 0;
}
close(fd);
return 0;
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 04-25-2009 #1Just Joined!
- Join Date
- Mar 2009
- Posts
- 13
ioctl() error operation not permitted
hi,
#include <stdio.h>
#include <linux/usbdevice_fs.h>
#include <fcntl.h>
int main() {
int fd;
fd=open("/proc/bus/usb/005/007", O_RDONLY);
struct usb_connectinfo usbinfo;
int err;
if((err=ioctl(fd, USB_CONNECTINFO, &usbinfo))==<0){
perror("ioctl error");
return 0;
}
close(fd);
return 0;
}
at run time command sudo ./a.out
operation not permitted error is comming.
permission for 007 file is 660.
please reply me.
- 04-25-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,156
Well, /proc/bus/usb/005/007 is not a device. It is a process file. What are you trying to accomplish?
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 04-26-2009 #3Just Joined!
- Join Date
- Mar 2009
- Posts
- 13
same problem after device file include
as i know all device file in /dev directory.
when i insert pen drive in usb port than sdb and sdb1 to new device file create can you tell me what exactly these device file.
i modified program but problem is same.
int main() {
int fd;
if((fd=open("/dev/bus/usb/005/007" ,O_RDONLY))<0){
perror("device file opening error");
return 0;
}
int chk;
printf("\n device file descriptor is: %d",fd);
struct usbdevfs_connectinfo usbinfo;
if((chk=ioctl(fd, USBDEVFS_CONNECTINFO, &usbinfo ))<0){
perror("device ioctl error: ");
close(fd);
return 0;
}
printf("\n%d",chk);
printf("\n device number is: %d",usbinfo.devnum);
printf("\n device speed is: %d", usbinfo.slow);
close(fd);
return 0;
}
$ ./a.out
device ioctl error: : Operation not permitted
- 04-26-2009 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,156
Because the device for the file is the file system it is mounted on, the driver for that device has to support the USBDEVFS_CONNECTINFO ioctl command. The file is NOT a USB device. That's why the call fails.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 04-27-2009 #5Just Joined!
- Join Date
- Mar 2009
- Posts
- 13
ok. if i am opening file sdb or sdb1 after that same problem is coming.
which file will i open for this ioctl command.
can you correct this program.
- 04-27-2009 #6Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,156
The raw usb devices seen by the system are /dev/usbdev*. When a usb drive is plugged into the system, the kernel maps the raw device to /dev/sdXN. Some other USB devices, such as printers, are mapped to /dev/usb/*. That's as much as I know at this point, since I have never needed to do any low-level USB programming, other than to specify device and manufacturer id's to get the correct driver loaded for something like a wireless device or camera, which is all shell-level stuff.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
