[PATCH] libcamera: dma_buf_allocator: Work around lack of file seals in uClibc
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Wed Jun 5 11:10:34 CEST 2024
On Wed, Jun 05, 2024 at 09:45:28AM +0100, Kieran Bingham wrote:
> Quoting Laurent Pinchart (2024-06-05 09:35:33)
> > uClibc doesn't provide the macros defining parameters for the file
> > sealing API. Define them manually as a work around.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > ---
> > An alternative would be to disable udmabuf support on such platforms. I
> > think we can expect someone running libcamera on a uClibc system to be
> > able to enable DMA heaps.
>
> I think this is fine, and keeps our uClibc compile coverage up.
>
> > ---
> > meson.build | 4 ++++
> > src/libcamera/dma_buf_allocator.cpp | 5 +++++
> > 2 files changed, 9 insertions(+)
> >
> > diff --git a/meson.build b/meson.build
> > index 1902ea2fd3ff..0ef4cdaafd76 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -74,6 +74,10 @@ cc = meson.get_compiler('c')
> > cxx = meson.get_compiler('cpp')
> > config_h = configuration_data()
> >
> > +if cc.has_header_symbol('fcntl.h', 'F_ADD_SEALS', prefix : '#define _GNU_SOURCE')
> > + config_h.set('HAVE_FILE_SEALS', 1)
> > +endif
> > +
> > if cc.has_header_symbol('unistd.h', 'issetugid')
> > config_h.set('HAVE_ISSETUGID', 1)
> > endif
> > diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp
> > index d7d08e188a62..1c39441a3415 100644
> > --- a/src/libcamera/dma_buf_allocator.cpp
> > +++ b/src/libcamera/dma_buf_allocator.cpp
> > @@ -157,6 +157,11 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size)
> > return {};
> > }
> >
> > +#if not HAVE_FILE_SEALS
>
> A one line comment above saying why they are hardcoded here for context
> to readers coming across this would be nice but optional.
I'll add
/* uClibc doesn't provide the file sealig API. */
> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
>
> > +#define F_ADD_SEALS 1033
> > +#define F_SEAL_SHRINK 0x0002
> > +#endif
> > +
> > /* udmabuf dma-buffers *must* have the F_SEAL_SHRINK seal. */
> > ret = fcntl(memfd.get(), F_ADD_SEALS, F_SEAL_SHRINK);
> > if (ret < 0) {
> >
> > base-commit: 98071d3109c131820439f61d9380c0bd4cd2119a
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list