The Linux Kernel API

This documentation is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

For more details see the file COPYING in the source distribution of Linux.


Table of Contents

1. Data Types
Doubly Linked Lists
2. Basic C Library Functions
String Conversions
String Manipulation
Bit Operations
3. Basic Kernel Library Functions
Bitmap Operations
Command-line Parsing
CRC Functions
idr/ida Functions
4. Memory Management in Linux
The Slab Cache
User Space Memory Access
More Memory Management Functions
5. Kernel IPC facilities
IPC utilities
6. FIFO Buffer
kfifo interface
7. relay interface support
relay interface
8. Module Support
Module Loading
Inter Module support
9. Hardware Interfaces
Interrupt Handling
DMA Channels
Resources Management
MTRR Handling
PCI Support Library
PCI Hotplug Support Library
10. Firmware Interfaces
DMI Interfaces
EDD Interfaces
11. Security Framework
security_init — initializes the security framework
security_module_enable — Load given security module on boot ?
register_security — registers a security framework with the kernel
securityfs_create_file — create a file in the securityfs filesystem
securityfs_create_dir — create a directory in the securityfs filesystem
securityfs_remove — removes a file or directory from the securityfs filesystem
12. Audit Interfaces
audit_log_start — obtain an audit buffer
audit_log_format — format a message into the audit buffer.
audit_log_end — end one audit record
audit_log — Log an audit record
audit_log_secctx — Converts and logs SELinux context
audit_alloc — allocate an audit context block for a task
__audit_free — free a per-task audit context
__audit_syscall_entry — fill in an audit record at syscall entry
__audit_syscall_exit — deallocate audit context after a system call
__audit_reusename — fill out filename with info from existing entry
__audit_getname — add a name to the list
__audit_inode — store the inode and device from a lookup
auditsc_get_stamp — get local copies of audit_context values
audit_set_loginuid — set current task's audit_context loginuid
__audit_mq_open — record audit data for a POSIX MQ open
__audit_mq_sendrecv — record audit data for a POSIX MQ timed send/receive
__audit_mq_notify — record audit data for a POSIX MQ notify
__audit_mq_getsetattr — record audit data for a POSIX MQ get/set attribute
__audit_ipc_obj — record audit data for ipc object
__audit_ipc_set_perm — record audit data for new ipc permissions
__audit_socketcall — record audit data for sys_socketcall
__audit_fd_pair — record audit data for pipe and socketpair
__audit_sockaddr — record audit data for sys_bind, sys_connect, sys_sendto
__audit_signal_info — record signal info for shutting down audit subsystem
__audit_log_bprm_fcaps — store information about a loading bprm and relevant fcaps
__audit_log_capset — store information about the arguments to the capset syscall
audit_core_dumps — record information about processes that end abnormally
audit_rule_change — apply all rules to the specified message type
audit_list_rules_send — list the audit rules
parent_len — find the length of the parent portion of a pathname
audit_compare_dname_path — compare given dentry name with last component in given path. Return of 0 indicates a match.
13. Accounting Framework
sys_acct — enable/disable process accounting
acct_collect — collect accounting information into pacct_struct
acct_process
14. Block Devices
blk_get_backing_dev_info — get the address of a queue's backing_dev_info
blk_delay_queue — restart queueing after defined interval
blk_start_queue — restart a previously stopped queue
blk_stop_queue — stop a queue
blk_sync_queue — cancel any pending callbacks on a queue
__blk_run_queue — run a single device queue
blk_run_queue_async — run a single device queue in workqueue context
blk_run_queue — run a single device queue
blk_queue_bypass_start — enter queue bypass mode
blk_queue_bypass_end — leave queue bypass mode
blk_cleanup_queue — shutdown a request queue
blk_init_queue — prepare a request queue for use with a block device
blk_make_request — given a bio, allocate a corresponding struct request.
blk_rq_set_block_pc — initialize a request to type BLOCK_PC
blk_requeue_request — put a request back on queue
part_round_stats — Round off the performance stats on a struct disk_stats.
blk_add_request_payload — add a payload to a request
generic_make_request — hand a buffer to its device driver for I/O
submit_bio — submit a bio to the block device layer for I/O
blk_rq_check_limits — Helper function to check a request for the queue limit
blk_insert_cloned_request — Helper for stacking drivers to submit a request
blk_rq_err_bytes — determine number of bytes till the next failure boundary
blk_peek_request — peek at the top of a request queue
blk_start_request — start request processing on the driver
blk_fetch_request — fetch a request from a request queue
blk_update_request — Special helper function for request stacking drivers
blk_unprep_request — unprepare a request
blk_end_request — Helper function for drivers to complete the request.
blk_end_request_all — Helper function for drives to finish the request.
blk_end_request_cur — Helper function to finish the current request chunk.
blk_end_request_err — Finish a request till the next failure boundary.
__blk_end_request — Helper function for drivers to complete the request.
__blk_end_request_all — Helper function for drives to finish the request.
__blk_end_request_cur — Helper function to finish the current request chunk.
__blk_end_request_err — Finish a request till the next failure boundary.
rq_flush_dcache_pages — Helper function to flush all pages in a request
blk_lld_busy — Check if underlying low-level drivers of a device are busy
blk_rq_unprep_clone — Helper function to free all bios in a cloned request
blk_rq_prep_clone — Helper function to setup clone request
blk_start_plug — initialize blk_plug and track it inside the task_struct
blk_pm_runtime_init — Block layer runtime PM initialization routine
blk_pre_runtime_suspend — Pre runtime suspend check
blk_post_runtime_suspend — Post runtime suspend processing
blk_pre_runtime_resume — Pre runtime resume processing
blk_post_runtime_resume — Post runtime resume processing
__blk_run_queue_uncond — run a queue whether or not it has been stopped
__blk_drain_queue — drain requests from request_queue
rq_ioc — determine io_context for request allocation
__get_request — get a free request
get_request — get a free request
blk_attempt_plug_merge — try to merge with current's plugged list
blk_end_bidi_request — Complete a bidi request
__blk_end_bidi_request — Complete a bidi request with queue lock held
blk_rq_map_user_iov — map user data to a request, for REQ_TYPE_BLOCK_PC usage
blk_rq_unmap_user — unmap a request with user data
blk_rq_map_kern — map kernel data to a request, for REQ_TYPE_BLOCK_PC usage
blk_release_queue — release a struct request_queue when it is no longer needed
blk_queue_prep_rq — set a prepare_request function for queue
blk_queue_unprep_rq — set an unprepare_request function for queue
blk_queue_merge_bvec — set a merge_bvec function for queue
blk_set_default_limits — reset limits to default values
blk_set_stacking_limits — set default limits for stacking devices
blk_queue_make_request — define an alternate make_request function for a device
blk_queue_bounce_limit — set bounce buffer limit for queue
blk_limits_max_hw_sectors — set hard and soft limit of max sectors for request
blk_queue_max_hw_sectors — set max sectors for a request for this queue
blk_queue_chunk_sectors — set size of the chunk for this queue
blk_queue_max_discard_sectors — set max sectors for a single discard
blk_queue_max_write_same_sectors — set max sectors for a single write same
blk_queue_max_segments — set max hw segments for a request for this queue
blk_queue_max_segment_size — set max segment size for blk_rq_map_sg
blk_queue_logical_block_size — set logical block size for the queue
blk_queue_physical_block_size — set physical block size for the queue
blk_queue_alignment_offset — set physical block alignment offset
blk_limits_io_min — set minimum request size for a device
blk_queue_io_min — set minimum request size for the queue
blk_limits_io_opt — set optimal request size for a device
blk_queue_io_opt — set optimal request size for the queue
blk_queue_stack_limits — inherit underlying queue limits for stacked drivers
blk_stack_limits — adjust queue_limits for stacked devices
bdev_stack_limits — adjust queue limits for stacked drivers
disk_stack_limits — adjust queue limits for stacked drivers
blk_queue_dma_pad — set pad mask
blk_queue_update_dma_pad — update pad mask
blk_queue_dma_drain — Set up a drain buffer for excess dma.
blk_queue_segment_boundary — set boundary rules for segment merging
blk_queue_dma_alignment — set dma length and memory alignment
blk_queue_update_dma_alignment — update dma length and memory alignment
blk_queue_flush — configure queue's cache flush capability
blk_execute_rq_nowait — insert a request into queue for execution
blk_execute_rq — insert a request into queue for execution
blkdev_issue_flush — queue a flush
blkdev_issue_discard — queue a discard
blkdev_issue_write_same — queue a write same operation
blkdev_issue_zeroout — zero-fill a block range
blk_queue_find_tag — find a request by its tag and queue
blk_free_tags — release a given set of tag maintenance info
blk_queue_free_tags — release tag maintenance info
blk_init_tags — initialize the tag info for an external tag map
blk_queue_init_tags — initialize the queue tag info
blk_queue_resize_tags — change the queueing depth
blk_queue_end_tag — end tag operations for a request
blk_queue_start_tag — find a free tag and assign it
blk_queue_invalidate_tags — invalidate all pending tags
__blk_queue_free_tags — release tag maintenance info
blk_rq_count_integrity_sg — Count number of integrity scatterlist elements
blk_rq_map_integrity_sg — Map integrity metadata into a scatterlist
blk_integrity_compare — Compare integrity profile of two disks
blk_integrity_register — Register a gendisk as being integrity-capable
blk_integrity_unregister — Remove block integrity profile
blk_trace_ioctl — handle the ioctls associated with tracing
blk_trace_shutdown — stop and cleanup trace structures
blk_add_trace_rq — Add a trace for a request oriented action
blk_add_trace_bio — Add a trace for a bio oriented action
blk_add_trace_bio_remap — Add a trace for a bio-remap operation
blk_add_trace_rq_remap — Add a trace for a request-remap operation
blk_mangle_minor — scatter minor numbers apart
blk_alloc_devt — allocate a dev_t for a partition
blk_free_devt — free a dev_t
disk_replace_part_tbl — replace disk->part_tbl in RCU-safe way
disk_expand_part_tbl — expand disk->part_tbl
disk_block_events — block and flush disk event checking
disk_unblock_events — unblock disk event checking
disk_flush_events — schedule immediate event checking and flushing
disk_clear_events — synchronously check, clear and return pending events
disk_get_part — get partition
disk_part_iter_init — initialize partition iterator
disk_part_iter_next — proceed iterator to the next partition and return it
disk_part_iter_exit — finish up partition iteration
disk_map_sector_rcu — map sector to partition
register_blkdev — register a new block device
add_disk — add partitioning information to kernel list
get_gendisk — get partitioning information for a given device
bdget_disk — do bdget by gendisk and partition number
15. Char devices
register_chrdev_region — register a range of device numbers
alloc_chrdev_region — register a range of char device numbers
__register_chrdev — create and register a cdev occupying a range of minors
unregister_chrdev_region — return a range of device numbers
__unregister_chrdev — unregister and destroy a cdev
cdev_add — add a char device to the system
cdev_del — remove a cdev from the system
cdev_alloc — allocate a cdev structure
cdev_init — initialize a cdev structure
16. Miscellaneous Devices
misc_register — register a miscellaneous device
misc_deregister — unregister a miscellaneous device
17. Clock Framework
struct clk_notifier — associate a clk with a notifier
struct clk_notifier_data — rate data to pass to the notifier callback
clk_notifier_register — change notifier callback
clk_notifier_unregister — change notifier callback
clk_get_accuracy — obtain the clock accuracy in ppb (parts per billion) for a clock source.
clk_set_phase — adjust the phase shift of a clock signal
clk_get_phase — return the phase shift of a clock signal
clk_is_match — check if two clk's point to the same hardware clock
clk_prepare — prepare a clock source
clk_unprepare — undo preparation of a clock source
clk_get — lookup and obtain a reference to a clock producer.
devm_clk_get — lookup and obtain a managed reference to a clock producer.
clk_enable — inform the system when the clock source should be running.
clk_disable — inform the system when the clock source is no longer required.
clk_get_rate — obtain the current clock rate (in Hz) for a clock source. This is only valid once the clock source has been enabled.
clk_put — "free" the clock source
devm_clk_put — "free" a managed clock source
clk_round_rate — adjust a rate to the exact rate a clock can provide
clk_set_rate — set the clock rate for a clock source
clk_has_parent — check if a clock is a possible parent for another
clk_set_rate_range — set a rate range for a clock source
clk_set_min_rate — set a minimum clock rate for a clock source
clk_set_max_rate — set a maximum clock rate for a clock source
clk_set_parent — set the parent clock source for this clock
clk_get_parent — get the parent clock source for this clock
clk_get_sys — get a clock based upon the device name
clk_add_alias — add a new clock alias