* Which one corresponds to ioctl in the file_operations struct in linux/fs.h?
@ 2011-12-01 7:40 Peng Yu
2011-12-01 10:22 ` Tvrtko Ursulin
0 siblings, 1 reply; 4+ messages in thread
From: Peng Yu @ 2011-12-01 7:40 UTC (permalink / raw)
To: linux-kernel
Hi,
I have some driver code for older version of kernel. It refers to
ioctl in the file_operations struct. But this field is change in
kernel 3.0.0-13
I find the following in linux/fs.h
1566 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
1567 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
Does anybody know which one I should use in order to migrate the
driver code to the newer version of kernel? Thanks!
--
Regards,
Peng
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Which one corresponds to ioctl in the file_operations struct in linux/fs.h?
2011-12-01 7:40 Which one corresponds to ioctl in the file_operations struct in linux/fs.h? Peng Yu
@ 2011-12-01 10:22 ` Tvrtko Ursulin
2011-12-01 12:45 ` Arnd Bergmann
2011-12-01 18:55 ` Peng Yu
0 siblings, 2 replies; 4+ messages in thread
From: Tvrtko Ursulin @ 2011-12-01 10:22 UTC (permalink / raw)
To: Peng Yu; +Cc: linux-kernel
On Thursday 01 Dec 2011 07:40:49 Peng Yu wrote:
> Hi,
>
> I have some driver code for older version of kernel. It refers to
> ioctl in the file_operations struct. But this field is change in
> kernel 3.0.0-13
>
> I find the following in linux/fs.h
>
> 1566 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
> 1567 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
>
> Does anybody know which one I should use in order to migrate the
> driver code to the newer version of kernel? Thanks!
>From Documentation/filesystems/vfs.txt:
unlocked_ioctl: called by the ioctl(2) system call.
compat_ioctl: called by the ioctl(2) system call when 32 bit system calls
are used on 64 bit kernels.
You don't need compat_ioctl if your ioctl arguments are 32/64-bit safe.
For both your code needs to be re-entrant or take appropriate locks
internally.
Hope this helps,
Tvrtko
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Which one corresponds to ioctl in the file_operations struct in linux/fs.h?
2011-12-01 10:22 ` Tvrtko Ursulin
@ 2011-12-01 12:45 ` Arnd Bergmann
2011-12-01 18:55 ` Peng Yu
1 sibling, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2011-12-01 12:45 UTC (permalink / raw)
To: Tvrtko Ursulin; +Cc: Peng Yu, linux-kernel
On Thursday 01 December 2011, Tvrtko Ursulin wrote:
> On Thursday 01 Dec 2011 07:40:49 Peng Yu wrote:
> > Hi,
> >
> > I have some driver code for older version of kernel. It refers to
> > ioctl in the file_operations struct. But this field is change in
> > kernel 3.0.0-13
> >
> > I find the following in linux/fs.h
> >
> > 1566 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
> > 1567 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
> >
> > Does anybody know which one I should use in order to migrate the
> > driver code to the newer version of kernel? Thanks!
>
> From Documentation/filesystems/vfs.txt:
>
> unlocked_ioctl: called by the ioctl(2) system call.
>
> compat_ioctl: called by the ioctl(2) system call when 32 bit system calls
> are used on 64 bit kernels.
>
> You don't need compat_ioctl if your ioctl arguments are 32/64-bit safe.
Actually, you should always provide a .compat_ioctl pointer, but if
all commands are 32/64 bit safe, it can point to the same function,
or (slightly safer) be a wrapper like
static long my_compat_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
{
return my_ioctl(f, cmd, (unsigned long)compat_ptr(arg));
}
Strictly speaking, the first option assumes that all commands
take no argument or integers directly encoded in the 'arg', while
the second option assumes that all commands take either no argument
or a pointer to an argument in memory.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Which one corresponds to ioctl in the file_operations struct in linux/fs.h?
2011-12-01 10:22 ` Tvrtko Ursulin
2011-12-01 12:45 ` Arnd Bergmann
@ 2011-12-01 18:55 ` Peng Yu
1 sibling, 0 replies; 4+ messages in thread
From: Peng Yu @ 2011-12-01 18:55 UTC (permalink / raw)
To: Tvrtko Ursulin; +Cc: linux-kernel
> From Documentation/filesystems/vfs.txt:
As a side question, besides using the fullpath of the document. Is
there a faster way to open it?
vim /usr/share/doc/linux-doc/filesystems/vfs.txt.gz
--
Regards,
Peng
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-12-01 18:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-01 7:40 Which one corresponds to ioctl in the file_operations struct in linux/fs.h? Peng Yu
2011-12-01 10:22 ` Tvrtko Ursulin
2011-12-01 12:45 ` Arnd Bergmann
2011-12-01 18:55 ` Peng Yu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.