Re: [PATCH] util-linux: add minimal uuidgen implementation

2026-01-30 Thread Osama Abdelkader via busybox
On Fri, Jan 30, 2026 at 09:41:09PM +0100, Hans Ulli Kroll wrote:
> Hi Osama
> 
> On Thu, 2026-01-29 at 22:35 +0100, Osama Abdelkader via busybox wrote:
> > On Sun, Nov 23, 2025 at 03:19:58AM +0200, Osama Abdelkader wrote:
> > > Add a simple uuidgen utility that generates RFC 4122 compliant
> > > UUIDs (version 4, random). Uses the existing generate_uuid()
> > > function from libbb.
> > > 
> > > Features:
> > > - Generates standard format UUIDs: ----
> > > - RFC 4122 version 4 compliant
> > > - Minimal implementation (~1.1 kb)
> > > - NOFORK applet for efficiency
> > > 
> > > Signed-off-by: Osama Abdelkader 
> > > ---
> > >  util-linux/uuidgen.c | 47 
> > >  1 file changed, 47 insertions(+)
> > >  create mode 100644 util-linux/uuidgen.c
> > > 
> > > diff --git a/util-linux/uuidgen.c b/util-linux/uuidgen.c
> > > new file mode 100644
> > > index 0..6c5fb6903
> > > --- /dev/null
> > > +++ b/util-linux/uuidgen.c
> > > @@ -0,0 +1,47 @@
> > > +/* vi: set sw=4 ts=4: */
> > > +/*
> > > + * Mini uuidgen implementation for busybox
> > > + *
> > > + * Licensed under GPLv2 or later, see file LICENSE in this source tree.
> > > + */
> > > +//config:config UUIDGEN
> > > +//config:bool "uuidgen (1.1 kb)"
> > > +//config:default y
> > > +//config:help
> > > +//config:Generate a UUID (Universally Unique Identifier) in RFC 
> > > 4122 format.
> > > +
> > > +//applet:IF_UUIDGEN(APPLET_NOFORK(uuidgen, uuidgen, BB_DIR_USR_BIN, 
> > > BB_SUID_DROP, uuidgen))
> > > +
> > > +//kbuild:lib-$(CONFIG_UUIDGEN) += uuidgen.o
> > > +
> > > +//usage:#define uuidgen_trivial_usage
> > > +//usage:   ""
> > > +//usage:#define uuidgen_full_usage "\n\n"
> > > +//usage:   "Generate a UUID (Universally Unique Identifier)"
> > > +
> > > +#include "libbb.h"
> > > +
> > > +/* This is a NOFORK applet. Be very careful! */
> > > +
> > > +int uuidgen_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
> > > +int uuidgen_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
> > > +{
> > > + uint8_t uuid[16];
> > > + 
> > > + if (argv[1]) {
> > > + bb_show_usage();
> > > + }
> > > +
> > > + generate_uuid(uuid);
> > > + 
> > > + /* Format: ---- */
> > > + 
> > > printf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
> > > + uuid[0], uuid[1], uuid[2], uuid[3],
> > > + uuid[4], uuid[5],
> > > + uuid[6], uuid[7],
> > > + uuid[8], uuid[9],
> > > + uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]);
> > > +
> > > + return fflush_all();
> > > +}
> > > +
> > > -- 
> > > 2.43.0
> > > 
> > ping.
> > 
> 
> This is my version of the from my (endless) didn't send list
> Only the main code
> 
> int uuidgen_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
> int uuidgen_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
> {
>   struct volume_id id;
>   char uuid[37];
> 
>   generate_uuid(uuid);
>   volume_id_set_uuid(&id, uuid, UUID_DCE);
>   printf("%s\n", id.uuid);
> 
>   return 0;
> }
> 
> I didn't check the size.
> You can take this
> 
> Ulli

Hi Ulli,

Thank you, I just sent a v2, please feel free to change the commit
message.

Thanks,
Osama
___
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] util-linux: add minimal uuidgen implementation

2026-01-30 Thread Hans Ulli Kroll via busybox
Hi Osama

On Thu, 2026-01-29 at 22:35 +0100, Osama Abdelkader via busybox wrote:
> On Sun, Nov 23, 2025 at 03:19:58AM +0200, Osama Abdelkader wrote:
> > Add a simple uuidgen utility that generates RFC 4122 compliant
> > UUIDs (version 4, random). Uses the existing generate_uuid()
> > function from libbb.
> > 
> > Features:
> > - Generates standard format UUIDs: ----
> > - RFC 4122 version 4 compliant
> > - Minimal implementation (~1.1 kb)
> > - NOFORK applet for efficiency
> > 
> > Signed-off-by: Osama Abdelkader 
> > ---
> >  util-linux/uuidgen.c | 47 
> >  1 file changed, 47 insertions(+)
> >  create mode 100644 util-linux/uuidgen.c
> > 
> > diff --git a/util-linux/uuidgen.c b/util-linux/uuidgen.c
> > new file mode 100644
> > index 0..6c5fb6903
> > --- /dev/null
> > +++ b/util-linux/uuidgen.c
> > @@ -0,0 +1,47 @@
> > +/* vi: set sw=4 ts=4: */
> > +/*
> > + * Mini uuidgen implementation for busybox
> > + *
> > + * Licensed under GPLv2 or later, see file LICENSE in this source tree.
> > + */
> > +//config:config UUIDGEN
> > +//config:  bool "uuidgen (1.1 kb)"
> > +//config:  default y
> > +//config:  help
> > +//config:  Generate a UUID (Universally Unique Identifier) in RFC 4122 
> > format.
> > +
> > +//applet:IF_UUIDGEN(APPLET_NOFORK(uuidgen, uuidgen, BB_DIR_USR_BIN, 
> > BB_SUID_DROP, uuidgen))
> > +
> > +//kbuild:lib-$(CONFIG_UUIDGEN) += uuidgen.o
> > +
> > +//usage:#define uuidgen_trivial_usage
> > +//usage:   ""
> > +//usage:#define uuidgen_full_usage "\n\n"
> > +//usage:   "Generate a UUID (Universally Unique Identifier)"
> > +
> > +#include "libbb.h"
> > +
> > +/* This is a NOFORK applet. Be very careful! */
> > +
> > +int uuidgen_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
> > +int uuidgen_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
> > +{
> > +   uint8_t uuid[16];
> > +   
> > +   if (argv[1]) {
> > +   bb_show_usage();
> > +   }
> > +
> > +   generate_uuid(uuid);
> > +   
> > +   /* Format: ---- */
> > +   
> > printf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
> > +   uuid[0], uuid[1], uuid[2], uuid[3],
> > +   uuid[4], uuid[5],
> > +   uuid[6], uuid[7],
> > +   uuid[8], uuid[9],
> > +   uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]);
> > +
> > +   return fflush_all();
> > +}
> > +
> > -- 
> > 2.43.0
> > 
> ping.
> 

This is my version of the from my (endless) didn't send list
Only the main code

int uuidgen_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int uuidgen_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
struct volume_id id;
char uuid[37];

generate_uuid(uuid);
volume_id_set_uuid(&id, uuid, UUID_DCE);
printf("%s\n", id.uuid);

return 0;
}

I didn't check the size.
You can take this

Ulli
___
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] util-linux: add minimal uuidgen implementation

2026-01-29 Thread Osama Abdelkader via busybox
On Sun, Nov 23, 2025 at 03:19:58AM +0200, Osama Abdelkader wrote:
> Add a simple uuidgen utility that generates RFC 4122 compliant
> UUIDs (version 4, random). Uses the existing generate_uuid()
> function from libbb.
> 
> Features:
> - Generates standard format UUIDs: ----
> - RFC 4122 version 4 compliant
> - Minimal implementation (~1.1 kb)
> - NOFORK applet for efficiency
> 
> Signed-off-by: Osama Abdelkader 
> ---
>  util-linux/uuidgen.c | 47 
>  1 file changed, 47 insertions(+)
>  create mode 100644 util-linux/uuidgen.c
> 
> diff --git a/util-linux/uuidgen.c b/util-linux/uuidgen.c
> new file mode 100644
> index 0..6c5fb6903
> --- /dev/null
> +++ b/util-linux/uuidgen.c
> @@ -0,0 +1,47 @@
> +/* vi: set sw=4 ts=4: */
> +/*
> + * Mini uuidgen implementation for busybox
> + *
> + * Licensed under GPLv2 or later, see file LICENSE in this source tree.
> + */
> +//config:config UUIDGEN
> +//config:bool "uuidgen (1.1 kb)"
> +//config:default y
> +//config:help
> +//config:Generate a UUID (Universally Unique Identifier) in RFC 4122 
> format.
> +
> +//applet:IF_UUIDGEN(APPLET_NOFORK(uuidgen, uuidgen, BB_DIR_USR_BIN, 
> BB_SUID_DROP, uuidgen))
> +
> +//kbuild:lib-$(CONFIG_UUIDGEN) += uuidgen.o
> +
> +//usage:#define uuidgen_trivial_usage
> +//usage:   ""
> +//usage:#define uuidgen_full_usage "\n\n"
> +//usage:   "Generate a UUID (Universally Unique Identifier)"
> +
> +#include "libbb.h"
> +
> +/* This is a NOFORK applet. Be very careful! */
> +
> +int uuidgen_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
> +int uuidgen_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
> +{
> + uint8_t uuid[16];
> + 
> + if (argv[1]) {
> + bb_show_usage();
> + }
> +
> + generate_uuid(uuid);
> + 
> + /* Format: ---- */
> + 
> printf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
> + uuid[0], uuid[1], uuid[2], uuid[3],
> + uuid[4], uuid[5],
> + uuid[6], uuid[7],
> + uuid[8], uuid[9],
> + uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]);
> +
> + return fflush_all();
> +}
> +
> -- 
> 2.43.0
> 
ping.
___
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] util-linux: add minimal uuidgen implementation

2025-12-04 Thread Osama Abdelkader
On Wed, Nov 26, 2025 at 12:56:23AM +0800, Kang-Che Sung wrote:
> On Mon, Nov 24, 2025 at 11:29 AM Osama Abdelkader
>  wrote:
> >
> > Add a simple uuidgen utility that generates RFC 4122 compliant
> > UUIDs (version 4, random). Uses the existing generate_uuid()
> > function from libbb.
> >
> > Features:
> > - Generates standard format UUIDs: ----
> > - RFC 4122 version 4 compliant
> > - Minimal implementation (~1.1 kb)
> > - NOFORK applet for efficiency
> 
> A simple reminder that, in Linux,
> `cat /proc/sys/kernel/random/uuid` can be an alias to uuidgen.

Hi,

Just following up on this patch in case it was missed in the thread.

Regarding the point about using /proc/sys/kernel/random/uuid — I agree this
works on Linux, but I think a small uuidgen applet can still be useful in
BusyBox because:

  * BusyBox runs in environments where /proc may be unavailable
(initramfs, early boot, rescue shells, Android, static systems).

  * The /proc uuid interface is Linux-specific, while BusyBox is often used
on non-Linux or restricted platforms.

  * Using libbb’s generate_uuid() keeps behavior consistent and portable.

Happy to improve or simplify the applet if needed.

Thanks!
Osama
___
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] util-linux: add minimal uuidgen implementation

2025-11-25 Thread Osama Abdelkader
On Wed, Nov 26, 2025 at 12:56:23AM +0800, Kang-Che Sung wrote:
> On Mon, Nov 24, 2025 at 11:29 AM Osama Abdelkader
>  wrote:
> >
> > Add a simple uuidgen utility that generates RFC 4122 compliant
> > UUIDs (version 4, random). Uses the existing generate_uuid()
> > function from libbb.
> >
> > Features:
> > - Generates standard format UUIDs: ----
> > - RFC 4122 version 4 compliant
> > - Minimal implementation (~1.1 kb)
> > - NOFORK applet for efficiency
> 
> A simple reminder that, in Linux,
> `cat /proc/sys/kernel/random/uuid` can be an alias to uuidgen.

Thanks for the reminder! Yes, on Linux systems with /proc mounted,
"cat /proc/sys/kernel/random/uuid" can generate UUIDs.

However, there are a few cases where a standalone uuidgen applet is still
useful for BusyBox:

1. Portability:
   The /proc/sys/kernel/random/uuid interface is Linux-specific.
   BusyBox runs on platforms/environments where /proc is absent,
   read-only, or not mounted yet (initramfs, rescue shells, static
   minimal systems, Android).

2. Consistency:
   BusyBox already implements many util-linux utilities, including some
   that overlap with kernel-provided interfaces (e.g. dmesg, mount,
   fstrim, lsblk). uuidgen fills one of the remaining gaps.

3. Features:
   Using libbb's generate_uuid() ensures RFC 4122 v4 UUIDs regardless of
   kernel configuration. Some systems disable /proc/sys/kernel/random/*
   for security.

If these reasons make sense, I'm happy to revise or extend the applet as needed.

BR,
Osama
___
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] util-linux: add minimal uuidgen implementation

2025-11-25 Thread Kang-Che Sung
On Mon, Nov 24, 2025 at 11:29 AM Osama Abdelkader
 wrote:
>
> Add a simple uuidgen utility that generates RFC 4122 compliant
> UUIDs (version 4, random). Uses the existing generate_uuid()
> function from libbb.
>
> Features:
> - Generates standard format UUIDs: ----
> - RFC 4122 version 4 compliant
> - Minimal implementation (~1.1 kb)
> - NOFORK applet for efficiency

A simple reminder that, in Linux,
`cat /proc/sys/kernel/random/uuid` can be an alias to uuidgen.
___
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox