hwclock.c revision 2f6a59070559786428d9eaf199ae3d61772b2225
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering This file is part of systemd.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering Copyright 2010-2012 Lennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering systemd is free software; you can redistribute it and/or modify it
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering under the terms of the GNU Lesser General Public License as published by
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering (at your option) any later version.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering systemd is distributed in the hope that it will be useful, but
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering Lesser General Public License for more details.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering You should have received a copy of the GNU Lesser General Public License
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fd = open("/dev/rtc", O_RDONLY|O_CLOEXEC);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering /* This leaves the timezone fields of struct tm
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * uninitialized! */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering /* We don't know daylight saving, so we reset this in order not
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * to confuse mktime(). */
599659860c770058f2eb04d578c521c16e0b1853Lennart Poettering * The third line of adjtime is "UTC" or "LOCAL" or nothing.
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmekint hwclock_set_timezone(int *min) {
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers assert_se(clock_gettime(CLOCK_REALTIME, &ts) == 0);
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek tz.tz_minuteswest = -minutesdelta;
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek * If the hardware clock does not run in UTC, but in local time:
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek * The very first time we set the kernel's timezone, it will warp
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen * the clock so that it runs in UTC instead of local time.
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers * The very first time we set the kernel's timezone, it will warp
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers * the clock. Do a dummy call here, so the time warping is sealed
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * and we set only the timezone with next call.