From f4aa18bea1348602c165642f3a9680aee0c6706c Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 7 Jun 2025 11:46:40 -0400 Subject: cmd_device: Device add now updates blkid cache Signed-off-by: Kent Overstreet --- c_src/cmd_device.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'c_src/cmd_device.c') diff --git a/c_src/cmd_device.c b/c_src/cmd_device.c index fe1dbc95..800ccca4 100644 --- a/c_src/cmd_device.c +++ b/c_src/cmd_device.c @@ -12,6 +12,8 @@ #include #include +#include + #include "libbcachefs/bcachefs.h" #include "libbcachefs/bcachefs_ioctl.h" #include "libbcachefs/errcode.h" @@ -88,7 +90,7 @@ static int cmd_device_add(int argc, char *argv[]) exit(EXIT_FAILURE); break; } -} + } args_shift(optind); char *fs_path = arg_pop(); @@ -125,6 +127,18 @@ static int cmd_device_add(int argc, char *argv[]) darray_exit(&devs); free(sb); bchu_disk_add(fs, dev_opts.path); + + /* A whole bunch of nonsense to get blkid to update its cache, so + * mount can find the new device by UUID: + */ + blkid_cache cache = NULL; + if (!blkid_get_cache(&cache, NULL)) { + blkid_dev dev = blkid_get_dev(cache, dev_opts.path, BLKID_DEV_VERIFY); + if (dev) + blkid_verify(cache, dev); + blkid_put_cache(cache); + } + return 0; } -- cgit v1.2.3