On 2022/11/18 14:34, Lauri Kasanen wrote:
On Fri, 18 Nov 2022 09:01:58 +0800
Xiaoming Ni wrote:
LOOP_CONFIGURE is added to Linux 5.8
...
diff --git a/libbb/loop.c b/libbb/loop.c
index 9a7ca666d..d4f4906b0 100644
--- a/libbb/loop.c
+++ b/libbb/loop.c
@@ -126,6 +126,30 @@ static int
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
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
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.
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
On 2022/11/18 20:20, Walter Harms wrote:
hi,
just a minor comment.
do not use i as name for return value,
most ppl use it as loop counter, triggers the
wrong circuits in the brain. (rule of least surprise).
just name it err or what you like,
and please untangle the if()
if (err>=0)
return
On 2022/11/18 20:27, Walter Harms wrote:
on other minor
if (rc && errno == ENXIO)
turn it on its head safes one indent level
if ( !rc || errno != ENXIO )
return -1; // failed to get loopinfo
jm2c
Here's for copy-paste consistency
Simplification has been implemented in patch 5 by
On Fri, Nov 18, 2022 at 9:04 AM 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 device can be partially
> configured - eg the loop device has a backing file
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 without BB_LO_FLAGS_AUTOCLEAR
// does it realy
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
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
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.
Step 5 of micro-refactoring the set_loop():
Extract subfunction set_loop_configure()
function old new delta
set_loop 700 708 +8
Step 7 of micro-refactoring the set_loop():
Extract subfunction do_stat_and_mknod()
function old new delta
set_loop 720 700 -20
again try to safe indent level
if (stat(dev, ) == 0 && S_ISBLK(statbuf.st_mode))
return 0;
jm2c
Von: busybox im Auftrag von Xiaoming Ni
Gesendet: Freitag, 18. November 2022 13:14:46
An: busybox@busybox.net; vda.li...@googlemail.com; c...@gmx.com;
On 2022/11/18 20:39, Walter Harms wrote:
again try to safe indent level
if (stat(dev, ) == 0 && S_ISBLK(statbuf.st_mode))
return 0;
jm2c
Thanks, will be modified in v3
Von: busybox im Auftrag von Xiaoming Ni
Gesendet: Freitag, 18. November
i am wondering, maybe question for the maintainer.
would it hurt to open it O_RDONLY in the first place ?
cm2c
Von: busybox im Auftrag von Xiaoming Ni
Gesendet: Freitag, 18. November 2022 13:14:47
An: busybox@busybox.net; vda.li...@googlemail.com;
on other minor
if (rc && errno == ENXIO)
turn it on its head safes one indent level
if ( !rc || errno != ENXIO )
return -1; // failed to get loopinfo
jm2c
Von: busybox im Auftrag von Xiaoming Ni
Gesendet: Freitag, 18. November 2022 13:14:43
An:
On 2022/11/18 17:13, Kang-Che Sung wrote:
On Fri, Nov 18, 2022 at 9:04 AM 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 device can be partially
configured - eg the
On Fri, 18 Nov 2022 17:11:17 +0800
Xiaoming Ni wrote:
> >> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)
> >> +static int set_loop_configure(int ffd, int lfd, bb_loop_info *loopinfo)
> >> +#else
> >
> > This assumes compile-time matches runtime. Ie, if you build on a 5.8
> > system, but run
Step 1 of micro-refactoring the set_loop():
Extract subfunction open_file() from set_loop()
function old new delta
set_loop 760 758 -2
hi,
just a minor comment.
do not use i as name for return value,
most ppl use it as loop counter, triggers the
wrong circuits in the brain. (rule of least surprise).
just name it err or what you like,
and please untangle the if()
if (err>=0)
return
if (err==-2)
return
return -1
just my
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 device can be partially
> configured - eg the loop device has a backing file
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) and mknod fail
>
> function old new
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 set_loop_info()
>
> function old new
25 matches
Mail list logo