[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] New command checktime
From: |
Bean |
Subject: |
Re: [PATCH] New command checktime |
Date: |
Wed, 13 Aug 2008 01:13:59 +0800 |
On Tue, Aug 12, 2008 at 5:07 AM, Marco Gerards <address@hidden> wrote:
>
>> * commands/date.c: New file.
>>
>> * commands/datetime.c: Likewise.
>
> This is not a command. But I do not really know a good place for this
> module...
How about the /hook directory ?
>
>> * include/grub/datetime.h: Likewise.
>>
>> * include/grub/i386/cmos.h: Likewise.
>>
>> * kern/i386/datetime.c: Likewise.
>>
>> * kern/efi/datetime.c: Likewise.
>
> Does this really belong in the kernel? You created lib/ (which I
> still not might agree with, but ok ;)). But that might be a better
> place than here.
Ok.
>> + "Sunday",
>> + "Monday",
>> + "Tueday",
>
> Tuesday
>
>> + "Wednesday",
>> + "Thusday",
>
> Thursday
Oh, fixed.
>> +int
>> +grub_get_weekday (struct grub_datetime *datetime)
>> +{
>> + int a, y, m;
>> +
>> + a = (14 - datetime->month) / 12;
>> + y = datetime->year - a;
>> + m = datetime->month + 12 * a - 2;
>> +
>> + return (datetime->day + y + y / 4 - y / 100 + y / 400 + (31 * m / 12)) %
>> 7;
>
> Wow ;-)
>
> Does this deal with leap years?
It should be able to handle leap years.
>> +GRUB_MOD_FINI(datetime)
>> +{
>> + int i;
>> +
>> + for (i = 0; i < 7; i++)
>> + grub_register_variable_hook (grub_datetime_names[i], 0, 0);
>
> Perhaps it is even wise to unset the variables? As the contents are
> no longer valid.
Right, fixed.
>> +grub_err_t
>> +grub_get_datetime (struct grub_datetime *datetime)
>> +{
>> + grub_efi_status_t status;
>> + struct grub_efi_time efi_time;
>> +
>> + status = efi_call_2 (grub_efi_system_table->runtime_services->get_time,
>> + &efi_time, 0);
>> +
>> + if (status)
>> + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "can\'t get datetime");
>
> You implemented the function here!
Ok, change the error code.
>> +grub_err_t
>> +grub_set_datetime (struct grub_datetime *datetime, int mask)
>> +{
>> + grub_efi_status_t status;
>> + struct grub_efi_time efi_time;
>
> Why do you use a mask? Isn't it better to let the caller to deal with
> this by calling grub_get_datetime? Perhaps I do not see the results
> of dealing with this either way.
Ok then.
2008-08-12 Bean <address@hidden>
* conf/i386-pc.rmk (pkglib_MODULES): Add datetime.mod and date.mod.
(datetime_mod_SOURCES): New macro.
(datetime_mod_CFLAGS): Likewise.
(datetime_mod_LDFLAGS): Likewise.
(date_mod_SOURCES): Likewise.
(date_mod_CFLAGS): Likewise.
(date_mod_LDFLAGS): Likewise.
* conf/i386-coreboot.rmk (pkglib_MODULES): Add datetime.mod and
date.mod.
(datetime_mod_SOURCES): New macro.
(datetime_mod_CFLAGS): Likewise.
(datetime_mod_LDFLAGS): Likewise.
(date_mod_SOURCES): Likewise.
(date_mod_CFLAGS): Likewise.
(date_mod_LDFLAGS): Likewise.
* conf/i386-ieee1275.rmk (pkglib_MODULES): Add datetime.mod and
date.mod.
(datetime_mod_SOURCES): New macro.
(datetime_mod_CFLAGS): Likewise.
(datetime_mod_LDFLAGS): Likewise.
(date_mod_SOURCES): Likewise.
(date_mod_CFLAGS): Likewise.
(date_mod_LDFLAGS): Likewise.
* conf/i386-efi.rmk (pkglib_MODULES): Add datetime.mod and date.mod.
(datetime_mod_SOURCES): New macro.
(datetime_mod_CFLAGS): Likewise.
(datetime_mod_LDFLAGS): Likewise.
(date_mod_SOURCES): Likewise.
(date_mod_CFLAGS): Likewise.
(date_mod_LDFLAGS): Likewise.
* conf/x86_64-efi.rmk (pkglib_MODULES): Add datetime.mod and date.mod.
(datetime_mod_SOURCES): New macro.
(datetime_mod_CFLAGS): Likewise.
(datetime_mod_LDFLAGS): Likewise.
(date_mod_SOURCES): Likewise.
(date_mod_CFLAGS): Likewise.
(date_mod_LDFLAGS): Likewise.
* commands/date.c: New file.
* hook/datetime.c: Likewise.
* include/grub/lib/datetime.h: Likewise.
* include/grub/i386/cmos.h: Likewise.
* lib/i386/datetime.c: Likewise.
* lib/efi/datetime.c: Likewise.
--
Bean
date_4.diff
Description: Text Data
- Re: [PATCH] New command checktime, (continued)
- Re: [PATCH] New command checktime, Bean, 2008/08/09
- Re: [PATCH] New command checktime, Robert Millan, 2008/08/10
- Re: [PATCH] New command checktime, Bean, 2008/08/10
- Re: [PATCH] New command checktime, Isaac Dupree, 2008/08/10
- Re: [PATCH] New command checktime, Robert Millan, 2008/08/10
- Re: [PATCH] New command checktime, Robert Millan, 2008/08/07
Re: [PATCH] New command checktime, Marco Gerards, 2008/08/10
- Re: [PATCH] New command checktime, Bean, 2008/08/11
- Re: [PATCH] New command checktime, Robert Millan, 2008/08/11
- Re: [PATCH] New command checktime, Marco Gerards, 2008/08/11
- Re: [PATCH] New command checktime,
Bean <=
- Re: [PATCH] New command checktime, Marco Gerards, 2008/08/12
- Re: [PATCH] New command checktime, Bean, 2008/08/12
- Re: [PATCH] New command checktime, Bean, 2008/08/12
- Re: [PATCH] New command checktime, Marco Gerards, 2008/08/13
- Re: [PATCH] New command checktime, Bean, 2008/08/15