CN103744650A - Method of supporting daylight-saving time through Linux kernel - Google Patents

Method of supporting daylight-saving time through Linux kernel Download PDF

Info

Publication number
CN103744650A
CN103744650A CN201310698007.0A CN201310698007A CN103744650A CN 103744650 A CN103744650 A CN 103744650A CN 201310698007 A CN201310698007 A CN 201310698007A CN 103744650 A CN103744650 A CN 103744650A
Authority
CN
China
Prior art keywords
dst
daylight
time
module
saving time
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201310698007.0A
Other languages
Chinese (zh)
Inventor
陈真
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Gongjin Electronics Co Ltd
Original Assignee
Shenzhen Gongjin Electronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Gongjin Electronics Co Ltd filed Critical Shenzhen Gongjin Electronics Co Ltd
Priority to CN201310698007.0A priority Critical patent/CN103744650A/en
Publication of CN103744650A publication Critical patent/CN103744650A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention provides a method of supporting the daylight-saving time through a Linux kernel. The method comprises the following steps that a, a DST module is newly built in the Linux kernel and is initialized, a /proc/net/tbs_dst interface is built; b, the daylight-saving time is set in an application layer; c, the kernel reads a proc interface and modifies the content in the DST module; d, an iptables module in the kernel issues a rule and calls the DST module to judge whether the time is in the range of the daylight-saving time, and the time in the rule issued by the iptables module is automatically increased by one hour. According to the method of supporting the daylight-saving time through the Linux kernel, the DST module is newly built in the Linux kernel, when the rule of the iptables module in the kernel takes effect, whether the time is in the range of the daylight-saving time is judged by calling the DST module, and therefore it is ensured that the time set by a user is consistent with the time when the rule takes effect.

Description

Linux kernel is supported the method for daylight-saving time
Technical field
The present invention relates to Linux field, relate in particular to a kind of method that linux kernel is supported the daylight-saving time.
Background technology
Operating system is one and is used for and hardware is come into contacts with and provide the rudimentary support programs of a limited services set for user program.A computer system is the commensal of a hardware and software, and they interdepend, indivisible.The hardware of computing machine, contains the engine that peripherals, processor, internal memory, hard disk and other electronic equipment form computing machine.But not having software to operate and control it, self is inoperable.Complete this software of controlling work and be just called operating system, in the term of Linux, be called as " kernel ", also can be called " core ".The main modular of linux kernel (or assembly) minute following components: storage administration, CPU and management of process, file system, equipment control and driving, network service, and the initialization of system (guiding), system call etc.
Linux is a Monolithic Kernel (monolithic kernel) system.Device driver is access hardware completely.Device driver in Linux can be easily with the form setting of modularization (modularize), and in the direct loading or unloading of system run duration.
Daylight-saving time (Daylight Saving Time:DST), claim again " daylight saving time system " and " summer time ", be a kind of for saving the artificial regulation of the energy system of local time, be called the unified time adopting during this system is carried out " summer time ".Generally in summer early daybreak artificially by time advance one hour, can make people get up early and go to bed early, reduce exposure, to make full use of illumination resource, thereby save lighting electricity consumption.
Existing, Linux application layer issue regular in, can relate to the parameters such as time, as:
When a firewall rule is set, the 8:30-18:00 of Mon-Fri does not allow access websites www.luntan.com, in Linux application layer, need issue rule as follows:
iptables-t?filter-I?URL_BlackFilter-m?string--algo?bm--string"www.luntan.com"-m?time--timestart8:30--timestop18:00--weekdays?Sun,Mon,Tue,Wed,Thu,-j?DROP
But when opening the daylight-saving time, the time that issues taking effect rules is 9:30-19:00, and linux kernel is not supported the daylight-saving time, the time that user arranges like this and the time of taking effect rules have just conflicted.
Summary of the invention
The object of the present invention is to provide a kind of linux kernel to support the method for daylight-saving time, to guarantee time that user arranges and the time consistency of taking effect rules.
The object of the invention is to be achieved through the following technical solutions.
Linux kernel is supported the method for daylight-saving time, comprises the following steps:
A: a newly-built DST module in linux kernel, and initialization DST module, establishment/proc/net/tbs_dst interface;
B: application layer arranges the daylight-saving time;
C: kernel reads proc interface, and revise the content in DST module;
D: in kernel, iptables module issues rule, and call the DST module judgement time within the daylight-saving time, iptables module is issued to the time in rule increases by 1 hour automatically.
Further preferably, the module of initialization DST described in step a comprises: in DST module, initialization one global variable struct tbs_dst_info*dst is used for safeguarding the daylight-saving time.
Further preferably, the module of initialization DST described in step a also comprises: DST module initialization proc interface variables/proc/net/tbs_dst.
Further preferably, step b specifically comprises: application layer is called echo " initial time termination time " >/proc/net/tbs_dst and is used for arranging the kernel daylight-saving time.
Further preferably, step b also comprises: application layer is called cat/proc/net/tbs_dst and read time kernel daylight-saving time.
Further preferably, step c specifically comprises: kernel calls proc interface tbs_dst_read reads application layer setting, and revises the content in DST module.
Further preferably, step c also comprises: kernel calls proc interface tbs_dst_write exports the content in DST module.
Further preferably, steps d also comprises that the DST module judgement time, not within the daylight-saving time, keeps current time constant.
The present invention compared with prior art, beneficial effect is: linux kernel provided by the invention is supported the method for daylight-saving time, a newly-built DST module in linux kernel, when kernel module iptables taking effect rules, by calling DST module, judge that the time is whether within daylight-saving time scope, thereby guarantee time that user arranges and the time consistency of taking effect rules.
Accompanying drawing explanation
Fig. 1 is the method flow diagram that linux kernel of the present invention is supported the daylight-saving time.
Embodiment
In order to make object of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein, only in order to explain the present invention, is not intended to limit the present invention.
First, introduce under linux kernel several terms:
In iptables:linux system, facilitate user to control the instrument of IP packet filtration and firewall configuration setting;
Busybox:linux command set, comprises up to a hundred conventional orders;
TZ:linux system time configuration file, comprises time zone and daylight-saving time information;
As:
PST+08:00PST,69/02:00:00,307/02:00:00;
Wherein,
PST+08:00PST is time-zone information;
69/02:00:00,307/02:00:00 is daylight-saving time configuration information.
Refer to shown in Fig. 1, linux kernel provided by the invention is supported the method for daylight-saving time, comprising:
Step S1: a newly-built DST module in linux kernel;
Step S2: initialization one global variable struct tbs_dst_info*dst is used for safeguarding the daylight-saving time in DST module;
Step S3:DST module initialization one proc interface variables/proc/net/tbs_dst;
Step S4: application layer is called echo " initial time termination time " >/proc/net/tbs_dst and is used for arranging the kernel daylight-saving time;
Step S5: application layer is called cat/proc/net/tbs_dst and read time kernel daylight-saving time;
Step S6: kernel calls proc interface tbs_dst_read reads application layer setting, and revise the content of global variable dst in DST module;
Step S7: kernel calls proc interface tbs_dst_write exports the content in DST module;
Step S8: in kernel, iptables module issues rule, and call DST module and judge that the time whether within daylight-saving time scope, if so, enters step S9; Otherwise the retention time is constant;
Step S9: iptables module is issued in rule to the time increases by 1 hour automatically, thus time that user arranges and the time consistency of taking effect rules guaranteed.
Linux kernel provided by the invention is supported the method for daylight-saving time, a newly-built DST module in linux kernel, when kernel module iptables taking effect rules, by calling DST module, judge that the time is whether within daylight-saving time scope, thereby guarantee time that user arranges and the time consistency of taking effect rules.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, all any modifications of doing within the spirit and principles in the present invention, be equal to and replace and improvement etc., within all should being included in protection scope of the present invention.

Claims (8)

1. linux kernel is supported the method for daylight-saving time, it is characterized in that, comprises the following steps:
A: a newly-built DST module in linux kernel, and initialization DST module, establishment/proc/net/tbs_dst interface;
B: application layer arranges the daylight-saving time;
C: kernel reads proc interface, and revise the content in DST module;
D: in kernel, iptables module issues rule, and call the DST module judgement time within the daylight-saving time, iptables module is issued to the time in rule increases by 1 hour automatically.
2. linux kernel as claimed in claim 1 is supported the method for daylight-saving time, it is characterized in that, the DST of initialization described in step a module comprises: in DST module, initialization one global variable structtbs_dst_info*dst is used for safeguarding the daylight-saving time.
3. linux kernel as claimed in claim 2 is supported the method for daylight-saving time, it is characterized in that, the DST of initialization described in step a module also comprises: DST module initialization proc interface variables/proc/net/tbs_dst.
4. linux kernel as claimed in claim 3 is supported the method for daylight-saving time, it is characterized in that, step b specifically comprises: application layer is called echo " initial time termination time " >/proc/net/tbs_dst and is used for arranging the kernel daylight-saving time.
5. linux kernel as claimed in claim 4 is supported the method for daylight-saving time, it is characterized in that, step b also comprises: application layer is called cat/proc/net/tbs_dst and read time kernel daylight-saving time.
6. linux kernel as claimed in claim 4 is supported the method for daylight-saving time, it is characterized in that, step c specifically comprises: kernel calls proc interface tbs_dst_read reads application layer setting, and revises the content in DST module.
7. linux kernel as claimed in claim 6 is supported the method for daylight-saving time, it is characterized in that, step c also comprises: kernel calls proc interface tbs_dst_write exports the content in DST module.
8. linux kernel as claimed in claim 1 is supported the method for daylight-saving time, it is characterized in that, steps d also comprises that the DST module judgement time, not within the daylight-saving time, keeps current time constant.
CN201310698007.0A 2013-12-18 2013-12-18 Method of supporting daylight-saving time through Linux kernel Pending CN103744650A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310698007.0A CN103744650A (en) 2013-12-18 2013-12-18 Method of supporting daylight-saving time through Linux kernel

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310698007.0A CN103744650A (en) 2013-12-18 2013-12-18 Method of supporting daylight-saving time through Linux kernel

Publications (1)

Publication Number Publication Date
CN103744650A true CN103744650A (en) 2014-04-23

Family

ID=50501670

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310698007.0A Pending CN103744650A (en) 2013-12-18 2013-12-18 Method of supporting daylight-saving time through Linux kernel

Country Status (1)

Country Link
CN (1) CN103744650A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111901060A (en) * 2019-12-26 2020-11-06 长扬科技(北京)有限公司 Method and terminal for supporting local time by iptables rule

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1304103A (en) * 1999-10-25 2001-07-18 英业达集团(西安)电子技术有限公司 Daylight saving time and time-zone time difference regutation device for PDA and its method
CN1430739A (en) * 2000-05-26 2003-07-16 松下电器产业株式会社 Portable terminal apparatus having automatic adjustment function for time difference
CN102696058A (en) * 2010-01-07 2012-09-26 高通股份有限公司 Determination of time zone and DST participation
CN103425537A (en) * 2012-05-25 2013-12-04 中兴通讯股份有限公司 Time adjusting method and time adjusting device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1304103A (en) * 1999-10-25 2001-07-18 英业达集团(西安)电子技术有限公司 Daylight saving time and time-zone time difference regutation device for PDA and its method
CN1430739A (en) * 2000-05-26 2003-07-16 松下电器产业株式会社 Portable terminal apparatus having automatic adjustment function for time difference
CN102696058A (en) * 2010-01-07 2012-09-26 高通股份有限公司 Determination of time zone and DST participation
CN103425537A (en) * 2012-05-25 2013-12-04 中兴通讯股份有限公司 Time adjusting method and time adjusting device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111901060A (en) * 2019-12-26 2020-11-06 长扬科技(北京)有限公司 Method and terminal for supporting local time by iptables rule

Similar Documents

Publication Publication Date Title
US9600330B2 (en) Method and system for regulation and control of a multi-core central processing unit
US6631469B1 (en) Method and apparatus for periodic low power data exchange
TWI556092B (en) Priority based application event control (paec) to reduce power consumption
CN103207797B (en) Capsule type custom-made updating method based on unified extensible firmware interface firmware system
US9524117B2 (en) Control of page access in memory
US9182810B2 (en) Domain specific language, compiler and JIT for dynamic power management
CN103345415B (en) The terminal power-economizing method of management intervalometer and device
CN110688172B (en) Device function mutual exclusion logic configuration method and device, electronic device and storage medium
EP3317746B1 (en) Method and apparatus for a multiple-processor system
CN103581187A (en) Method and system for controlling access rights
WO2020206691A1 (en) Application processing method and apparatus, storage medium, and electronic device
CN106775609A (en) System and method for reducing dormancy and recovery time
CN104994547A (en) Network access method and user terminal
CN103955389A (en) System startup method based on PCM (Phase Change Random Access Memory)
CN116339836A (en) Resource access method, device, readable storage medium and BMC chip
CN111694402A (en) Control method of single-chip heterogeneous system and wearable device
KR20140026308A (en) Apparatus and method for managing power in multi-core system
CN103744650A (en) Method of supporting daylight-saving time through Linux kernel
AU2015203570A1 (en) Method, system and apparatus for segmenting an image set to generate a plurality of event clusters
US7299372B2 (en) Hierarchical management for multiprocessor system with real-time attributes
CN103324469A (en) Timer implementation method and device
CN107613546B (en) BLE chip, control method of designated element in BLE chip and Bluetooth low-power-consumption equipment
WO2016131313A1 (en) Code loading method and apparatus for embedded operating system
CN105589544A (en) Method, device and terminal reducing central processor energy consumption
CN111143830A (en) Method and device for limiting application use, terminal equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20140423