On Sun, Mar 15, 2015 at 04:04:50PM +0000, Zeeshan Ali (Khattak) wrote: > When creating a media object from an ISO9660 device/image, extract > volume size too along with other other information. > --- > osinfo/osinfo_media.c | 19 ++++++++++++++++--- > 1 file changed, 16 insertions(+), 3 deletions(-) > > diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c > index e86df11..d9f3e0b 100644 > --- a/osinfo/osinfo_media.c > +++ b/osinfo/osinfo_media.c > @@ -46,11 +46,15 @@ struct _PrimaryVolumeDescriptor { > guint8 ignored[8]; > gchar system[MAX_SYSTEM]; /* System ID */ > gchar volume[MAX_VOLUME]; /* Volume ID */ > - guint8 ignored2[246]; > + guint8 ignored2[8]; > + gint32 volume_space_size[2]; Why not guint32 ? At least wikipedia says that all numbers in ISO9660 images are unsigned (I could not find the place where this is explicitly stated in the spec though). > + guint8 ignored3[40]; > + gint16 logical_blk_size[2]; > + guint8 ignored4[186]; > gchar publisher[MAX_PUBLISHER]; /* Publisher ID */ > - guint8 ignored3[128]; > + guint8 ignored5[128]; > gchar application[MAX_APPLICATION]; /* Application ID */ > - guint8 ignored4[1346]; > + guint8 ignored6[1346]; > }; > > /* the PrimaryVolumeDescriptor struct must exactly 2048 bytes long > @@ -677,6 +681,8 @@ static void on_svd_read(GObject *source, > GError *error = NULL; > CreateFromLocationAsyncData *data; > gssize ret; > + guint8 index; > + gint64 vol_size; > > data = (CreateFromLocationAsyncData *)user_data; > > @@ -745,6 +751,13 @@ static void on_svd_read(GObject *source, > OSINFO_MEDIA_PROP_APPLICATION_ID, > data->pvd.application); > > + index = (G_BYTE_ORDER == G_LITTLE_ENDIAN)? 0 : 1; > + vol_size = ((gint64) data->pvd.volume_space_size[index]) * > + data->pvd.logical_blk_size[index]; > + osinfo_entity_set_param_int64(OSINFO_ENTITY(media), > + OSINFO_MEDIA_PROP_VOLUME_SIZE, > + vol_size); > + > EXIT: > if (error != NULL) > g_simple_async_result_take_error(data->res, error); > -- > 2.1.0 > > _______________________________________________ > Libosinfo mailing list > Libosinfo@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/libosinfo
Attachment:
pgpFydDxipyUW.pgp
Description: PGP signature
_______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo