I found this in initramfs.c, I haven't seen this syntax before, could some one explain what it is doing?
static __initdata int (*actions[])(void) = { [Start] = do_start, [Collect] = do_collect, [GotHeader] = do_header, [SkipIt] = do_skip, [GotName] = do_name, [CopyFile] = do_copy, [GotSymlink] = do_symlink, [Reset] = do_reset, };
Source Code (line 366): initramfs.c
The Linux® kernel is the main component of a Linux operating system (OS) and is the core interface between a computer's hardware and its processes. It communicates between the 2, managing resources as efficiently as possible.
The start_kernel is the entry of the generic and architecture independent kernel code, although we will return to the arch/ folder many times. If you look inside of the start_kernel function, you will see that this function is very big. For this moment it contains about 86 calls of functions.
With io_uring system calls can be completed asynchronously. This means an application thread does not have to block while waiting for the kernel to complete the system call. It can simply submit a request for a system call and retrieve the results later; no time is wasted by blocking.
eBPF is a kernel technology (fully available since Linux 4.4). It lets programs run without needing to add additional modules or modify the kernel source code. You can conceive of it as a lightweight, sandboxed virtual machine (VM) within the Linux kernel.
This is an out-of-sequence array initialization by index. It's like writing
actions[Start] = do_start; actions[Collect] = do_collect;
except that you can do it as a static initializer.
This is a feature from ISO C99 known as designated initializers. It creates an array and initializes specific elements of that array, not necessarily the first N in order. It's equivalent to the following snippet:
static __initdata int (*actions[SOME_SIZE])(void); actions[Start] = do_start; actions[Collect] = do_collect; actions[GotHeader] = do_header; actions[SkipIt] = do_skip; actions[GotName] = do_name; actions[CopyFile] = do_copy; actions[GotSymlink] = do_symlink; actions[Reset] = do_reset;
Except that the array will only be as large as it needs to (equal in size to one more than the largest index), and it can be initialized statically at global scope -- you can't run the above code at global scope.
This is not a feature of ANSI C89, but GCC provides this feature as an extension even when compiling code as C89.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With