Вот такой туториал ;-)

On Thu, 27 Oct 2005 10:36:53 -0500, Steve Dobbelstein wrote:

> John Antypas <[EMAIL PROTECTED]> wrote on 10/26/2005 08:31:17 PM:
> 
>> EVMS'ers,
>>
>> I've got some of this, but I'm missing the obvious I'm sure.  I'm trying
>> to tie EVMS into higher-level interfaces.  For many tasks, the EVMS CLI
>> works fine, but if I want to do someting like scan the object tree,
>> finding hte various childrne of a given object, say a disk, all the way
>> to the end, I need it appers, to use the API.
>>
>> I understand the this involes getting the handles of the object in
>> quetion, but it's the data structures that throw me.  Is there anywhere,
>> or anyone, that cna show me a map of what a handle returns, and how I
>> follow it up in the data structure.  I'm hoping to map all of this into
>> JAVA objects.
>>
>> Any ideas?
> 
> Hi, John.
> 
> Here is an introductory description of how it works.
> 
> Call evms_get_info() to get information on the entity behind the handle.
> evms_get_info() returns a pointer to a handle_object_info_t, defined in
> include/appstructs.h.
> 
> typedef struct handle_object_info_s {
>       object_type_t   type;
>       object_info_t   info;
> } __attribute__ ((packed)) handle_object_info_t;
> 
> The handle_object_info_t contains a "type" followed by "info" which is an
> object_info_t union.  The type says which field of the union is used.  The
> types are defined in include/common.h
> 
> typedef enum {
>       PLUGIN      = (1<<0),
>       DISK        = (1<<1),
>       SEGMENT     = (1<<2),
>       REGION      = (1<<3),
>       EVMS_OBJECT = (1<<4),
>       CONTAINER   = (1<<5),
>       VOLUME      = (1<<6),
>       TASK        = (1<<7)
> } object_type_t;
> 
> For example, a type of SEGMENT says to use the .segment field of the
> union. The .segment field is a storage_object_info_t (defined in
> include/appstructs.h), which contains information on a storage object, in
> this example, information about the segment.  The storage object_info_t
> contains information such as the handle of the plug-in that owns the
> object, a handle array of the object's parents, a handle array of the
> object's children, a handle of the container that consumes the object (if
> any), a handle of the container that produces the object (if any), etc.
> 
> typedef struct storage_object_info_s {
>       object_handle_t         handle;                 /* Handle of this
> object */
>       object_type_t           object_type;            /* SEGMENT, REGION,
> DISK ,... */
>       data_type_t             data_type;        /* DATA_TYPE,
> META_DATA_TYPE, FREE_SPACE_TYPE */
>       u_int32_t               dev_major;        /* Device major number */
>       u_int32_t               dev_minor;        /* Device minor number */
>       object_handle_t         disk_group;       /* Disk group in which
>       this
> object resides */
>       plugin_handle_t         plugin;                 /* Handle of the
> plug-in that manages */
>                                           /* this storage object */
>       object_handle_t         producing_container;    /* storage_container
> that produced this object */
>       object_handle_t         consuming_container;    /* storage_container
> that consumed this object */
>       handle_array_t        * parent_objects;         /* List of parent
> objects, filled in by parent   */
>       handle_array_t        * child_objects;          /* List of objects
> that this object comprises */
>       u_int32_t               flags;                  /* Defined by
> SOFLAG_???? defines */
>       char                    name[EVMS_NAME_SIZE+1]; /* Object's name */
>       lba_t                   start;                  /* Relative starting
> block of this object */
>       sector_count_t          size;             /* Size of the storage
> object in sectors */
>       geometry_t              geometry;         /* Optional object
>       geometry
> */
>       object_handle_t         volume;                 /* Volume to which
> this object belongs */
> } __attribute__ ((packed)) storage_object_info_t;
> 
> Here is a sample function for displaying the name of the entity
> represented by a handle.
> 
> int display_name(engine_handle_t handle) {
> 
>       int rc;
>       handle_object_info_t *info = NULL;
> 
>       rc = evms_get_info(handle, &info);
>       if (rc != 0) {
>             printf("Could not get info about handle %d.  Error code is %d:
> %s\n",
>                    handle, rc, evms_strerror(rc));
>             return rc;
>       }
>       }
>       switch (info->type) {
>       case DISK:
>             printf("Handle %d is for disk %s.\n",
>                    handle, info->info.disk.name);
>             break;
>       case SEGMENT:
>             printf("Handle %d is for segment %s.\n",
>                    handle, info->info.segment.name);
>             break;
>       case REGION:
>             printf("Handle %d is for region %s.\n",
>                    handle, info->info.region.name);
>             break;
>       case EVMS_OBJECT:
>             printf("Handle %d is for EVMS object %s.\n",
>                    handle, info->info.object.name);
>             break;
>       case CONTAINER:
>             printf("Handle %d is for container %s.\n",
>                    handle, info->info.container.name);
>             break;
>       case VOLUME:
>             printf("Handle %d is for volume %s.\n",
>                    handle, info->info.volume.name);
>             break;
>       case PLUGIN:
>             printf("Handle %d is for plug-in %s.\n",
>                    handle, info->info.plugin.long_name);
>             break;
>       default:
>             printf("Handle %d is for a thing of unknown type %x.\n",
>                    handle, info->type);
>             break;
>       }
>       }
>       evms_free(info);
> 
>       return rc;
> }
> }
> Once you get the info for a handle you can then call evms_get_info() for
> any of the handles contained in the info.  (The following code is for
> illustration.  I typed it into the email.  I'm not sure if it will
> actually compile.)
> 
> engine_handle_t segment_handle;
> handle_object_info_t *segment_info = NULL; handle_object_info_t
> *consuming_container_info = NULL; handle_object_info_t *parent_info =
> NULL; int i;
> 
> rc = evms_get_info(segment_handle, &segment_info); if (rc == 0) {
>       if (segment_info->info.segment.consuming_container != 0) {
>             rc =
> evms_get_info(segment_info->info.segment.consuming_container,
>                   &consuming_container_info);
> 
>             printf("Segment %s is consumed by container %s.\n",
>                   segment_info->info.segment.name,
>                   consuming_container_info->info.container.name);
>       }
>       }
>       printf("Segment %s has %d parent(s)\n",
>             segment_info->info.segment.name,
>             segment_info->info.segment.parent_objects->count);
>       for (i=0; i < segment_info->info.segment.parent_objects->count; i++)
> {
>             rc =
> evms_get_info(segment_info->info.segment.parent_objects->handle[i],
>                   &parent_info);
>             printf("Parent object %d is %s\n",
>                   i,
>                   parent_info->info.segment.name);
>       }
>       }
> }
> See ui/utils/evms_query.c for an example of how to walk the object tree
> structure using engine handles and the info structures.
> 
> That's a start.  Hope it helps.  Post if you have any further questions.
> 
> Steve D.
> 
> 
> 
> ------------------------------------------------------- This SF.Net email
> is sponsored by the JBoss Inc. Get Certified Today * Register for a JBoss
> Training Course Free Certification Exam for All Training Attendees Through
> End of 2005 Visit http://www.jboss.com/services/certification for more
> information _______________________________________________ Evms-devel
> mailing list
> [EMAIL PROTECTED]
> To subscribe/unsubscribe, please visit:
> https://lists.sourceforge.net/lists/listinfo/evms-devel

_______________________________________________
Devel-conf mailing list
[email protected]
https://lists.altlinux.org/mailman/listinfo/devel-conf

Ответить