diff mbox series

libubi: ubi_update_start: slightly improve documentation

Message ID 20240710112904.15172-1-ceggers@arri.de
State New
Headers show
Series libubi: ubi_update_start: slightly improve documentation | expand

Commit Message

Christian Eggers July 10, 2024, 11:29 a.m. UTC
Calling ubi_update_start() may fail if exclusive access to the UBI
volume cannot be established by the kernel. This is likely to happen if
an UBI volume is updated directly after creation, because current
versions of (systemd-)udevd run their internal 'blkid' also for UBI
volumes as soon as they appear (trying to read the UBIFS UUID).

There are mainly to options for this case:
1. Don't allow udevd to read UBI volumes at all (means loosing
functionatlity)
2. Wait until udevd has finished accessing a new volume (requires
cooperation with udevd)
3. Simply retry after short time in case of EBUSY

For using option 3, the documentation should state that the concrete
error code can be read via errno (this has always been the case since
libubi has been introduced).

Link: https://groups.google.com/g/swupdate/c/8NVooKjD9oo
Signed-off-by: Christian Eggers <ceggers@arri.de>
---
 include/libubi.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Zhihao Cheng July 10, 2024, 11:43 a.m. UTC | #1
在 2024/7/10 19:29, Christian Eggers 写道:
> Calling ubi_update_start() may fail if exclusive access to the UBI
> volume cannot be established by the kernel. This is likely to happen if
> an UBI volume is updated directly after creation, because current
> versions of (systemd-)udevd run their internal 'blkid' also for UBI
> volumes as soon as they appear (trying to read the UBIFS UUID).
> 
> There are mainly to options for this case:
> 1. Don't allow udevd to read UBI volumes at all (means loosing
> functionatlity)
> 2. Wait until udevd has finished accessing a new volume (requires
> cooperation with udevd)
> 3. Simply retry after short time in case of EBUSY
> 
> For using option 3, the documentation should state that the concrete
> error code can be read via errno (this has always been the case since
> libubi has been introduced).
> 
> Link: https://groups.google.com/g/swupdate/c/8NVooKjD9oo
> Signed-off-by: Christian Eggers <ceggers@arri.de>
> ---

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>

>   include/libubi.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/libubi.h b/include/libubi.h
> index e1e234e1b01b..9cb5037bb92a 100644
> --- a/include/libubi.h
> +++ b/include/libubi.h
> @@ -431,8 +431,8 @@ int ubi_vol_block_remove(int fd);
>    * @bytes: how many bytes will be written to the volume
>    *
>    * This function initiates UBI volume update and returns %0 in case of success
> - * and %-1 in case of error. The caller is assumed to write @bytes data to the
> - * volume @fd afterward.
> + * and %-1 in case of error (errno is set). The caller is assumed to write
> + * @bytes data to the volume @fd afterward.
>    */
>   int ubi_update_start(libubi_t desc, int fd, long long bytes);
>   
>
David Oberhollenzer Sept. 25, 2024, 5:45 a.m. UTC | #2
Applied to mtd-utils.git master.

Thanks,

David
diff mbox series

Patch

diff --git a/include/libubi.h b/include/libubi.h
index e1e234e1b01b..9cb5037bb92a 100644
--- a/include/libubi.h
+++ b/include/libubi.h
@@ -431,8 +431,8 @@  int ubi_vol_block_remove(int fd);
  * @bytes: how many bytes will be written to the volume
  *
  * This function initiates UBI volume update and returns %0 in case of success
- * and %-1 in case of error. The caller is assumed to write @bytes data to the
- * volume @fd afterward.
+ * and %-1 in case of error (errno is set). The caller is assumed to write
+ * @bytes data to the volume @fd afterward.
  */
 int ubi_update_start(libubi_t desc, int fd, long long bytes);