summaryrefslogtreecommitdiff
authorsandman <sandman>2002-06-26 17:42:48 (UTC)
committer sandman <sandman>2002-06-26 17:42:48 (UTC)
commit1ddf9aa5ffc8dbb4ba290fa6a439b2d7681a0038 (patch) (side-by-side diff)
treed34f5076bfd68ed6bdae0af1a475d9118fef3879
parent18905bcc671622ab11b4e3d4447e4cd34f7308ee (diff)
downloadopie-1ddf9aa5ffc8dbb4ba290fa6a439b2d7681a0038.zip
opie-1ddf9aa5ffc8dbb4ba290fa6a439b2d7681a0038.tar.gz
opie-1ddf9aa5ffc8dbb4ba290fa6a439b2d7681a0038.tar.bz2
The embedix arm-linux-strip does not accept -s but --strip-all (weird)
Fixed a RTC get time ioctl bug in opiealarm.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/opiealarm/Makefile2
-rw-r--r--core/opiealarm/opiealarm.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/core/opiealarm/Makefile b/core/opiealarm/Makefile
index e988abf..f20d451 100644
--- a/core/opiealarm/Makefile
+++ b/core/opiealarm/Makefile
@@ -1,26 +1,26 @@
DESTDIR=../../bin
CROSS:=arm-linux-
CC :=$(CROSS)gcc
LD :=$(CROSS)gcc
STRIP:=$(CROSS)strip
CFLAGS:=-O2
LDFLAGS:=
all: $(DESTDIR)/opiealarm $(DESTDIR)/opieatd
$(DESTDIR)/opiealarm: opiealarm.c
$(CC) $(CFLAGS) opiealarm.c -o $(DESTDIR)/opiealarm $(LDFLAGS)
- $(STRIP) -s $(DESTDIR)/opiealarm
+ $(STRIP) --strip-all $(DESTDIR)/opiealarm
chmod u+s $(DESTDIR)/opiealarm
chown root $(DESTDIR)/opiealarm 2>/dev/null || echo -e "\nopiealarm must be owned by root to work correctly.\n"
$(DESTDIR)/opieatd: opieatd
cp opieatd $(DESTDIR)/opieatd
chmod +x $(DESTDIR)/opieatd
clean:
-rm -f *~ core
diff --git a/core/opiealarm/opiealarm.c b/core/opiealarm/opiealarm.c
index 71367b3..ce0103e 100644
--- a/core/opiealarm/opiealarm.c
+++ b/core/opiealarm/opiealarm.c
@@ -182,129 +182,129 @@ int main ( int argc, char **argv )
// kill running opiealarm
opiealarm_was_running = kill_with_pidfile ( );
remove_pidfile ( );
switch ( mode ) {
case 'r': return resume ( ac_resusp );
case 's':
default : return suspend ( fix_rtc );
}
return 0;
}
int suspend ( int fix_rtc )
{
FILE *fp;
char buf [64];
time_t alrt, syst, rtct;
struct tm alr, sys, rtc;
int fd;
int rtc_sys_diff;
if ( !fork_with_pidfile ( ))
return 3;
log = fopen ( "/tmp/opiealarm.log", "w" );
log_msg ( "STARTING\n" );
if (!( fp = fopen ( "/etc/resumeat", "r" )))
error_msg_and_die ( 1, "/etc/resumeat" );
if ( !fgets ( buf, sizeof( buf ) - 1, fp ))
error_msg_and_die ( 1, "/etc/resumeat" );
fclose ( fp );
alrt = atoi ( buf );
if ( alrt == 0 )
error_msg_and_die ( 0, "/etc/resumeat contains an invalid time description" );
/* subtract 5 sec from event time... */
alrt -= 5;
if ( log )
fprintf ( log, "Setting RTC alarm to %d\n", alrt );
tzset ( );
alr = *gmtime ( &alrt );
// get system time
time ( &syst );
sys = *localtime ( &syst );
// Write alarm time to RTC
if (( fd = open ( "/dev/misc/rtc", O_RDWR )) < 0 )
error_msg_and_die ( 1, "/dev/misc/rtc" );
// get RTC time
memset ( &rtc, 0, sizeof ( struct tm ));
- if ( ioctl ( fd, RTC_ALM_SET, &rtc ) < 0 )
+ if ( ioctl ( fd, RTC_RD_TIME, &rtc ) < 0 )
error_msg_and_die ( 1, "ioctl RTC_RD_TIME" );
rtct = mktime ( &rtc );
fprintf ( log, "System time: %02d.%02d.%04d %02d:%02d:%02d DST: %d (TZ: %s, offset: %d)\n", sys. tm_mday, sys. tm_mon + 1, sys. tm_year + 1900, sys. tm_hour, sys. tm_min, sys. tm_sec, sys. tm_isdst, sys. tm_zone, sys. tm_gmtoff );
fprintf ( log, "RTC time: %02d.%02d.%04d %02d:%02d:%02d DST: %d (TZ: %s, offset: %d)\n", rtc. tm_mday, rtc. tm_mon + 1, rtc. tm_year + 1900, rtc. tm_hour, rtc. tm_min, rtc. tm_sec, rtc. tm_isdst, rtc. tm_zone, rtc. tm_gmtoff );
fprintf ( log, "Wakeup time: %02d.%02d.%04d %02d:%02d:%02d DST: %d (TZ: %s, offset: %d)\n", alr. tm_mday, alr. tm_mon + 1, alr. tm_year + 1900, alr. tm_hour, alr. tm_min, alr. tm_sec, alr. tm_isdst, alr. tm_zone, alr. tm_gmtoff );
fprintf ( log, "System/RTC diff: %d seconds\n", ( syst - rtct ) - sys. tm_gmtoff );
rtc_sys_diff = ( syst - rtct ) - sys. tm_gmtoff;
if ( fix_rtc && (( rtc_sys_diff < -4 ) || ( rtc_sys_diff > 4 ))) {
struct tm set;
set = *gmtime ( &syst );
fprintf ( log, "Correcting RTC: %d seconds\n", rtc_sys_diff );
if ( ioctl ( fd, RTC_SET_TIME, &set ) < 0 )
error_msg_and_die ( 1, "ioctl RTC_SET_TIME" );
}
// set alarm time
if ( ioctl ( fd, RTC_ALM_SET, &alr ) < 0 )
error_msg_and_die ( 1, "ioctl RTC_ALM_SET" );
// enable alarm irq
if ( ioctl ( fd, RTC_AIE_ON, 0 ) < 0 )
error_msg_and_die ( 1, "ioctl RTC_AIE_ON" );
log_msg ( "SLEEPING\n" );
// wait for alarm irq
if ( read ( fd, buf, sizeof( unsigned long )) < 0 )
error_msg_and_die ( 1, "read rtc alarm" );
log_msg ( "WAKEUP\n" );
// disable alarm irq
if ( ioctl ( fd, RTC_AIE_OFF, 0 ) < 0 )
error_msg_and_die ( 1, "ioctl RTC_AIE_OFF" );
close ( fd );
log_msg ( "EXITING\n" );
fclose ( log );
remove_pidfile ( );
return 0;
}
int onac ( void )
{
FILE *fp;
int on = 0;
if (( fp = fopen ( APMFILE, "r" ))) {
int ac = 0;
if ( fscanf ( fp, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%*x 0x%*x %*d%% %*i %*c", &ac ) == 1 )
on = ( ac == 0x01 ) ? 1 : 0;