All of lore.kernel.org
 help / color / mirror / Atom feed
* get_unused_fd and get_unused_fd_flags
@ 2012-06-22  9:33 Ozan Çağlayan
  2012-06-22  9:47 ` Al Viro
  0 siblings, 1 reply; 4+ messages in thread
From: Ozan Çağlayan @ 2012-06-22  9:33 UTC (permalink / raw)
  To: linux-kernel; +Cc: viro, mcgrof

Hi,

With,

commit 1027abe8827b47f7e9c4ed6514fde3d44f79963c
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Wed Jul 30 04:13:04 2008 -0400

    [PATCH] merge locate_fd() and get_unused_fd()

        New primitive: alloc_fd(start, flags).  get_unused_fd() and
    get_unused_fd_flags() become wrappers on top of it.

    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Two wrappers get_unused_fd() and get_unused_fd_flags() are introduced.
get_unused_fd() is an exported one-liner:

int get_unused_fd(void)
{
        return alloc_fd(0, 0);
}
EXPORT_SYMBOL(get_unused_fd);

But get_unused_fd_flags() is implemented through a macro:

#define get_unused_fd_flags(flags) alloc_fd(0, (flags))

Both are wrappers around alloc_fd(). I'm quite new to this stuff but
why there's an asymmetry in here? One is exposed, the other is not.

(BTW: I'm doing compat-drm stuff for GSoC and I have to call
get_unused_fd_flags() but since alloc_fd() is not exported, this
doesn't work.)

Thanks :)

-- 
Ozan Çağlayan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: get_unused_fd and get_unused_fd_flags
  2012-06-22  9:33 get_unused_fd and get_unused_fd_flags Ozan Çağlayan
@ 2012-06-22  9:47 ` Al Viro
  2012-06-22  9:59   ` Ozan Çağlayan
  0 siblings, 1 reply; 4+ messages in thread
From: Al Viro @ 2012-06-22  9:47 UTC (permalink / raw)
  To: Ozan ??a??layan; +Cc: linux-kernel, mcgrof

On Fri, Jun 22, 2012 at 12:33:35PM +0300, Ozan ??a??layan wrote:
> But get_unused_fd_flags() is implemented through a macro:
> 
> #define get_unused_fd_flags(flags) alloc_fd(0, (flags))
> 
> Both are wrappers around alloc_fd(). I'm quite new to this stuff but
> why there's an asymmetry in here? One is exposed, the other is not.

Because get_unused_fd_flags() never had been exported.  And
default policy for exports is "Don't, unless somebody can
demonstrate a clear need that can't be handled in other
ways".

> (BTW: I'm doing compat-drm stuff for GSoC and I have to call
> get_unused_fd_flags() but since alloc_fd() is not exported, this
> doesn't work.)

Details of that "have to", please.  Note that existing modular uses of
get_unused_fd() tend to be rather fishy; if anything, I'd expect
get_unused_fd() eventually becoming internal-only, if we manage to
pull that off.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: get_unused_fd and get_unused_fd_flags
  2012-06-22  9:47 ` Al Viro
@ 2012-06-22  9:59   ` Ozan Çağlayan
  2012-06-22 10:34     ` Ozan Çağlayan
  0 siblings, 1 reply; 4+ messages in thread
From: Ozan Çağlayan @ 2012-06-22  9:59 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel, mcgrof

> Details of that "have to", please.  Note that existing modular uses of
> get_unused_fd() tend to be rather fishy; if anything, I'd expect
> get_unused_fd() eventually becoming internal-only, if we manage to
> pull that off.

I've got it. I'm backporting the dma-buf (drivers/base/dma-buf.c)
feature to kernels < 3.3. It is actually pretty straightforward except
a single call to get_unused_fd_flags() from dma_buf_fd(). Then
get_unused_fd_flags() macro resolves to alloc_fd() which is not
exported.

Maybe I should backport alloc_fd and rename it to sth like
compat_alloc_fd and use that instead of alloc_fd in compat. What I was
trying to understand was the reason behind exporting/not-exporting
those similar wrappers. I don't try to justify that it should be
exported for me :)

Thanks!



-- 
Ozan Çağlayan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: get_unused_fd and get_unused_fd_flags
  2012-06-22  9:59   ` Ozan Çağlayan
@ 2012-06-22 10:34     ` Ozan Çağlayan
  0 siblings, 0 replies; 4+ messages in thread
From: Ozan Çağlayan @ 2012-06-22 10:34 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel, mcgrof

> Maybe I should backport alloc_fd and rename it to sth like
> compat_alloc_fd and use that instead of alloc_fd in compat. What I was
> trying to understand was the reason behind exporting/not-exporting
> those similar wrappers. I don't try to justify that it should be
> exported for me :)

Well this already seems unbackportable as alloc_fd() pulls in
expand_files() which pulls in expand_fdtable() which pulls in
alloc_fdtable(), etc. etc.


-- 
Ozan Çağlayan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-22 10:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-22  9:33 get_unused_fd and get_unused_fd_flags Ozan Çağlayan
2012-06-22  9:47 ` Al Viro
2012-06-22  9:59   ` Ozan Çağlayan
2012-06-22 10:34     ` Ozan Çağlayan

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.