lib/tst_device.c: Add exception handling of function tst_find_free_loopdev
PATCH 1/1 lib/tst_device.c: Add exception handling of function tst_find_free_loopdev
Hi!
Quoted 5 lines
In addition, when "loopdevno =
ioctl(fd, LOOP_CTL_GET_FREE)" get free loop device i, and the loop device file /dev/loop%i has been removed?set_dev_pathwill return 1 and set " /dev/block/loop%i " in path. It might happened in many Embedded Systems because the test process's id is root always. So we could also Add exception handling?
Or maybe we can try to create it when node doesn't exist?
mknod("/dev/loop%i", S_IFBLK|0644, makedev(7, i))-----------------------------------------------------------
Quoted 33 lines
Hi Petr, Li,
At first, it seems ok that using
ST_RETRY_FUNCmacro to try more times for race condition.In addition, when "loopdevno =
ioctl(fd, LOOP_CTL_GET_FREE)" get free loop device i, and the loop device file /dev/loop%i has been removed?set_dev_pathwill return 1 and set " /dev/block/loop%i " in path. It might happened in many Embedded Systems because the test process's id is root always. So we could also Add exception handling?Thanks!
Best Regards,
GongyiQuoted 16 lines
Hi,
Quoted 8 lines
Quoted 3 lines
Because of race condition or abnormal env,
set_dev_pathmay be return 1. And whenset_dev_pathreturn 1 intst_find_free_loopdev, we should return Immediately.If there exists a race condition, I firstly think of the
TST_RETRY_FUNCmacro to try more times for theset_dev_path. That might help to get the function success in the follow-up tries.+1
Kind regards,
Petr
PATCH 1/1 lib/tst_device.c: Add exception handling of function tst_find_free_loopdev
Hi!
Quoted 8 lines
Quoted 5 lines
In addition, when "loopdevno =
ioctl(fd, LOOP_CTL_GET_FREE)" get free loop device i, and the loop device file /dev/loop%i has been removed??set_dev_pathwill return 1 and set " /dev/block/loop%i "
in path. It might happened in many Embedded Systems because the test process's id is root always. So we could also Add exception handling?Or maybe we can try to create it when node doesn't exist?
mknod("/dev/loop%i", S_IFBLK|0644, makedev(7, i))
I do not really get what happens on your system. It looks like dev fs is not properly populated, which would be bug in your system rather than in the test library.
What is the state of /dev/loop* and /dev/block/loop* before you attempt to run the test?
Signature · 2 lines
Cyril Hrubis [email protected]