* Made set_timezone() argument const - it's not supposed to mess with it.
* Renamed time.c to time.cpp. * set_timezone() now uses localtime_r() instead of localtime(), and will also no longer fail in case there was no timezone symlink before. * Cleaned up OS.h header. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31371 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+53
-50
@@ -1,11 +1,11 @@
|
|||||||
/* Kernel specific structures and functions
|
/*
|
||||||
*
|
* Copyright 2004-2009, Haiku Inc. All Rights Reserved.
|
||||||
* Copyright 2004-2006, Haiku Inc. All Rights Reserved.
|
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _OS_H
|
#ifndef _OS_H
|
||||||
#define _OS_H
|
#define _OS_H
|
||||||
|
|
||||||
|
//! Kernel specific structures and functions
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* System constants */
|
/* System constants */
|
||||||
|
|
||||||
#define B_OS_NAME_LENGTH 32
|
#define B_OS_NAME_LENGTH 32
|
||||||
@@ -37,7 +36,7 @@ enum {
|
|||||||
| B_TIMEOUT_REAL_TIME_BASE
|
| B_TIMEOUT_REAL_TIME_BASE
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* Types */
|
/* Types */
|
||||||
|
|
||||||
typedef int32 area_id;
|
typedef int32 area_id;
|
||||||
@@ -47,7 +46,6 @@ typedef int32 team_id;
|
|||||||
typedef int32 thread_id;
|
typedef int32 thread_id;
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* Areas */
|
/* Areas */
|
||||||
|
|
||||||
typedef struct area_info {
|
typedef struct area_info {
|
||||||
@@ -82,10 +80,11 @@ typedef struct area_info {
|
|||||||
#define B_READ_AREA 1
|
#define B_READ_AREA 1
|
||||||
#define B_WRITE_AREA 2
|
#define B_WRITE_AREA 2
|
||||||
|
|
||||||
extern area_id create_area(const char *name, void **startAddress, uint32 addressSpec,
|
extern area_id create_area(const char *name, void **startAddress,
|
||||||
size_t size, uint32 lock, uint32 protection);
|
uint32 addressSpec, size_t size, uint32 lock,
|
||||||
extern area_id clone_area(const char *name, void **destAddress, uint32 addressSpec,
|
uint32 protection);
|
||||||
uint32 protection, area_id source);
|
extern area_id clone_area(const char *name, void **destAddress,
|
||||||
|
uint32 addressSpec, uint32 protection, area_id source);
|
||||||
extern area_id find_area(const char *name);
|
extern area_id find_area(const char *name);
|
||||||
extern area_id area_for(void *address);
|
extern area_id area_for(void *address);
|
||||||
extern status_t delete_area(area_id id);
|
extern status_t delete_area(area_id id);
|
||||||
@@ -103,7 +102,6 @@ extern status_t _get_next_area_info(team_id team, int32 *cookie,
|
|||||||
_get_next_area_info((team), (cookie), (areaInfo), sizeof(*(areaInfo)))
|
_get_next_area_info((team), (cookie), (areaInfo), sizeof(*(areaInfo)))
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* Ports */
|
/* Ports */
|
||||||
|
|
||||||
typedef struct port_info {
|
typedef struct port_info {
|
||||||
@@ -117,24 +115,28 @@ typedef struct port_info {
|
|||||||
|
|
||||||
extern port_id create_port(int32 capacity, const char *name);
|
extern port_id create_port(int32 capacity, const char *name);
|
||||||
extern port_id find_port(const char *name);
|
extern port_id find_port(const char *name);
|
||||||
extern ssize_t read_port(port_id port, int32 *code, void *buffer, size_t bufferSize);
|
extern ssize_t read_port(port_id port, int32 *code, void *buffer,
|
||||||
extern ssize_t read_port_etc(port_id port, int32 *code, void *buffer, size_t bufferSize,
|
size_t bufferSize);
|
||||||
uint32 flags, bigtime_t timeout);
|
extern ssize_t read_port_etc(port_id port, int32 *code, void *buffer,
|
||||||
extern status_t write_port(port_id port, int32 code, const void *buffer, size_t bufferSize);
|
size_t bufferSize, uint32 flags, bigtime_t timeout);
|
||||||
|
extern status_t write_port(port_id port, int32 code, const void *buffer,
|
||||||
|
size_t bufferSize);
|
||||||
extern status_t write_port_etc(port_id port, int32 code, const void *buffer,
|
extern status_t write_port_etc(port_id port, int32 code, const void *buffer,
|
||||||
size_t bufferSize, uint32 flags, bigtime_t timeout);
|
size_t bufferSize, uint32 flags, bigtime_t timeout);
|
||||||
extern status_t close_port(port_id port);
|
extern status_t close_port(port_id port);
|
||||||
extern status_t delete_port(port_id port);
|
extern status_t delete_port(port_id port);
|
||||||
|
|
||||||
extern ssize_t port_buffer_size(port_id port);
|
extern ssize_t port_buffer_size(port_id port);
|
||||||
extern ssize_t port_buffer_size_etc(port_id port, uint32 flags, bigtime_t timeout);
|
extern ssize_t port_buffer_size_etc(port_id port, uint32 flags,
|
||||||
|
bigtime_t timeout);
|
||||||
extern ssize_t port_count(port_id port);
|
extern ssize_t port_count(port_id port);
|
||||||
extern status_t set_port_owner(port_id port, team_id team);
|
extern status_t set_port_owner(port_id port, team_id team);
|
||||||
|
|
||||||
/* system private, use the macros instead */
|
/* system private, use the macros instead */
|
||||||
extern status_t _get_port_info(port_id port, port_info *portInfo, size_t portInfoSize);
|
extern status_t _get_port_info(port_id port, port_info *portInfo,
|
||||||
extern status_t _get_next_port_info(team_id team, int32 *cookie, port_info *portInfo,
|
|
||||||
size_t portInfoSize);
|
size_t portInfoSize);
|
||||||
|
extern status_t _get_next_port_info(team_id team, int32 *cookie,
|
||||||
|
port_info *portInfo, size_t portInfoSize);
|
||||||
|
|
||||||
#define get_port_info(port, info) \
|
#define get_port_info(port, info) \
|
||||||
_get_port_info((port), (info), sizeof(*(info)))
|
_get_port_info((port), (info), sizeof(*(info)))
|
||||||
@@ -158,10 +160,9 @@ extern status_t _get_port_message_info_etc(port_id port,
|
|||||||
bigtime_t timeout);
|
bigtime_t timeout);
|
||||||
|
|
||||||
#define get_port_message_info_etc(port, info, flags, timeout) \
|
#define get_port_message_info_etc(port, info, flags, timeout) \
|
||||||
_get_port_message_info_etc((port), (info), sizeof(*(info)), flags, \
|
_get_port_message_info_etc((port), (info), sizeof(*(info)), flags, timeout)
|
||||||
timeout)
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* Semaphores */
|
/* Semaphores */
|
||||||
|
|
||||||
typedef struct sem_info {
|
typedef struct sem_info {
|
||||||
@@ -194,21 +195,23 @@ enum {
|
|||||||
extern sem_id create_sem(int32 count, const char *name);
|
extern sem_id create_sem(int32 count, const char *name);
|
||||||
extern status_t delete_sem(sem_id id);
|
extern status_t delete_sem(sem_id id);
|
||||||
extern status_t acquire_sem(sem_id id);
|
extern status_t acquire_sem(sem_id id);
|
||||||
extern status_t acquire_sem_etc(sem_id id, int32 count, uint32 flags, bigtime_t timeout);
|
extern status_t acquire_sem_etc(sem_id id, int32 count, uint32 flags,
|
||||||
|
bigtime_t timeout);
|
||||||
extern status_t release_sem(sem_id id);
|
extern status_t release_sem(sem_id id);
|
||||||
extern status_t release_sem_etc(sem_id id, int32 count, uint32 flags);
|
extern status_t release_sem_etc(sem_id id, int32 count, uint32 flags);
|
||||||
/* ToDo: the following two calls are not part of the BeOS API, and might be
|
/* TODO: the following two calls are not part of the BeOS API, and might be
|
||||||
changed or even removed for the final release of Haiku R1 */
|
changed or even removed for the final release of Haiku R1 */
|
||||||
extern status_t switch_sem(sem_id semToBeReleased, sem_id id);
|
extern status_t switch_sem(sem_id semToBeReleased, sem_id id);
|
||||||
extern status_t switch_sem_etc(sem_id semToBeReleased, sem_id id, int32 count,
|
extern status_t switch_sem_etc(sem_id semToBeReleased, sem_id id,
|
||||||
uint32 flags, bigtime_t timeout);
|
int32 count, uint32 flags, bigtime_t timeout);
|
||||||
extern status_t get_sem_count(sem_id id, int32 *threadCount);
|
extern status_t get_sem_count(sem_id id, int32 *threadCount);
|
||||||
extern status_t set_sem_owner(sem_id id, team_id team);
|
extern status_t set_sem_owner(sem_id id, team_id team);
|
||||||
|
|
||||||
/* system private, use the macros instead */
|
/* system private, use the macros instead */
|
||||||
extern status_t _get_sem_info(sem_id id, struct sem_info *info, size_t infoSize);
|
extern status_t _get_sem_info(sem_id id, struct sem_info *info,
|
||||||
extern status_t _get_next_sem_info(team_id team, int32 *cookie, struct sem_info *info,
|
|
||||||
size_t infoSize);
|
size_t infoSize);
|
||||||
|
extern status_t _get_next_sem_info(team_id team, int32 *cookie,
|
||||||
|
struct sem_info *info, size_t infoSize);
|
||||||
|
|
||||||
#define get_sem_info(sem, info) \
|
#define get_sem_info(sem, info) \
|
||||||
_get_sem_info((sem), (info), sizeof(*(info)))
|
_get_sem_info((sem), (info), sizeof(*(info)))
|
||||||
@@ -217,7 +220,6 @@ extern status_t _get_next_sem_info(team_id team, int32 *cookie, struct sem_info
|
|||||||
_get_next_sem_info((team), (cookie), (info), sizeof(*(info)))
|
_get_next_sem_info((team), (cookie), (info), sizeof(*(info)))
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* Teams */
|
/* Teams */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -241,7 +243,8 @@ extern status_t kill_team(team_id team);
|
|||||||
|
|
||||||
/* system private, use macros instead */
|
/* system private, use macros instead */
|
||||||
extern status_t _get_team_info(team_id id, team_info *info, size_t size);
|
extern status_t _get_team_info(team_id id, team_info *info, size_t size);
|
||||||
extern status_t _get_next_team_info(int32 *cookie, team_info *info, size_t size);
|
extern status_t _get_next_team_info(int32 *cookie, team_info *info,
|
||||||
|
size_t size);
|
||||||
|
|
||||||
#define get_team_info(id, info) \
|
#define get_team_info(id, info) \
|
||||||
_get_team_info((id), (info), sizeof(*(info)))
|
_get_team_info((id), (info), sizeof(*(info)))
|
||||||
@@ -263,12 +266,13 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* system private, use macros instead */
|
/* system private, use macros instead */
|
||||||
extern status_t _get_team_usage_info(team_id team, int32 who, team_usage_info *info, size_t size);
|
extern status_t _get_team_usage_info(team_id team, int32 who,
|
||||||
|
team_usage_info *info, size_t size);
|
||||||
|
|
||||||
#define get_team_usage_info(team, who, info) \
|
#define get_team_usage_info(team, who, info) \
|
||||||
_get_team_usage_info((team), (who), (info), sizeof(*(info)))
|
_get_team_usage_info((team), (who), (info), sizeof(*(info)))
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* Threads */
|
/* Threads */
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -311,7 +315,8 @@ typedef status_t (*thread_func)(void *);
|
|||||||
#define thread_entry thread_func
|
#define thread_entry thread_func
|
||||||
/* thread_entry is for backward compatibility only! Use thread_func */
|
/* thread_entry is for backward compatibility only! Use thread_func */
|
||||||
|
|
||||||
extern thread_id spawn_thread(thread_func, const char *name, int32 priority, void *data);
|
extern thread_id spawn_thread(thread_func, const char *name, int32 priority,
|
||||||
|
void *data);
|
||||||
extern status_t kill_thread(thread_id thread);
|
extern status_t kill_thread(thread_id thread);
|
||||||
extern status_t resume_thread(thread_id thread);
|
extern status_t resume_thread(thread_id thread);
|
||||||
extern status_t suspend_thread(thread_id thread);
|
extern status_t suspend_thread(thread_id thread);
|
||||||
@@ -319,14 +324,16 @@ extern status_t suspend_thread(thread_id thread);
|
|||||||
extern status_t rename_thread(thread_id thread, const char *newName);
|
extern status_t rename_thread(thread_id thread, const char *newName);
|
||||||
extern status_t set_thread_priority (thread_id thread, int32 newPriority);
|
extern status_t set_thread_priority (thread_id thread, int32 newPriority);
|
||||||
extern void exit_thread(status_t status);
|
extern void exit_thread(status_t status);
|
||||||
extern status_t wait_for_thread (thread_id thread, status_t *threadReturnValue);
|
extern status_t wait_for_thread (thread_id thread,
|
||||||
|
status_t *threadReturnValue);
|
||||||
extern status_t on_exit_thread(void (*callback)(void *), void *data);
|
extern status_t on_exit_thread(void (*callback)(void *), void *data);
|
||||||
|
|
||||||
extern thread_id find_thread(const char *name);
|
extern thread_id find_thread(const char *name);
|
||||||
|
|
||||||
extern status_t send_data(thread_id thread, int32 code, const void *buffer,
|
extern status_t send_data(thread_id thread, int32 code, const void *buffer,
|
||||||
size_t bufferSize);
|
size_t bufferSize);
|
||||||
extern int32 receive_data(thread_id *sender, void *buffer, size_t bufferSize);
|
extern int32 receive_data(thread_id *sender, void *buffer,
|
||||||
|
size_t bufferSize);
|
||||||
extern bool has_data(thread_id thread);
|
extern bool has_data(thread_id thread);
|
||||||
|
|
||||||
extern status_t snooze(bigtime_t amount);
|
extern status_t snooze(bigtime_t amount);
|
||||||
@@ -345,17 +352,16 @@ extern status_t _get_next_thread_info(team_id team, int32 *cookie,
|
|||||||
_get_next_thread_info((team), (cookie), (info), sizeof(*(info)))
|
_get_next_thread_info((team), (cookie), (info), sizeof(*(info)))
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* Time */
|
/* Time */
|
||||||
|
|
||||||
extern uint32 real_time_clock(void);
|
extern uint32 real_time_clock(void);
|
||||||
extern void set_real_time_clock(uint32 secs_since_jan1_1970);
|
extern void set_real_time_clock(uint32 secsSinceJan1st1970);
|
||||||
extern bigtime_t real_time_clock_usecs(void);
|
extern bigtime_t real_time_clock_usecs(void);
|
||||||
extern status_t set_timezone(char *timezone);
|
extern status_t set_timezone(const char *timezone);
|
||||||
extern bigtime_t system_time(void); /* time since booting in microseconds */
|
extern bigtime_t system_time(void);
|
||||||
|
/* time since booting in microseconds */
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* Alarm */
|
/* Alarm */
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -367,7 +373,6 @@ enum {
|
|||||||
extern bigtime_t set_alarm(bigtime_t when, uint32 flags);
|
extern bigtime_t set_alarm(bigtime_t when, uint32 flags);
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* Debugger */
|
/* Debugger */
|
||||||
|
|
||||||
extern void debugger(const char *message);
|
extern void debugger(const char *message);
|
||||||
@@ -391,7 +396,6 @@ extern void ktrace_printf(const char *format, ...)
|
|||||||
extern void ktrace_vprintf(const char *format, va_list args);
|
extern void ktrace_vprintf(const char *format, va_list args);
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* System information */
|
/* System information */
|
||||||
|
|
||||||
#if __INTEL__
|
#if __INTEL__
|
||||||
@@ -409,10 +413,8 @@ extern void ktrace_vprintf(const char *format, va_list args);
|
|||||||
# define B_MAX_CPU_COUNT 1
|
# define B_MAX_CPU_COUNT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define OBOS_CPU_TYPES
|
|
||||||
|
|
||||||
typedef enum cpu_types {
|
typedef enum cpu_types {
|
||||||
/* ToDo: add latest models */
|
/* TODO: add latest models */
|
||||||
|
|
||||||
/* Motorola/IBM */
|
/* Motorola/IBM */
|
||||||
B_CPU_PPC_UNKNOWN = 0,
|
B_CPU_PPC_UNKNOWN = 0,
|
||||||
@@ -641,7 +643,8 @@ typedef union {
|
|||||||
} regs;
|
} regs;
|
||||||
} cpuid_info;
|
} cpuid_info;
|
||||||
|
|
||||||
extern status_t get_cpuid(cpuid_info *info, uint32 eaxRegister, uint32 cpuNum);
|
extern status_t get_cpuid(cpuid_info *info, uint32 eaxRegister,
|
||||||
|
uint32 cpuNum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -695,17 +698,17 @@ typedef struct {
|
|||||||
int32 max_teams;
|
int32 max_teams;
|
||||||
int32 used_teams;
|
int32 used_teams;
|
||||||
|
|
||||||
char kernel_name[B_FILE_NAME_LENGTH]; /* name of kernel */
|
char kernel_name[B_FILE_NAME_LENGTH];
|
||||||
char kernel_build_date[B_OS_NAME_LENGTH]; /* date kernel built */
|
char kernel_build_date[B_OS_NAME_LENGTH];
|
||||||
char kernel_build_time[B_OS_NAME_LENGTH]; /* time kernel built */
|
char kernel_build_time[B_OS_NAME_LENGTH];
|
||||||
int64 kernel_version; /* version of this kernel */
|
int64 kernel_version;
|
||||||
|
|
||||||
bigtime_t _busy_wait_time; /* reserved for whatever */
|
bigtime_t _busy_wait_time; /* reserved for whatever */
|
||||||
int32 cached_pages;
|
int32 cached_pages;
|
||||||
|
|
||||||
uint32 abi; /* the system API */
|
uint32 abi; /* the system API */
|
||||||
|
|
||||||
int32 pad[2]; /* just in case... */
|
int32 pad[2];
|
||||||
} system_info;
|
} system_info;
|
||||||
|
|
||||||
/* system private, use macro instead */
|
/* system private, use macro instead */
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ MergeObject os_main.o :
|
|||||||
system_info.c
|
system_info.c
|
||||||
team.c
|
team.c
|
||||||
thread.c
|
thread.c
|
||||||
time.c
|
time.cpp
|
||||||
syscalls.S
|
syscalls.S
|
||||||
wait_for_objects.cpp
|
wait_for_objects.cpp
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de.
|
* Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
|
||||||
|
#include <FindDirectory.h>
|
||||||
|
#include <OS.h>
|
||||||
|
|
||||||
#include <commpage_defs.h>
|
#include <commpage_defs.h>
|
||||||
#include <libroot_private.h>
|
#include <libroot_private.h>
|
||||||
#include <real_time_data.h>
|
#include <real_time_data.h>
|
||||||
#include <syscalls.h>
|
#include <syscalls.h>
|
||||||
|
|
||||||
#include <FindDirectory.h>
|
|
||||||
#include <OS.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
static struct real_time_data* sRealTimeData;
|
||||||
#include <string.h>
|
|
||||||
#include <syslog.h>
|
|
||||||
|
|
||||||
|
|
||||||
static struct real_time_data *sRealTimeData;
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -30,6 +31,9 @@ __init_time(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - public API
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
real_time_clock(void)
|
real_time_clock(void)
|
||||||
{
|
{
|
||||||
@@ -53,43 +57,40 @@ set_real_time_clock(uint32 secs)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
set_timezone(char *timezone)
|
set_timezone(const char* timezone)
|
||||||
{
|
{
|
||||||
char path[B_PATH_NAME_LENGTH];
|
char path[B_PATH_NAME_LENGTH];
|
||||||
char tzfilename[B_PATH_NAME_LENGTH];
|
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, -1, true, path,
|
||||||
|
B_PATH_NAME_LENGTH);
|
||||||
|
if (status != B_OK) {
|
||||||
|
syslog(LOG_ERR, "can't find settings directory: %s\n", strerror(status));
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
strlcat(path, "/timezone", sizeof(path));
|
||||||
|
|
||||||
|
if (unlink(path) != 0 && errno != ENOENT) {
|
||||||
|
syslog(LOG_ERR, "can't unlink: %s\n", strerror(errno));
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (symlink(timezone, path) != 0) {
|
||||||
|
syslog(LOG_ERR, "can't symlink: %s\n", strerror(errno));
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
|
||||||
bool isGMT;
|
bool isGMT;
|
||||||
|
_kern_get_tzfilename(NULL, 0, &isGMT);
|
||||||
status_t err;
|
|
||||||
struct tm *tm;
|
|
||||||
time_t t;
|
|
||||||
|
|
||||||
if ((err = find_directory(B_USER_SETTINGS_DIRECTORY, -1, true, path, B_PATH_NAME_LENGTH)) != B_OK) {
|
|
||||||
fprintf(stderr, "can't find settings directory: %s\n", strerror(err));
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
strcat(path, "/timezone");
|
|
||||||
|
|
||||||
err = unlink(path);
|
|
||||||
if (err != B_OK) {
|
|
||||||
fprintf(stderr, "can't unlink: %s\n", strerror(err));
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
err = symlink(timezone, path);
|
|
||||||
if (err != B_OK) {
|
|
||||||
fprintf(stderr, "can't symlink: %s\n", strerror(err));
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
_kern_get_tzfilename(tzfilename, sizeof(tzfilename), &isGMT);
|
|
||||||
_kern_set_tzfilename(timezone, strlen(timezone), isGMT);
|
_kern_set_tzfilename(timezone, strlen(timezone), isGMT);
|
||||||
|
|
||||||
tzset();
|
tzset();
|
||||||
|
|
||||||
time(&t);
|
time_t seconds;
|
||||||
tm = localtime(&t);
|
time(&seconds);
|
||||||
|
struct tm tm;
|
||||||
|
localtime_r(&seconds, &tm);
|
||||||
|
|
||||||
if ((err = _kern_set_timezone(tm->tm_gmtoff, tm->tm_isdst)) < B_OK)
|
return _kern_set_timezone(tm.tm_gmtoff, tm.tm_isdst);
|
||||||
return err;
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user