From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yang Xu Date: Wed, 17 Jul 2019 13:29:27 +0800 Subject: [LTP] [PATCH v4 1/3] lib: alter find_free_loopdev() In-Reply-To: <5D2819B8.8050401@cn.fujitsu.com> References: <5D25B05A.8000600@cn.fujitsu.com> <1562755997-5626-1-git-send-email-xuyang2018.jy@cn.fujitsu.com> <20190710135710.GC5628@rei.lan> <5D26B44D.4010208@cn.fujitsu.com> <20190711125108.GB8709@rei> <5D2819B8.8050401@cn.fujitsu.com> Message-ID: <5D2EB237.7070202@cn.fujitsu.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ltp@lists.linux.it > >> 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()? Hi Cyril ping. :-) > Thanks > Yang Xu >