[LTP] [PATCH v4 1/3] lib: alter find_free_loopdev()
Yang Xu
xuyang2018.jy@cn.fujitsu.com
Fri Jul 12 07:25:12 CEST 2019
> Hi!
>>> This needs more changes than this.
>>>
>>> The problem here is that the function modifies dev_path which is
>>> returned by tst_acquire_device() so if you call this function after
>>> tst_acquire_device() it will rewrite the dev_path which means that the
>>> test would end up with wrong device path in tst_device->dev.
>>>
>>> I guess that the easiest solution would be changing the function to get
>>> buffer parameter which, when non-NULL, is filled with the path.
>>>
>>> I.e. the function prototype would became:
>>>
>>> int tst_find_free_loopdev(char *path, size_t path_len);
>>>
>>> And we would pass the dev_path inside of the tst_device.c and NULL from
>>> the copy_file_range() tests.
>> Hi Cyril
>>
>> This is a good comment. But I doubt why we don't use a set_devpath_flag todistinguish it.
>> Or you have a future plan(in different directory ,/dev,/dev/loop/,/dev/block)?
> Well you can add a flag to the function but that would be a bad design
> as far as I can tell. It would still allowed for a user to modify the
> library internal state by calling the tst_find_free_loopdev() with the
> flag set.
>
Hi Cyril
Even we use int tst_find_free_loopdev(char *path, size_t path_len), user aslo can modify the internal state.
I don't know how to limit it. Can you give some example code? If we set LTP_DEV in *tst_acquire_device__,
we can pass dev and len to tst_find_free_loopdev(), but if we not set LTP_DEV, what can pass to tst_free_loopdev()?
Thanks
Yang Xu
More information about the ltp
mailing list