[Libguestfs] [PATCH] Report last-modified time of hive root and nodes

Alex‎ Nelson ajnelson at cs.ucsc.edu
Wed Aug 10 19:07:09 UTC 2011


On Aug 10, 2011, at 11:19 , Richard W.M. Jones wrote:

> On Wed, Aug 10, 2011 at 11:03:21AM -0700, Alex‎ Nelson wrote:
>> The reason for this change was to expose some of the handle's
>> fields.  I wasn't sure how to detect being at the root node.
> 
> From the public API you can use:
> 
>  hive_node_h some_node = ...;
> 
>  if (some_node == hivex_root (h)) {
>    // you're at the root node
>  }
Looks good, I'll use that.  It looks like it'd be quicker to just query h->rootoffs if within lib/hivex.c, but I'll stick with the API.

> 
>> It also looked like a good place to stash the last-modified time of
>> the root node.  With your ABI suggestions below, I think I have a
>> better way that doesn't muck with the handle structure.
> 
> Stashing the last-modified time in the handle may be a good idea, but
> the handle structure doesn't have to be public to do this.  When
> writing or changing the library (ie. in lib/hivex.c) you already have
> access to the internal structure of struct hive_h.
> 
>> Thank you, I'll adjust my changes to use differently-named
>> functions.  Is it acceptable style to you to have these become
>> Java-like wrapper functions, e.g.:
>> 
>> static int
>> node_start_with_time (hive_h *h, void *writer_v, hive_node_h node, const char *name, const char *last_modified)
>> {
>>  //Body:  the node_start function as it is now, augmented with null-checking work on last_modified
>> }
>> 
>> static int
>> node_start (hive_h *h, void *writer_v, hive_node_h node, const char *name, const char *last_modified)
>> {
>>  return node_start_with_time (h, write_v, node, name, NULL);
>> }
>> 
>> This preserves the C ABI, and prevents code duplication.
> 
> I'm not entirely sure what you mean here.  Functions like 'node_start'
> are defined by the caller of the hivex API, and so have nothing to do
> with the implementation.  To make this clearer: xml/hivexml.c is a
> caller of the public API, while lib/hivex.c is the internal
> implementation of the API.
I apologize, I was unclear on where these functions were.  I meant the node_start within xml/hivexml.c.  Fortunately, I've managed to make the time changes without modifying the API, so the point here is moot.  However, for the changeset that adds data offsets, I've tried adding a few additional arguments to API functions (hivex_value_*) so I could record data offsets and lengths, and then pass those offsets and lengths to the visitor functions.  This will probably be better explained with a patch, I'll try to get that to you very soon.

--Alex


> 
> If you mean using node_start_with_time instead of node_start2, then
> yes that's a better name.
> 
> Rich.
> 
> -- 
> Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
> libguestfs lets you edit virtual machines.  Supports shell scripting,
> bindings from many languages.  http://libguestfs.org





More information about the Libguestfs mailing list