Disclosure of Invention
The invention provides a method for reading a system log so as to obtain the system log through UEFI, and the defects of the prior art are overcome.
The invention provides a method for reading a system log, which is applied to UEFI and comprises the following steps:
the method comprises the following steps that firstly, a hard disk drive, a video card drive and a file system drive are loaded;
secondly, identifying a hard disk partition corresponding to the system log through the hard disk drive;
thirdly, identifying a file system in the hard disk partition through the file system driver;
fourthly, positioning the system log from the file system through a file system function and the characteristic information of the system log;
and fifthly, loading the system log into a cache and displaying the system log through a display.
Aiming at the method, the system log is loaded into a cache and displayed through a display, and the method comprises the following steps:
reading a starting record of the last starting from the system log;
and reading the starting record into the cache, and displaying the starting record through the display.
For the above method, reading the last start record from the system log, including:
reading data from an address M-K to an address M;
and M is an address corresponding to the end of the system log, and K is a preset length of one-time starting record.
The invention provides UEFI for reading a system log, which comprises the following modules:
the drive module is used for loading a hard disk drive, a display card drive and a file system drive;
the first identification module is used for identifying a hard disk partition corresponding to the system log through the hard disk drive;
the second identification module is used for identifying the file system in the hard disk partition through the file system driver;
the positioning module is used for positioning the system log from the file system through a file system function and the characteristic information of the system log;
and the display module is used for loading the system log into a cache and displaying the system log through a display.
For the UEFI, the display module includes:
the first reading submodule is used for reading the starting record of the last starting from the system log;
and the display submodule is used for reading the starting record into the cache and displaying the starting record through the display.
For the UEFI, the first reading sub-module includes:
the second reading submodule is used for reading data of the address M-K-M;
and M is an address corresponding to the end of the system log, and K is a preset length of one-time starting record.
The invention provides a computer for reading system logs, which comprises any UEFI.
The UEFI method provided by the invention can read the system log, so that a user can more flexibly acquire the system log under the condition that the user cannot enter the operating system.
Detailed Description
The present invention is not limited by the following examples, and specific embodiments may be determined according to the technical solutions and practical situations of the present invention.
The invention is further described with reference to the following examples and figures:
example 1: fig. 1 is a flowchart of a method for reading a system log, which is applied to UEFI, and includes the following steps:
s1, loading a hard disk drive, a video card drive and a file system drive;
s2, identifying the hard disk partition corresponding to the system log through the hard disk drive;
s3, identifying the file system in the hard disk partition through the file system driver;
s4, locating the system log from the file system through the file system function and the characteristic information of the system log;
and S5, loading the system log into a cache and displaying the system log through a display.
The invention is suitable for domestic platforms. The operating system used by the domestic platform may be Linux.
In practical application, the system log is automatically generated by the operating system in the process of starting the operating system. When the operating system cannot be loaded, the user typically reboots the computer. After the system log is restarted, after the logo of the UEFI appears, a user can trigger the process of reading the system log through pressing a key.
In step S1, the order of loading the hard disk drive, the graphics card drive, and the file drive may be arbitrary. Generally, UEFI automatically loads drivers of all devices after startup, and S2 may be executed after the drivers of all devices are loaded, or may be executed immediately after the drivers of all devices in S1 are preferentially loaded.
Specifically, in step S3, the FILE SYSTEM in the partition may be identified by a FILE SYSTEM function (EFI _ SIMPLE _ FILE _ SYSTEM _ PROTOCOL) in the FILE SYSTEM driver, and a root directory handle (EFI _ FILE _ PROTOCOL) of the FILE SYSTEM may be obtained by OpenVolume in the FILE SYSTEM function, where the directory handle includes an operation interface for operating the directory FILE. After getting the pointer of the root directory EFI _ FILE _ progress instance on the partition FILE system, the FILE on the partition can be operated on, such as for reading a FILE or directory.
In step S4, the characteristic information of the system log may be a name of the system log or/and a name of a directory of files where the system log is located. The system log may be located under a root directory of the file system or under other directories. UEFI can locate system log files by automatically traversing the file system through a function, for example, a name syslog of a system log is preset in UEFI, and the file is searched in a root-removing directory; or the system log can be manually selected in the operation interface according to the file name. If operated manually, the driver of the input device, such as a keyboard or a mouse, needs to be loaded in S1.
The UEFI method provided by the invention can read the system log, so that a user can more flexibly acquire the system log under the condition that the user cannot enter the operating system.
Example 2: the method, step S5, includes:
s51, reading the starting record of the last start from the system log;
and S52, reading the start record into the cache, and displaying the start record through the display.
The system logs are generated when the system is started every time, the service time of the computer is long, and the system logs are very long and inconvenient to check. And when the operating system loads a fault, only the last started record is meaningful for repair, so that the embodiment only displays the last started record, and the displayed information is more convenient for a user to find the fault.
Specifically, the start-up record is stored in the buffer, and all the contents in the buffer can be displayed through the print function.
Example 3: the method, step S51, includes:
s511, reading data of the address M-K-M;
and M is an address corresponding to the end of the system log, and K is a preset length of one-time starting record.
Specifically, the computer is started once, and the corresponding section of the system log (i.e. the start record) of the start is generated at the tail of the whole system log. In order to obtain the start record of the last start, all data from the length of the start record of the last start back from the tail of the system file to the tail of the system file are read and displayed on a display. Because the lengths of the start records corresponding to each start are different, multiple detections can be performed, and the length of a start record with a longer length is detected as the preset length of the start record, for example, the memory size occupied by 100 pages of content.
The embodiment provides a method for displaying the section of the system log corresponding to the last startup on the screen, so that the user can more easily find the fault occurring in the last startup process of the operating system in the displayed content.
Based on the same inventive concept, the embodiment of the invention also provides the UEFI and the computer for reading the system log, and as the UEFI and the computer solve the problem in a similar manner to the method, the implementation of the UEFI and the computer can refer to the implementation of the method, and repeated parts are not described again.
Example 4: FIG. 2 is an overall frame diagram of UEFI for reading system logs, which includes the following modules:
the drive module is used for loading a hard disk drive, a display card drive and a file system drive;
the first identification module is used for identifying a hard disk partition corresponding to the system log through the hard disk drive;
the second identification module is used for identifying the file system in the hard disk partition through the file system driver;
the positioning module is used for positioning the system log from the file system through a file system function and the characteristic information of the system log;
and the display module is used for loading the system log into a cache and displaying the system log through a display.
Example 5: the UEFI, the display module, comprises:
the first reading submodule is used for reading the starting record of the last starting from the system log;
and the display submodule is used for reading the starting record into the cache and displaying the starting record through the display.
Example 6: the UEFI, the first reading sub-module, includes:
the second reading submodule is used for reading data of the address M-K-M;
and M is an address corresponding to the end of the system log, and K is a preset length of one-time starting record.
Example 7: the invention provides a computer for reading system logs, which comprises any UEFI.