All of lore.kernel.org
 help / color / mirror / Atom feed
* Suggestion for a new system call: convert file handle to a cookie for transfering file handles between processes.
@ 2003-07-17 17:47 RAMON_GARCIA_F
  2003-07-18 18:39 ` Ingo Oeser
  2003-07-19  9:59 ` Miquel van Smoorenburg
  0 siblings, 2 replies; 11+ messages in thread
From: RAMON_GARCIA_F @ 2003-07-17 17:47 UTC (permalink / raw)
  To: linux-kernel

Hello.

I suggest to add a new system call for transfering a file handle between
two processes.

In Linux, transfer of file handles can be done through a Unix domain
socket. This mechanism is quite unflexible. It requires that the two
applications connect by this kind of socket, and it is difficult to
use from shell scripts.

The new mechanims proposed is more flexible.

A cookie is a large integer number (160 bit suggested) that can be used
to refer to a file handle from any process. It is randomly choosen by
the kernel at creation time. Afterwards, any process that knows this
cookie can convert it back to a file handle. When this conversion is
done, the cookie dies and is no longer valid.

An example of why cookies are useful.

Let cdwritter be a program for writting CDs. Unlike other programs,
cdwritter is rationally designed. It is a server process that listens
through a named pipe, thus making it easy to write either command line
or graphical interfaces that use its functionality. The named pipe
is called /var/run/cdwritter

To keep this discussion simple, cdwritter supports writting a single
file (usually an ISO image) to a cdrecorder. The user gives a command,
and afterwards the CD is burned. To write a file, the user must write a
string "write <cookie>" to /var/run/cdwritter. The cookie is used to
identify the file.

An alternative would be that cdwritter accepts a file name instead of
a cookie. But then, the author of cdwritter would have to check if the
user has permission to access the file. This makes cdwritter more error
prone.

Shell scripts can write CDs to cdwriter. The command get_cookie, opens a
file given on the command line and prints a cookie on stdout. Thus a
shell script for burning the image my_nude_photos.iso would be:

echo "write $(get_cookie my_nude_photos.iso)" > /var/run/cdwritter

CREDITS: The Plan9 operating system provided inspiration for this idea.

Ramon







^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Suggestion for a new system call: convert file handle to a cookie for transfering file handles between processes.
@ 2003-07-21  9:49 RAMON_GARCIA_F
  2003-07-21 13:42 ` Mark Mielke
  2003-07-21 14:41 ` Horst von Brand
  0 siblings, 2 replies; 11+ messages in thread
From: RAMON_GARCIA_F @ 2003-07-21  9:49 UTC (permalink / raw)
  To: linux-kernel

Although it is posible to use unix sockets, my proposal
integrates better with shell scripts.

Ramon



^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Suggestion for a new system call: convert file handle to a cookie for transfering file handles between processes.
@ 2003-07-21 16:55 RAMON_GARCIA_F
  2003-07-21 19:16 ` Mark Mielke
  0 siblings, 1 reply; 11+ messages in thread
From: RAMON_GARCIA_F @ 2003-07-21 16:55 UTC (permalink / raw)
  To: linux-kernel

My proposal is useful for cases where the server program is running with
a different priviledge from the user invoking it. Examples where this
behaviour is useful are writting CDs, saving man pages, saving TeX cache
files, where full access to a resource would be unsafe, but limited
access through an intermediate server is safe.

In addition, this proposal is useful for cases where the server process
cannot access the named file, becaue it does not have permission to do
so, or because it is anonymous (example: a pipe).

I can't see why cookies introduce circular references. A cookie referes
to an inode, but an inode does not refer to a file.

However, a cookie introduces a permanent reference to a file handle.
This reference is not destroyed until the cookie is used. Therefore,
cookies should have a timeout associated with them, so that if they
are not consumed they should be destroyed.

Ramon





^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Suggestion for a new system call: convert file handle to a cookie for transfering file handles between processes.
@ 2003-07-21 19:48 RAMON_GARCIA_F
  2003-07-21 20:07 ` Mark Mielke
  0 siblings, 1 reply; 11+ messages in thread
From: RAMON_GARCIA_F @ 2003-07-21 19:48 UTC (permalink / raw)
  To: linux-kernel

It might be posible to implement in user space. I have not fully studied
it to see if there are significant problems.

I believe that innovation is a public good that should be actively
promoted. Otherwise technology would never advance.

The complication added to the kernel is minimal because the primitive is
simple. That is actually the most important reason why I like it.

There are barriers to adopting, such as portability. But if the
primitive is included in standard Linux and is found useful by
application developers, other Unixes will follow.

Ramon




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

end of thread, other threads:[~2003-07-21 19:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-17 17:47 Suggestion for a new system call: convert file handle to a cookie for transfering file handles between processes RAMON_GARCIA_F
2003-07-18 18:39 ` Ingo Oeser
2003-07-19  3:55   ` Mark Mielke
2003-07-19  9:59 ` Miquel van Smoorenburg
2003-07-21  9:49 RAMON_GARCIA_F
2003-07-21 13:42 ` Mark Mielke
2003-07-21 14:41 ` Horst von Brand
2003-07-21 16:55 RAMON_GARCIA_F
2003-07-21 19:16 ` Mark Mielke
2003-07-21 19:48 RAMON_GARCIA_F
2003-07-21 20:07 ` Mark Mielke

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.