summaryrefslogtreecommitdiffstats
path: root/mdadm.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Refactor continue_via_systemd()Mateusz Kusiak5 days1-1/+1
| | | | | | | Refactor continue_via_systemd() and it's calls to make it more readable. No functional changes. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
* Remove --freeze-reshape logicMateusz Kusiak5 days1-2/+0
| | | | | | | | | | | | | | This commit removes --freeze-reshape logic, it basicaly reverts commit b76b30e0f950 ("Do not continue reshape during initrd phase"). --freeze-reshape was supposed to be used to restore critical sector in incremental and assemble operations without starting a reshape process, but it's meaning has been lost through the years and it is not currently used. A replacement for this logic will be added in incoming patches, so reshapes won't be started in initrd phrase. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
* Incremental: Simplify remove logicMariusz Tkaczyk2024-12-161-0/+1
| | | | | | Incremental_remove() does not execute Manage_subdevs() now. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* sysfs: functions for writing md/<memb>/stateMariusz Tkaczyk2024-12-161-0/+19
| | | | | | | Add dedicated enum to reflect possible values for mentioned file. Not all values are mapped. Add map to present sysfs keywords. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: remove bitmap file supportYu Kuai2024-12-031-6/+12
| | | | | | | | | | | Because it's marked deprecated for a long time now, and it's not worthy to support it for new bitmap. Now that we don't need to store filename for bitmap, also declare a new enum type bitmap_type to simplify code. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* debug: add timestamps for debug messagesMateusz Kusiak2024-11-221-3/+11
| | | | | | | | | | Timestamps on debug messages help establish what takes long to process. Debug messages are print only if DDEBUG flag is passed. Add timestamps for debug messages. Remove dead code from dprintf dummies for non-debug builds. Remove timestamps from current debug messages. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
* mdadm: drop auto= supportMariusz Tkaczyk2024-11-051-6/+1
| | | | | | | | | | | | According to author (and what was described in man): "With mdadm 3.0, device creation is normally left up to udev so this is option is unlikely to be needed" This was a workaround for kernel 2.6 family issues (partitionable and non-partitionable arrays hell) and I believe we are far away from it now. I'm not aware of any usage of it, hence it is removed. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* ReadMe: Fix stylistic issuesMariusz Tkaczyk2024-11-051-4/+2
| | | | | | No functional changes, just adopt style to allow checkpatch to pass. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdmon: delegate removal to managemonMariusz Tkaczyk2024-11-041-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Starting from [1], kernel requires suspend lock on member drive remove path. It causes deadlock with external management because monitor thread may be locked on suspend and is unable to switch array to active, for example if badblock is reported in this time. It is blocking action now, so it must be delegated to managemon thread but we must ensure that monitor does metadata update first, just after detecting faulty. This patch adds appropriative support. Monitor thread detects "faulty", and updates the metadata. After that, it is asking manager thread to remove the device. Manager must be careful because closing descriptors used by select() may lead to abort with D_FORTIFY_SOURCE=2. First, it must ensure that device descriptors are not used by monitor. There is unlimited numer of remove retries and recovery is blocked until all failed drives are removed. It is safe because "faulty" device is not longer used by MD. Issue will be also mitigated by optimalization on badlbock recording path in kernel. It will check if device is not failed before badblock is recorded but relying on this is not ideologically correct. Userspace must keep compatibility with kernel and since it is blocking action, we must tract is as blocking action. [1] kernel commit cfa078c8b80d ("md: use new apis to suspend array for adding/removing rdev from state_store()") Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* monitor: Add DS_EXTERNAL_BB flagMariusz Tkaczyk2024-11-041-0/+1
| | | | | | | | | | If this is set, then metadata handler must support external badblocks. Remove checks for superswitch functions. If mdi->state_fd is not set then we should not try to record badblock, we cannot trust this device. No functional changes. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* sysfs: add sysfs_open_memb_attr()Mariusz Tkaczyk2024-11-041-3/+2
| | | | | | | | | | Function is added to not repeat defining "dev-%s", disk_name. Related code branches are updated. Ioctl way for setting disk faulty/remove is removed, sysfs is always used now. Some non functional style issues are fixed in Manage_subdevs(). Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Add mdadm_status.hAnna Sztukowska2024-10-101-6/+1
| | | | | | | Move mdadm_status_t to mdadm_status.h file. Add status for memory allocation failure. Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
* mdadm: add xmalloc.hMariusz Tkaczyk2024-09-271-5/+0
| | | | | | | | | | Move memory declaration helpers outside mdadm.h. They seems to be useful so keep them but include separatelly. Rework them to not reffer to Name[] declared internally in mdadm/mdmon. This is first step to start decomplexing mdadm.h. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* sysfs: add function for writing to sysfs fdMariusz Tkaczyk2024-09-271-0/+3
| | | | | | | | | | Proposed function sysfs_wrte_descriptor() unifies error handling for write() done to sysfs files. Main purpose is to use it with MD sysfs file but it can be used elsewhere. No functional changes. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Incremental: Rename IncrementalRemoveMariusz Tkaczyk2024-09-271-1/+1
| | | | | | | Rename it to Incremental_remove for better readability. No functional changes. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Incremental: support devnode in IncrementalRemove.Mariusz Tkaczyk2024-09-101-0/+5
| | | | | | | | There are no reasons to keep this interface different than others. Allow to use devnode but keep old way for backward compatibility. Method is added to verify that only devnode or kernel name is used. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdstat: Rework mdstat external arrays handlingMariusz Tkaczyk2024-07-301-1/+5
| | | | | | | | | | | | To avoid repeating mdstat_read() in IncrementalRemove(), new function mdstat_find_by_member_name() has been proposed. With that, IncrementalRemove() handles own copy of mdstat content and there is no need to repeat reading for external stop. Additionally, It proposed few helper to avoid repeating mdstat_ent->metadata_version checks across code. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* super0: use define for char array in examine_super0Kinga Stefaniuk2024-07-301-0/+3
| | | | | | | | | Using nb with 11 length may cause format-truncation errors, because it was possible to use snprintf with 12 length input and write it to 11 length output. Added new define and use it to avoid this error. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* mdadm: Fix socket connection failure when mdmon runs in foreground mode.Shminderjit Singh2024-07-021-0/+1
| | | | | | | | | | | | | | | | | | | | While creating an IMSM RAID, mdadm will wait for the mdmon main process to finish if mdmon runs in forking mode. This is because with "Type=forking" in the mdmon service unit file, "systemctl start service" will block until the main process of mdmon exits. At that moment, mdmon has already created the socket, so the subsequent socket connect from mdadm will succeed. However, when mdmon runs in foreground mode (without "Type=forking" in the service unit file), "systemctl start service" will return once the mdmon process starts. This causes mdadm and mdmon to run in parallel, which may lead to a socket connection failure since mdmon has not yet initialized the socket when mdadm tries to connect. If the next instruction/command is to access this device and try to write to it, a permission error will occur since mdmon has not yet set the array to RW mode. Signed-off-by: Shminderjit Singh <shminderjit.singh@oracle.com>
* mdadm.h: provide basename if GLIBC is not avialableMariusz Tkaczyk2024-05-281-0/+8
| | | | | | | | | If GNU basename is not avilable, define it. It is safer to use that rather than include libgen.h with XPG basename() definition. Fixes:#12 Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Start update_opt from 0Xiao Ni2024-05-241-2/+2
| | | | | | | | | Before f2e8393bd722 ('Manage&Incremental: code refactor, string to enum'), it uses NULL to represent it doesn't need to update. So init UOPT_UNDEFINED to 0. This problem is found by test case 05r6tor0. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Wait for mdmon when it is stared via systemdKinga Stefaniuk2024-05-141-0/+2
| | | | | | | | | When mdmon is being started it may need few seconds to start. For now, we didn't wait for it. Introduce wait_for_mdmon() function, which waits up to 5 seconds for mdmon to start completely. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* util.c: change devnm to const in mdmon functionsKinga Stefaniuk2024-05-141-2/+2
| | | | | | | | Devnm shall not be changed inside mdmon_running() and mdmon_pid() functions, change this parameter to const. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: use struct context in reshape_super()Mateusz Kusiak2024-05-071-8/+10
| | | | | | | | | | | | | | reshape_super() takes too many arguments. Change passing params in favor of single struct. Add devname pointer and change direction members to struct shape and use it for reshape_super(). Create reshape_array_size() and reshape_array_non_size() to handle reshape_super() calls. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: pass struct context for external reshapesMateusz Kusiak2024-05-071-7/+4
| | | | | | | | | | | | This patch alters mutiple functions calls so the context is passed to external reshape functions. There are two main reasons behind it: - reduces number of arguments passed and unifies them, - imsm code will make use of context in incoming patches. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Add key ENCRYPTION_NO_VERIFY to confBlazej Kucman2024-04-021-0/+1
| | | | | | | | | | | | | | | | | Add ENCRYPTION_NO_VERIFY config key and allow to disable checking encryption status for given type of drives. The key is introduced because of SATA Opal disks for which TPM commands must be enabled in libata kernel module, (libata.allow_tpm=1), otherwise it is impossible to verify encryption status. TPM commands are disabled by default. Currently the key only supports the "sata_opal" value, if necessary, the functionality is ready to support more types of disks. This functionality will be used in the next patches. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Add reading SATA encryption informationBlazej Kucman2024-04-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Functionality reads information about SATA disk encryption. Technical documentation used is given in the implementation. The implementation is able to recognized two encryption standards for SATA drives, OPAL and ATA security. If the SATA drive supports OPAL, encryption status and ability are determined based on Opal Level 0 discovery response, for ATA security, based on ATA identify response. If SATA supports OPAL, ability is set to "SED", for ATA security to "Other". SED(Self-Encrypting Drive) is commonly used to describe drive which using OPAL or Enterprise standards developed by Trusted Computing Group. Ability "Other" is used for ATA security because we rely only on information from ATA identify which describe the overall state of encryption. It is allowed to mix disks with different encryption ability such as "SED" and "Other" and it is not security gap. Motivation for adding this functionality is to block mixing of disks in IMSM arrays with encryption enabled and disabled. The main goal is to not allow stealing data by rebuilding array to not encrypted drive which can be read elsewhere. For SATA Opal drives, libata allow_tmp parameter enabled is required, which is necessary for Opal Security commands to work, therefore, if the parameter is not enabled, SATA Opal disk cannot be used in case the encryption will be checked by metadata. Implemented functions will be used in one of the next patches. In one of the next patches, a flag will be added to enable disabling SATA Opal encryption checking due to allow_tpm kernel setting dependency. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Move pr_vrb define to mdadm.hBlazej Kucman2024-04-021-0/+2
| | | | | | | | Move pr_vrb define from super-intel.c to mdadm.h to make it widely available. This change will be used in the next patches. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* sysfs: remove vers parameter from sysfs_set_arrayMateusz Kusiak2024-03-221-1/+1
| | | | | | | | | | | 9003 was passed directly to sysfs_set_array() since md_get_version() always returned this value. md_get_version() was removed long ago. Remove dead version check from sysfs_set_array(). Remove "vers" argument and fix function calls. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Fix native --detail --exportMariusz Tkaczyk2024-03-221-2/+1
| | | | | | | | | | | | | | | | Mentioned commit (see Fixes) causes that UUID is not swapped as expected for native superblock. Fix this problem. For detail, we should avoid superblock calls, we can have information about supertype from map, use that. Simplify fname_from_uuid() by removing dependencies to metadata handler, it is not needed. Decision is taken at compile time, expect super1 but this function is not used by super1. Add warning about that. Remove separator, it is always ':'. Fixes: 60c19530dd7c ("Detail: remove duplicated code") Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: drop get_disk_controller_domain()Mariusz Tkaczyk2024-03-111-15/+0
| | | | | | | | This function is unused now. Drop it. Controller for IMSM is a device policy and is separated from user defined domains. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Monitor, Incremental: use device policiesMariusz Tkaczyk2024-03-111-2/+3
| | | | | | | | | | | | | spare_criteria is expanded to contain policies which will be generated by handler's get_spare_criteria() function. It provides a way to test device for metadata specific policies earlier than during add_do_super(), when device is already removed from previous array/container for Monitor. For Incremental, it ensures that all criteria are tested when trying spare. It is not tested when device contains valid metadata. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: test_and_add device policies implementationMariusz Tkaczyk2024-03-111-0/+7
| | | | | | | | | | | | Add support for three scenarios: - obtaining array wide policies via fd, - obtaining array wide policies via struct mdinfo, - getting policies for particular drive from the request. Add proper functions and make them extern. These functions are used in next patches. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm.h: Introduce custom device policiesMariusz Tkaczyk2024-03-111-18/+36
| | | | | | | | | | | | | | | | | | | | The approach proposed here is to test drive policies outside validate_geometry() separately per every drive and add determined policies to list. The implementation reuses dev_policy we have in mdadm. This concept addresses following problems: - test drives if they fit together to criteria required by metadata handler, - test all drives assigned to the container even if some of them are not target of the request, mdmon is free to use any drive in the same container, - extensibility, new policies can be added to handler easy, - fix issues related to imsm controller domain verifying. Add superswitch function. It is used in next patches. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: introduce sysfs_get_container_devnm()Mariusz Tkaczyk2024-03-111-0/+2
| | | | | | | | There at least two places where it is done directly, so replace them with function. Print message about creating external array, add "/dev/" prefix to refer directly to devnode. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: drop get_required_spare_criteria()Mariusz Tkaczyk2024-03-111-3/+2
| | | | | | | | | | | | | | | | | | | | | Only IMSM implements get_spare_criteria, so load_super() in get_required_spare_criteria() is dead code. It is moved inside metadata handler, because only IMSM implements it. Give possibility to provide devnode to be opened. With that we can hide load_container() used only to fill spare criteria inside handler and simplify implementation in generic code. Add helper function for testing spare criteria in Incremental and error messages. File descriptor in get_spare_criteria_imsm() is always opened on purpose. New functionality added in next patches will require it. For the same reason, function is moved to other place. No functional changes. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Add functions for spare criteria verificationMariusz Tkaczyk2024-03-111-2/+4
| | | | | | | | | | | | | | | | | It is done similar way in few places. As a result, two almost identical functions (dev_size_from_id() and dev_sector_size_from_id()) are removed. Now, it uses same file descriptor to send two ioctls. Two extern functions are added, in next patches disk_fd_matches_criteria() is used. Next optimization is inline zeroing struct spare_criteria. With that, we don't need to reset values in get_spare_criteria_imsm(). Dedicated boolean field for checking if criteria are filled is added. We don't need to execute the code if it is not set. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: signal_s() init variablesMateusz Kusiak2024-02-231-3/+2
| | | | | | | | Init sigaction structs in signal_s(). This approach might throw warnings for GCC 4.x and lower. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Revert "mdadm: remove container_enough logic"Mariusz Tkaczyk2024-02-091-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Mentioned patch changes way of IMSM member arrays assembling, they are updated by every new drive incremental processes. Previously, member arrays were created and filled once, by last drive incremental process. We determined regressions with various impact. Unfortunately, initial testing didn't show them. Regressions are connected to drive appearance order and may not be reproducible on every configuration, there are at least two know issues for now: - sysfs attributes are filled using old metadata if there is outdated drive and it is enumerated first. - rebuild may be aborted and started from beginning after reboot, if drive under rebuild is enumerated as the last one. This reverts commit 4dde420fc3e24077ab926f79674eaae1b71de10b. It fixes checkpatch issues and reworks logic to remove empty "if" branch in Incremental. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Replace "none" with macroMateusz Kusiak2024-01-241-0/+16
| | | | | | | | | | | String "none" is used many times throughout the code. Replace "none" strings with predefined macro. Add str_is_none() for comparing strings with "none". Replace str(n)cmp calls with function. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Define sysfs max buffer sizeMateusz Kusiak2024-01-241-0/+2
| | | | | | | | | | | sysfs_get_str() usages have inconsistant buffer size. This results in wild buffer declarations and redundant memory usage. Define maximum buffer size for sysfs strings. Replace wild sysfs string buffer sizes for globaly defined value. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* udev: Move udev_block() and udev_unblock() into udev.cMateusz Grzonka2023-11-211-2/+0
| | | | | | | | Add kernel style comments and better error handling. Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Signed-off-by: Kinga Tanska <kinga.tanska@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Mdmonitor: Improve udev event handlingMateusz Grzonka2023-11-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Mdmonitor is waiting for udev queue to become empty. Even if the queue becomes empty, udev might still be processing last event. However we want to wait and wake up mdmonitor when udev finished processing events.. Also, the udev queue interface is considered legacy and should not be used outside of udev. Use udev monitor instead, and wake up mdmonitor on every event triggered by udev for md block device. We need to generate more change events from kernel, because they are missing in some situations, for example, when rebuild started. This will be addressed in a separate patch. Move udev specific code into separate functions, and place them in udev.c file. Also move use_udev() logic from lib.c into newly created file. Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Signed-off-by: Kinga Tanska <kinga.tanska@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: remove container_enough logicPawel Piatkowski2023-10-261-3/+0
| | | | | | | | | | | | | | | | Arrays without enough disk count will be assembled but not started. Now RAIDs will be assembled always (even if they are failed). RAID devices in all states will be assembled and exposed to mdstat. This change affects only IMSM (for ddf it wasn't used, container_enough was set to true always). Removed this logic from incremental_container as well with runstop checking because runstop condition is being verified in assemble_container_content function. Signed-off-by: Pawel Piatkowski <pawel.piatkowski@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: Follow POSIX Portable Character SetMariusz Tkaczyk2023-10-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the user creates a device with a name that contains whitespace, mdadm timeouts and throws an error. This issue is caused by udev, which truncates /dev/md link until the first whitespace. This patch introduces prohibition of characters other than A-Za-z0-9.-_ in the device name. Also, it prohibits using leading "-" in device name, so name won't be confused with cli parameter. Set of allowed characters is taken from POSIX 3.280 Portable Character Set. Also, device name length now is limited to NAME_MAX. In some places, there are other requirements for string length (e.g. size up to MD_NAME_MAX for device name). This routine is made to follow POSIX and other, more strict limitations should be checked separately. We are aware of the risk of regression in exceptional cases (as escape_devname function is removed) that should be fixed by updating the array name. The POSIX validation is added for: - 'name' parameter in every mode. - first devlist entry, for Build, Create, Assemble, Manage, Grow. - config entries, both devname and "name=". Additionally, some manual cleanups are made. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: define ident_set_devname()Mariusz Tkaczyk2023-10-261-1/+2
| | | | | | | | | | | | | | | | | Use dedicated set method for ident->devname. Now, devname validation is done early for modes where device is created (Build, Create and Assemble). The rules, used for devname validation are derived from config file. It could cause regression with execeptional cases where existing device has name which doesn't match criteria for Manage and Grow modes. It is low risk and those modes are not omitted from early devname validation. Use can used main numbered devnode to avoid this problem. Messages exposed to user are changed so it might cause a regression in negative scenarios. Error codes are not changed. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: refactor ident->name handlingMariusz Tkaczyk2023-10-261-6/+14
| | | | | | | | | | | | | | | | Create dedicated setter for name in mddev_ident and propagate it. Following changes are made: - move duplicated code from config.c and mdadm.c into new function. - Add error enum in mdadm.h. - Use MD_NAME_MAX instead of hardcoded value in mddev_ident. - Use secure functions. - Add more detailed verification of the name. - make error messages reusable for cmdline and config: - for cmdline, these are errors so use pr_err(). - for config, these are just warnings, so use pr_info(). Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: set ident.devname if applicableMariusz Tkaczyk2023-10-261-8/+5
| | | | | | | | | | | | | | | This patch tries to propagate the usage of struct mddev_ident for cmdline where it is applicable. To avoid regression, this value is derived from devlist->devname for applicable modes only. As a result, the whole structure is passed to some functions. It produces some changes for Build, Create and Assemble. No functional changes intended. The goal of the change is to unify devname validation which is done in next patches. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Add secure gethostname() wrapperBlazej Kucman2023-09-011-0/+1
| | | | | | | | | | | | gethostname() func does not ensure null-terminated string if hostname is longer than buffer length. For security, a function s_gethostname() has been added to ensure that "\0" is added to the end of the buffer. Previously this had to be handled in each place of the gethostname() call. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: numbered names verificationMariusz Tkaczyk2023-05-081-1/+3
| | | | | | | | New functions added to remove literals and make the code reusable. Use parse_num() instead of is_numer(). Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>