summaryrefslogtreecommitdiff
path: root/c_src/cmd_device.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-06-07 11:46:40 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-06-07 19:04:03 -0400
commitf4aa18bea1348602c165642f3a9680aee0c6706c (patch)
tree311ed0484861d4e93ce9bb04c26201a88bf7c66a /c_src/cmd_device.c
parent8868e1c2b4586f5fc0a693509188afdecbd56127 (diff)
cmd_device: Device add now updates blkid cache
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'c_src/cmd_device.c')
-rw-r--r--c_src/cmd_device.c16
1 files changed, 15 insertions, 1 deletions
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 <sys/types.h>
#include <unistd.h>
+#include <blkid.h>
+
#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;
}