develoment workflow: how to avoid duplicate work ?

Hugo Lefeuvre hle at owl.eu.com
Tue Jun 5 21:48:23 EDT 2018


> > It's not duplication, it's increment/decrement of a counter.
> > 
> > Look for functions  with 'get' and 'put' in their names.
> 
> AFAICT counter is f_count in struct file, updated by fget and fput.

Yes, this is the counter I was speaking about. But to me the only way to
increment/decrement this counter was either to duplicate an existing
reference using dup/dup2, or to fork the process. This was wrong, and
I'm glad I learned that.

FTR: After taking a look at the kernel code, the ioctl syscall is
implemented in ksys_ioctl[0], which calls fdget/fdput to get the struct
fd, incrementing and decrementing the count.

Thanks your help !

> > I haven't looked at the code - there's an outside chance that the driver
> > isn't doing reference counting correctly.
> 
> pi433 driver does not mess with struct file too much so I guess it should
> be safe :)

I'll take a closer look at the TODO and come back later with a patch. If
there's nothing to do I'll remove it, otherwise I'll fix it.

Cheers,
 Hugo

[0] https://elixir.bootlin.com/linux/latest/source/fs/ioctl.c#L692

-- 
             Hugo Lefeuvre (hle)    |    www.owl.eu.com
4096/ 9C4F C8BF A4B0 8FC5 48EB 56B8 1962 765B B9A8 BACA



More information about the Kernelnewbies mailing list