kexec_load()函式 Unix/Linux


kexec_load -載入新的核心映像到記憶體

內容簡介

#include <syscall.h> 
#include <kexec.h> 

long kexec_load(unsigned long entry, unsigned long nr_segments,   
                            struct kexec_segment *
flags);

描述

kexec_load 載入從當前地址空間中的新核心。這個系統呼叫只能用於由root。

條目是一個指向新載入的可執行映像的入口點。這是核心將跳轉到並開始執行新載入的影象的指令的儲存器位置。

nr_segments denotes the number of segments which will be passed to kexec_load. The value must not be greater than KEXEC_SEGMENT_MAX.

segments denotes a pointer to the first element of an array of kexec_segmentelements. A kexec_segment element contains the details of a segment to be loaded in memory.

flags Sixteen most significant bits of the flag are used to communicate the architecture information (KEXEC_ARCH_*). The values for various architectures are same as defined by ELF specifications.  Lower sixteen bits have been reserved for miscellaneous information. Currently only one bit is being used and rest fifteen have been reserved for future use.  The least significant bit (KEXEC_ON_CRASH) can be set to inform the kernel that the memory memory image being loaded is to be executed upon a system crash and not regular boot. For regular boot, this bit is cleared.

返回值

On success, zero is returned. On error, nonzero value is returned, and errno is set appropriately. 

錯誤

EPERM the calling process has not sufficient permissions (is not root).

EINVAL the flags argument contains an invalid combination of flags, or nr_segments is greater than KEXEC_SEGMENT_MAX.

ENOMEM there is not enough memory to store the kernel image.

EBUSY the memory location which should be written to is not available now.

 

可用性

This syscall is implemented only since kernel 2.6.1