// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (C) 2017 The Chromium OS Authors <[email protected]> * * This file is released under the GPLv2. */ #include <linux/ctype.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/device-mapper.h> #include <linux/init.h> #include <linux/list.h> #include <linux/moduleparam.h> #define DM_MSG_PREFIX … #define DM_MAX_DEVICES … #define DM_MAX_TARGETS … #define DM_MAX_STR_SIZE … #define DM_MAX_WAITFOR … static char *create; static char *waitfor[DM_MAX_WAITFOR]; /* * Format: dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+] * Table format: <start_sector> <num_sectors> <target_type> <target_args> * Block devices to wait for to become available before setting up tables: * dm-mod.waitfor=<device1>[,..,<deviceN>] * * See Documentation/admin-guide/device-mapper/dm-init.rst for dm-mod.create="..." format * details. */ struct dm_device { … }; static const char * const dm_allowed_targets[] __initconst = …; static int __init dm_verify_target_type(const char *target) { … } static void __init dm_setup_cleanup(struct list_head *devices) { … } /** * str_field_delimit - delimit a string based on a separator char. * @str: the pointer to the string to delimit. * @separator: char that delimits the field * * Find a @separator and replace it by '\0'. * Remove leading and trailing spaces. * Return the remainder string after the @separator. */ static char __init *str_field_delimit(char **str, char separator) { … } /** * dm_parse_table_entry - parse a table entry * @dev: device to store the parsed information. * @str: the pointer to a string with the format: * <start_sector> <num_sectors> <target_type> <target_args>[, ...] * * Return the remainder string after the table entry, i.e, after the comma which * delimits the entry or NULL if reached the end of the string. */ static char __init *dm_parse_table_entry(struct dm_device *dev, char *str) { … } /** * dm_parse_table - parse "dm-mod.create=" table field * @dev: device to store the parsed information. * @str: the pointer to a string with the format: * <table>[,<table>+] */ static int __init dm_parse_table(struct dm_device *dev, char *str) { … } /** * dm_parse_device_entry - parse a device entry * @dev: device to store the parsed information. * @str: the pointer to a string with the format: * name,uuid,minor,flags,table[; ...] * * Return the remainder string after the table entry, i.e, after the semi-colon * which delimits the entry or NULL if reached the end of the string. */ static char __init *dm_parse_device_entry(struct dm_device *dev, char *str) { … } /** * dm_parse_devices - parse "dm-mod.create=" argument * @devices: list of struct dm_device to store the parsed information. * @str: the pointer to a string with the format: * <device>[;<device>+] */ static int __init dm_parse_devices(struct list_head *devices, char *str) { … } /** * dm_init_init - parse "dm-mod.create=" argument and configure drivers */ static int __init dm_init_init(void) { … } late_initcall(dm_init_init); module_param(create, charp, 0); MODULE_PARM_DESC(…) …; module_param_array(…); MODULE_PARM_DESC(…) …;