On 3/19/23 18:05, NeilBrown wrote:
> On Mon, 20 Mar 2023, Jes Sorensen wrote:
>> On 3/12/23 23:42, NeilBrown wrote:
>>> Factor out IMSM_NO_PLATFORM testing into a single function that caches
>>> the result.
>>>
>>> Allow mdmon to explicitly set the result to "1" so that we don't need
>>> the ENV var in the unit file
>>>
>>> Check if the kernel command line contains "mdadm.imsm.test=1" and in
>>> that case assert NO_PLATFORM. This simplifies testing in a virtual
>>> machine.
>>>
>>> Signed-off-by: NeilBrown <neilb@xxxxxxx>
>>> ---
>>> mdadm.h | 2 ++
>>> mdmon.c | 6 ++++++
>>> super-intel.c | 43 ++++++++++++++++++++++++++++++++++++++++---
>>> systemd/mdmon@.service | 3 ---
>>> 4 files changed, 48 insertions(+), 6 deletions(-)
>>
>> Hi Neil
>>
>>> diff --git a/super-intel.c b/super-intel.c
>>> index e155a8ae99cb..a514dea6f95c 100644
>>> --- a/super-intel.c
>>> +++ b/super-intel.c
>>> @@ -629,6 +629,43 @@ static const char *_sys_dev_type[] = {
>>> [SYS_DEV_VMD] = "VMD"
>>> };
>>>
>>> +static int no_platform = -1;
>>> +
>>> +static int check_no_platform(void)
>>> +{
>>> + static const char search[] = "mdadm.imsm.test=1";
>>> + int fd;
>>> + char buf[1024];
>>
>> This isn't safe, /proc/cmdline can be longer than 1024 characters.
>
> Why not safe? I agree that /proc/cmdline can be longer than 1024 but the
> only only considers the first 1023 at most, and does so safely.
>
> What would you prefer? Should I use conf_line() to read the line and
> split it into words for us?
Hi Neil,
Not safe was probably not the right word. I just saw your new patch, I
think that's much better. My concern is that it failing to parse in some
conditions is going to be a pain in the neck to debug.
Thanks,
Jes
>>
>>
>