public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tim Jansen <tim@tjansen.de>
To: Mark Hahn <hahn@coffee.psychology.mcmaster.ca>
Cc: linux-kernel@vger.kernel.org
Subject: Re: /proc format (was Device Registry (DevReg) Patch 0.2.0)
Date: Thu, 26 Apr 2001 16:06:53 +0200	[thread overview]
Message-ID: <01042616065300.00884@cookie> (raw)
In-Reply-To: <Pine.LNX.4.10.10104251804180.3127-100000@coffee.psychology.mcmaster.ca>
In-Reply-To: <Pine.LNX.4.10.10104251804180.3127-100000@coffee.psychology.mcmaster.ca>

On Thursday 26 April 2001 00:24, Mark Hahn wrote:
> I have a sense that all of these could be collapsed into a single
> api where kernel systems would register hierarchies of tuples of
> <type,tag,callback>, where callback would be passed the tag,

You also need to know the parent of the tuple to build a hierarchy. And it 
should be possible to create lists. 

The callback prototypes for values could look like this:

int proc_value_cb_string(char *buf, void *context); // writes string to buf, 
// returns len of string or negative value for error
int proc_value_cb_int(int *value, void *context); 


For parent/directory tuples you would provide two additional callbacks that 
set the context for their children and maybe take care of other things like 
locking (so they dont need to be done in every single value callback):

void *proc_value_cb_level_enter(void *old_context); // returns new context
void proc_value_cb_level_leave(void *old_context, void *new_context);


For tuples with a list there would be two callbacks to get the list elements:

int proc_value_cb_list_num(void *context); // returns number of elements
void *proc_value_cb_list_context(int index, void *context); // returns context
// of the element at the given index or NULL


To register such a tuple you would have the following functions:
void proc_value_register_string(parent_handle_t parent, 
                                             const char *name,
		                     proc_value_cb_string cb);
void proc_value_register_int(parent_handle_t parent, 
                                         const char *name,
			     proc_value_cb_int cb);
parent_handle_t proc_value_register_parent(parent_handle_t parent, 
                                  const char *name,
 		          proc_value_cb_level_enter cb1,
		          proc_value_cb_level_leave cb2);
parent_handle_t proc_value_register_list(parent_handle_t h, 
	     	          proc_value_cb_list_num cbnum,
	                      proc_value_cb_list_context cbcon);

This is the simplest API that I can imagine for this. The only problem is 
that you need to write a callback for each value (file). Just printing XML 
still looks easier to me...


> and proc code would take care of "rendering" the data into
> human readable text (default), binary, or even xml.  the latter
> would require some signalling mechanism like O_PROC_XML or the like.

Then you can argue that once you have a single format implemented in the 
kernel you can convert it to whatever you like in user-space. And it seems 
like the decision for "one-value-per-file" in /proc has already been made 
(please correct me if not and we start all over again), so I will try to make 
a generic API like the one above for it.


> further, programs could perform a meta-query, where they ask for
> the types and tags of a datum (or hierarchy), so that on subsequent
> queries, they'd now how to handle binary data.

That would undermine the only advantage of binary data: it's easy (and 
fast) to dump or read a C struct. Not that I would really care for binary 
data...

bye...

  reply	other threads:[~2001-04-26 14:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-25 17:10 Device Registry (DevReg) Patch 0.2.0 Dan Kegel
2001-04-25 18:09 ` H. Peter Anvin
2001-04-25 18:55 ` /proc format (was Device Registry (DevReg) Patch 0.2.0) Tim Jansen
2001-04-25 19:19   ` Dan Kegel
2001-04-25 23:09     ` Tim Jansen
2001-04-25 19:37   ` Jesse Pollard
2001-04-25 20:08     ` Dan Kegel
2001-04-25 20:40     ` Tim Jansen
2001-04-25 21:16       ` Jesse Pollard
2001-04-25 21:50         ` J . A . Magallon
2001-04-25 21:58           ` Doug McNaught
2001-04-25 22:03             ` J . A . Magallon
2001-04-25 22:24               ` Marko Kreen
2001-04-25 22:42               ` Alexander Viro
2001-04-25 22:24             ` Mark Hahn
2001-04-26 14:06               ` Tim Jansen [this message]
2001-04-25 22:46         ` Tim Jansen
     [not found] <200104252056.PAA44995@tomcat.admin.navo.hpc.mil>
2001-04-25 21:10 ` Dan Kegel
  -- strict thread matches above, loose matches on Subject: below --
2001-04-26  1:09 Dan Kegel

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=01042616065300.00884@cookie \
    --to=tim@tjansen.de \
    --cc=hahn@coffee.psychology.mcmaster.ca \
    --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