linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: RAMON_GARCIA_F <RAMON_GARCIA_F@terra.es>
To: linux-kernel@vger.kernel.org
Subject: Suggestion for a new system call: convert file handle to a cookie for transfering file handles between processes.
Date: Thu, 17 Jul 2003 19:47:11 +0200	[thread overview]
Message-ID: <fb7ddfab3b.fab3bfb7dd@teleline.es> (raw)

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







             reply	other threads:[~2003-07-17 17:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-17 17:47 RAMON_GARCIA_F [this message]
2003-07-18 18:39 ` Suggestion for a new system call: convert file handle to a cookie for transfering file handles between processes 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fb7ddfab3b.fab3bfb7dd@teleline.es \
    --to=ramon_garcia_f@terra.es \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).