Re: [libosinfo 3/3] API to retrieve checksum for driver files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 12, 2012 at 5:24 PM, Christophe Fergeau <cfergeau@xxxxxxxxxx> wrote:
> On Wed, Dec 12, 2012 at 04:04:04PM +0200, Zeeshan Ali (Khattak) wrote:
>> On Wed, Dec 12, 2012 at 11:13 AM, Christophe Fergeau
>> <cfergeau@xxxxxxxxxx> wrote:
>> > On Wed, Dec 12, 2012 at 03:21:30AM +0200, Zeeshan Ali (Khattak) wrote:
>> >> From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx>
>> >>
>> >> Keeping this API agnostic of MD5 so that we can later switch to another
>> >> hashing alogirthm without breaking the API.
>> >
>> > algorithm
>> >
>> >>  /**
>> >> + * osinfo_device_driver_get_file_checksum:
>> >> + * @driver: a #OsinfoDeviceDriver instance
>> >> + * @file: The name of the driver file for which checksum is requested
>> >> + * @checksum_type: (out) (allow-none): place-holder to return type of the
>> >> + *                                     checksum into, or NULL
>> >> + *
>> >> + * Retrieves the expected checksum for the given driver file @file.
>> >> + *
>> >> + * Returns: The file checksum
>> >> + */
>> >> +const gchar *osinfo_device_driver_get_file_checksum(OsinfoDeviceDriver *driver,
>> >> +                                                    const gchar *file,
>> >> +                                                    GChecksumType *checksum_type)
>> >
>> > I'd prefer a
>> > gboolean osinfo_device_driver_check_file(OsinfoDeviceDriver *driver, const char *file, GError **error);
>> > rather than forcing every app to do md5/sha1/... checks by hands while we
>> > can easily do it for them.
>>
>> Thats the idea I started with but then I thought checksum might have
>> some other uses.
>
> s/uses/abuses? ;) Apps who want to get to the checksum can always use raw
> osinfo_entity calls, so I'm not sure we need to promote this use in the
> API.

Except that there is no way to get to checksums through that API.

>> Also what if app wants/needs to check data before
>> pushing it into a file (this is what I'm doing in Boxes). Since glib
>> doesn't provide simple API for computing checksum for a file (only for
>> a buffer in memory), perhaps its a good idea to provide this
>> _check_file() API in addition to exposing checksum to app. Keep in
>> mind that _check_file() does I/O and therefore we must provide async
>> variant too then.
>
> Ah, good points. gboolean osinfo_device_driver_check_file_data(OsinfoDeviceDriver
> *driver, const guint8 *data, gsize len, GError **error) would work for me
> to, and would avoid the need for async variants.

Well then we are not really providing much help in case of validation
of already saved file (app can use some API that allows to directly
download to a file e.g) and glib already provides one function to do
the validation of data given the checksum info.

-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list


[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux