Re: [PATCH v2 2/9] loop:refactor: extract subfunction get_next_free_loop()

2022-11-20 Thread Kang-Che Sung
On Mon, Nov 21, 2022 at 9:19 AM Xiaoming Ni wrote: > static int get_next_free_loop(char *dev, size_t dev_size, int id) > { > int loopdevno = get_free_loop(); > if (loopdevno >= 0) { > snprintf(dev, dev_size, LOOP_FORMAT, loopdevno); > return 1;

Re: [PATCH v2 6/9] loop:refactor: Use a structure to reduce parameters

2022-11-20 Thread Xiaoming Ni
On 2022/11/21 12:28, Kang-Che Sung wrote: On Mon, Nov 21, 2022 at 9:31 AM Xiaoming Ni wrote: Also, it is unclear why there is the need to clone the loopinfo buffer. > /* Old kernel, does not support LO_FLAGS_AUTOCLEAR? */ > /* (this code path is not tested)

Re: [PATCH v2 6/9] loop:refactor: Use a structure to reduce parameters

2022-11-20 Thread Kang-Che Sung
On Mon, Nov 21, 2022 at 9:31 AM Xiaoming Ni wrote: > > Also, it is unclear why there is the need to clone the loopinfo buffer. > > > > > /* Old kernel, does not support LO_FLAGS_AUTOCLEAR? */ > > > /* (this code path is not tested) */ > > > -

[PATCH v3 6/9] loop:refactor: Use a structure to reduce parameters

2022-11-20 Thread Xiaoming Ni
Step 6 of micro-refactoring the set_loop(): Use structs to avoid transferring a large number of parameters in set_loop_configure() and set_loop_info() function old new delta set_loop 708

[PATCH v3 8/9] loop:refactor: extract subfunction set_loop_dev()

2022-11-20 Thread Xiaoming Ni
Step 8 of micro-refactoring the set_loop(): Extract subfunction open_file() from set_loop_dev() function old new delta set_loop 700 716 +16

[PATCH v3 9/9] loop: Add LOOP_CONFIGURE ioctl

2022-11-20 Thread Xiaoming Ni
LOOP_CONFIGURE is added to Linux 5.8 This allows userspace to completely setup a loop device with a single ioctl, removing the in-between state where the device can be partially configured - eg the loop device has a backing file associated with it, but is reading from the wrong offset.

[PATCH v3 2/9] loop:refactor: extract subfunction get_next_free_loop()

2022-11-20 Thread Xiaoming Ni
Step 2 of micro-refactoring the set_loop function () Extract subfunction get_next_free_loop() from set_loop() Also fix miss free(try) when stat(try) and mknod fail function old new delta set_loop

[PATCH v3 4/9] loop:refactor: extract subfunction set_loop_info()

2022-11-20 Thread Xiaoming Ni
Step 4 of micro-refactoring the set_loop(): Extract subfunction set_loop_info() from set_loop() function old new delta set_loop 734 700 -34

[PATCH v3 5/9] loop:refactor: extract subfunction set_loop_configure()

2022-11-20 Thread Xiaoming Ni
Step 5 of micro-refactoring the set_loop(): Extract subfunction set_loop_configure() function old new delta set_loop 700 708 +8

[PATCH v3 7/9] loop:refactor: Extract subfunction do_stat_and_mknod()

2022-11-20 Thread Xiaoming Ni
Step 7 of micro-refactoring the set_loop(): Extract subfunction do_stat_and_mknod() function old new delta set_loop 720 700 -20

[PATCH v3 3/9] loop:refactor: del close_and_try_next_loopN

2022-11-20 Thread Xiaoming Ni
Step 3 of micro-refactoring the set_loop() function: Delete close_and_try_next_loopN. (add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0) Total: 0 bytes Signed-off-by: Xiaoming Ni --- libbb/loop.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git

[PATCH v3 1/9] loop:refactor: extract subfunction open_file()

2022-11-20 Thread Xiaoming Ni
Step 1 of micro-refactoring the set_loop(): Extract subfunction open_file() from set_loop() function old new delta set_loop 760 758 -2

[PATCH v3 0/9] loop: Micro-refactoring set_loop() and add LOOP_CONFIGURE

2022-11-20 Thread Xiaoming Ni
LOOP_CONFIGURE is added to Linux 5.8 This allows userspace to completely setup a loop device with a single ioctl, removing the in-between state where the device can be partially configured - eg the loop device has a backing file associated with it, but is reading from the wrong offset.

Re: AW: [PATCH v2 5/9] loop:refactor: extract subfunction set_loop_configure()

2022-11-20 Thread Xiaoming Ni
On 2022/11/18 20:36, Walter Harms wrote: A little tweak make it more readable (i hope) putting if (rc) direkt behind rc = ioctl(lfd, BB_LOOP_SET_STATUS, ); if (rc == 0) return lfd; // no need to check rc again if ( (loopinfo.lo_flags & BB_LO_FLAGS_AUTOCLEAR)) { // try again

Re: [PATCH v2 9/9] loop: Add LOOP_CONFIGURE ioctl

2022-11-20 Thread Xiaoming Ni
On 2022/11/19 2:22, Kang-Che Sung wrote: On Friday, November 18, 2022, Xiaoming Ni > wrote: > LOOP_CONFIGURE is added to Linux 5.8 > > This allows userspace to completely setup a loop device with a single > ioctl, removing the in-between state where the

Re: [PATCH v2 6/9] loop:refactor: Use a structure to reduce parameters

2022-11-20 Thread Xiaoming Ni
On 2022/11/19 2:06, Kang-Che Sung wrote: On Friday, November 18, 2022, Xiaoming Ni > wrote: > Step 6 of micro-refactoring the set_loop(): >         Use structs to avoid transferring a large number of parameters >         in set_loop_configure() and

Re: [PATCH v2 2/9] loop:refactor: extract subfunction get_next_free_loop()

2022-11-20 Thread Xiaoming Ni
On 2022/11/19 1:40, Kang-Che Sung wrote: On Friday, November 18, 2022, Xiaoming Ni > wrote: > Step 2 of micro-refactoring the set_loop function () >         Extract subfunction get_next_free_loop() from set_loop() > > Also fix miss free(try) when stat(try)