Blame SOURCES/0093-grub2-btrfs-06-subvol-mount.patch

8631a2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8631a2
From: Michael Chang <mchang@suse.com>
8631a2
Date: Fri, 22 May 2015 11:45:25 +0000
8631a2
Subject: [PATCH] grub2-btrfs-06-subvol-mount
8631a2
8631a2
---
8631a2
 grub-core/fs/btrfs.c            | 195 +++++++++++++++++++++++++++++++++++++++-
8631a2
 grub-core/osdep/linux/getroot.c | 148 +++++++++++++++++++++++++++++-
8631a2
 util/grub-install.c             |  49 ++++++++++
8631a2
 include/grub/emu/getroot.h      |   5 ++
8631a2
 4 files changed, 392 insertions(+), 5 deletions(-)
8631a2
8631a2
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
09e3cc
index a47d29756..2e36ac47e 100644
8631a2
--- a/grub-core/fs/btrfs.c
8631a2
+++ b/grub-core/fs/btrfs.c
8631a2
@@ -32,6 +32,7 @@
8631a2
 #include <grub/command.h>
8631a2
 #include <grub/env.h>
8631a2
 #include <grub/extcmd.h>
8631a2
+#include <grub/list.h>
8631a2
 
8631a2
 GRUB_MOD_LICENSE ("GPLv3+");
8631a2
 
8631a2
@@ -245,6 +246,12 @@ static grub_err_t
8631a2
 grub_btrfs_read_logical (struct grub_btrfs_data *data,
8631a2
 			 grub_disk_addr_t addr, void *buf, grub_size_t size,
8631a2
 			 int recursion_depth);
8631a2
+static grub_err_t
8631a2
+get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key,
8631a2
+	  grub_uint64_t *tree, grub_uint8_t *type);
8631a2
+
8631a2
+grub_uint64_t
8631a2
+find_mtab_subvol_tree (const char *path, char **path_in_subvol);
8631a2
 
8631a2
 static grub_err_t
8631a2
 read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb)
8631a2
@@ -887,9 +894,26 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path)
8631a2
   grub_err_t err;
8631a2
   grub_uint64_t tree = 0;
8631a2
   grub_uint8_t type;
8631a2
+  grub_uint64_t saved_tree;
8631a2
   struct grub_btrfs_key key;
8631a2
 
8631a2
+  if (path[0] == '\0')
8631a2
+    {
8631a2
+      data->fs_tree = 0;
8631a2
+      return GRUB_ERR_NONE;
8631a2
+    }
8631a2
+
8631a2
+  err = get_root (data, &key, &tree, &type);
8631a2
+  if (err)
8631a2
+    return err;
8631a2
+
8631a2
+  saved_tree = data->fs_tree;
8631a2
+  data->fs_tree = tree;
8631a2
+
8631a2
   err = find_path (data, path, &key, &tree, &type);
8631a2
+
8631a2
+  data->fs_tree = saved_tree;
8631a2
+
8631a2
   if (err)
8631a2
       return grub_error(GRUB_ERR_FILE_NOT_FOUND, "couldn't locate %s\n", path);
8631a2
 
8631a2
@@ -1758,11 +1782,20 @@ grub_btrfs_dir (grub_device_t device, const char *path,
8631a2
   int r = 0;
8631a2
   grub_uint64_t tree;
8631a2
   grub_uint8_t type;
8631a2
+  char *new_path = NULL;
8631a2
 
8631a2
   if (!data)
8631a2
     return grub_errno;
8631a2
 
8631a2
-  err = find_path (data, path, &key_in, &tree, &type);
8631a2
+  tree = find_mtab_subvol_tree (path, &new_path);
8631a2
+
8631a2
+  if (tree)
8631a2
+    data->fs_tree = tree;
8631a2
+
8631a2
+  err = find_path (data, new_path ? new_path : path, &key_in, &tree, &type);
8631a2
+  if (new_path)
8631a2
+    grub_free (new_path);
8631a2
+
8631a2
   if (err)
8631a2
     {
8631a2
       grub_btrfs_unmount (data);
8631a2
@@ -1864,11 +1897,21 @@ grub_btrfs_open (struct grub_file *file, const char *name)
8631a2
   struct grub_btrfs_inode inode;
8631a2
   grub_uint8_t type;
8631a2
   struct grub_btrfs_key key_in;
8631a2
+  grub_uint64_t tree;
8631a2
+  char *new_path = NULL;
8631a2
 
8631a2
   if (!data)
8631a2
     return grub_errno;
8631a2
 
8631a2
-  err = find_path (data, name, &key_in, &data->tree, &type);
8631a2
+  tree = find_mtab_subvol_tree (name, &new_path);
8631a2
+
8631a2
+  if (tree)
8631a2
+    data->fs_tree = tree;
8631a2
+
8631a2
+  err = find_path (data, new_path ? new_path : name, &key_in, &data->tree, &type);
8631a2
+  if (new_path)
8631a2
+    grub_free (new_path);
8631a2
+
8631a2
   if (err)
8631a2
     {
8631a2
       grub_btrfs_unmount (data);
8631a2
@@ -2039,6 +2082,150 @@ grub_cmd_btrfs_info (grub_command_t cmd __attribute__ ((unused)), int argc,
8631a2
   return 0;
8631a2
 }
8631a2
 
8631a2
+struct grub_btrfs_mtab
8631a2
+{
8631a2
+  struct grub_btrfs_mtab *next;
8631a2
+  struct grub_btrfs_mtab **prev;
8631a2
+  char *path;
8631a2
+  char *subvol;
8631a2
+  grub_uint64_t tree;
8631a2
+};
8631a2
+
8631a2
+typedef struct grub_btrfs_mtab* grub_btrfs_mtab_t;
8631a2
+
8631a2
+static struct grub_btrfs_mtab *btrfs_mtab;
8631a2
+
8631a2
+#define FOR_GRUB_MTAB(var) FOR_LIST_ELEMENTS (var, btrfs_mtab)
8631a2
+#define FOR_GRUB_MTAB_SAFE(var, next) FOR_LIST_ELEMENTS_SAFE((var), (next), btrfs_mtab)
8631a2
+
8631a2
+static void
8631a2
+add_mountpoint (const char *path, const char *subvol, grub_uint64_t tree)
8631a2
+{
8631a2
+  grub_btrfs_mtab_t m = grub_malloc (sizeof (*m));
8631a2
+
8631a2
+  m->path = grub_strdup (path);
8631a2
+  m->subvol = grub_strdup (subvol);
8631a2
+  m->tree = tree;
8631a2
+  grub_list_push (GRUB_AS_LIST_P (&btrfs_mtab), GRUB_AS_LIST (m));
8631a2
+}
8631a2
+
8631a2
+static grub_err_t
8631a2
+grub_cmd_btrfs_mount_subvol (grub_command_t cmd __attribute__ ((unused)), int argc,
8631a2
+		     char **argv)
8631a2
+{
8631a2
+  char *devname, *dirname, *subvol;
8631a2
+  struct grub_btrfs_key key_in;
8631a2
+  grub_uint8_t type;
8631a2
+  grub_uint64_t tree;
8631a2
+  grub_uint64_t saved_tree;
8631a2
+  grub_err_t err;
8631a2
+  struct grub_btrfs_data *data = NULL;
8631a2
+  grub_device_t dev = NULL;
8631a2
+
8631a2
+  if (argc < 3)
8631a2
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, "required <dev> <dir> and <subvol>");
8631a2
+
8631a2
+  devname = grub_file_get_device_name(argv[0]);
8631a2
+  dev = grub_device_open (devname);
8631a2
+  grub_free (devname);
8631a2
+
8631a2
+  if (!dev)
8631a2
+    {
8631a2
+      err = grub_errno;
8631a2
+      goto err_out;
8631a2
+    }
8631a2
+
8631a2
+  dirname = argv[1];
8631a2
+  subvol = argv[2];
8631a2
+
8631a2
+  data = grub_btrfs_mount (dev);
8631a2
+  if (!data)
8631a2
+    {
8631a2
+      err = grub_errno;
8631a2
+      goto err_out;
8631a2
+    }
8631a2
+
8631a2
+  err = find_path (data, dirname, &key_in, &tree, &type);
8631a2
+  if (err)
8631a2
+    goto err_out;
8631a2
+
8631a2
+  if (type !=  GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
8631a2
+    {
8631a2
+      err = grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
8631a2
+      goto err_out;
8631a2
+    }
8631a2
+
8631a2
+  err = get_root (data, &key_in, &tree, &type);
8631a2
+
8631a2
+  if (err)
8631a2
+    goto err_out;
8631a2
+
8631a2
+  saved_tree = data->fs_tree;
8631a2
+  data->fs_tree = tree;
8631a2
+  err = find_path (data, subvol, &key_in, &tree, &type);
8631a2
+  data->fs_tree = saved_tree;
8631a2
+
8631a2
+  if (err)
8631a2
+    goto err_out;
8631a2
+
8631a2
+  if (key_in.object_id != grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK) || tree == 0)
8631a2
+    {
8631a2
+      err = grub_error (GRUB_ERR_BAD_FILE_TYPE, "%s: not a subvolume\n", subvol);
8631a2
+      goto err_out;
8631a2
+    }
8631a2
+
8631a2
+  grub_btrfs_unmount (data);
8631a2
+  grub_device_close (dev);
8631a2
+  add_mountpoint (dirname, subvol, tree);
8631a2
+
8631a2
+  return GRUB_ERR_NONE;
8631a2
+
8631a2
+err_out:
8631a2
+
8631a2
+  if (data)
8631a2
+    grub_btrfs_unmount (data);
8631a2
+
8631a2
+  if (dev)
8631a2
+    grub_device_close (dev);
8631a2
+
8631a2
+  return err;
8631a2
+}
8631a2
+
8631a2
+grub_uint64_t
8631a2
+find_mtab_subvol_tree (const char *path, char **path_in_subvol)
8631a2
+{
8631a2
+  grub_btrfs_mtab_t m, cm;
8631a2
+  grub_uint64_t tree;
8631a2
+
8631a2
+  if (!path || !path_in_subvol)
8631a2
+    return 0;
8631a2
+
8631a2
+  *path_in_subvol = NULL;
8631a2
+  tree = 0;
8631a2
+  cm = NULL;
8631a2
+
8631a2
+  FOR_GRUB_MTAB (m)
8631a2
+    {
8631a2
+      if (grub_strncmp (path, m->path, grub_strlen (m->path)) == 0)
8631a2
+	{
8631a2
+	  if (!cm)
8631a2
+	    cm = m;
8631a2
+	  else
8631a2
+	    if (grub_strcmp (m->path, cm->path) > 0)
8631a2
+	      cm = m;
8631a2
+	}
8631a2
+    }
8631a2
+
8631a2
+  if (cm)
8631a2
+    {
8631a2
+      const char *s = path + grub_strlen (cm->path);
8631a2
+      *path_in_subvol = (s[0] == '\0') ? grub_strdup ("/") : grub_strdup (s);
8631a2
+      tree = cm->tree;
8631a2
+    }
8631a2
+
8631a2
+  return tree;
8631a2
+}
8631a2
+
8631a2
 static grub_err_t
8631a2
 get_fs_root(struct grub_btrfs_data *data, grub_uint64_t tree,
8631a2
             grub_uint64_t objectid, grub_uint64_t offset,
8631a2
@@ -2245,6 +2432,7 @@ static struct grub_fs grub_btrfs_fs = {
8631a2
 };
8631a2
 
8631a2
 static grub_command_t cmd_info;
8631a2
+static grub_command_t cmd_mount_subvol;
8631a2
 static grub_extcmd_t cmd_list_subvols;
8631a2
 
8631a2
 static char *
8631a2
@@ -2308,6 +2496,9 @@ GRUB_MOD_INIT (btrfs)
8631a2
   cmd_info = grub_register_command("btrfs-info", grub_cmd_btrfs_info,
8631a2
 				   "DEVICE",
8631a2
 				   "Print BtrFS info about DEVICE.");
8631a2
+  cmd_mount_subvol = grub_register_command("btrfs-mount-subvol", grub_cmd_btrfs_mount_subvol,
8631a2
+				   "DEVICE DIRECTORY SUBVOL",
8631a2
+				   "Set btrfs DEVICE the DIRECTORY a mountpoint of SUBVOL.");
8631a2
   cmd_list_subvols = grub_register_extcmd("btrfs-list-subvols",
8631a2
 					 grub_cmd_btrfs_list_subvols, 0,
8631a2
 					 "[-p|-n] [-o var] DEVICE",
8631a2
diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
09e3cc
index 5d50dd6f8..4c5a13022 100644
8631a2
--- a/grub-core/osdep/linux/getroot.c
8631a2
+++ b/grub-core/osdep/linux/getroot.c
8631a2
@@ -107,6 +107,14 @@ struct btrfs_ioctl_search_key
8631a2
   grub_uint32_t unused[9];
8631a2
 };
8631a2
 
8631a2
+struct btrfs_ioctl_search_header {
8631a2
+  grub_uint64_t transid;
8631a2
+  grub_uint64_t objectid;
8631a2
+  grub_uint64_t offset;
8631a2
+  grub_uint32_t type;
8631a2
+  grub_uint32_t len;
8631a2
+};
8631a2
+
8631a2
 struct btrfs_ioctl_search_args {
8631a2
   struct btrfs_ioctl_search_key key;
8631a2
   grub_uint64_t buf[(4096 - sizeof(struct btrfs_ioctl_search_key))
8631a2
@@ -378,6 +386,109 @@ get_btrfs_fs_prefix (const char *mount_path)
8631a2
 
8631a2
 int use_relative_path_on_btrfs = 0;
8631a2
 
8631a2
+static char *
8631a2
+get_btrfs_subvol (const char *path)
8631a2
+{
8631a2
+  struct btrfs_ioctl_ino_lookup_args args;
8631a2
+  grub_uint64_t tree_id;
8631a2
+  int fd = -1;
8631a2
+  char *ret = NULL;
8631a2
+
8631a2
+  fd = open (path, O_RDONLY);
8631a2
+
8631a2
+  if (fd < 0)
8631a2
+    return NULL;
8631a2
+
8631a2
+  memset (&args, 0, sizeof(args));
8631a2
+  args.objectid = GRUB_BTRFS_TREE_ROOT_OBJECTID;
8631a2
+
8631a2
+  if (ioctl (fd, BTRFS_IOC_INO_LOOKUP, &args) < 0)
8631a2
+    goto error;
8631a2
+
8631a2
+  tree_id = args.treeid;
8631a2
+
8631a2
+  while (tree_id != GRUB_BTRFS_ROOT_VOL_OBJECTID)
8631a2
+    {
8631a2
+      struct btrfs_ioctl_search_args sargs;
8631a2
+      struct grub_btrfs_root_backref *br;
8631a2
+      struct btrfs_ioctl_search_header *search_header;
8631a2
+      char *old;
8631a2
+      grub_uint16_t len;
8631a2
+      grub_uint64_t inode_id;
8631a2
+
8631a2
+      memset (&sargs, 0, sizeof(sargs));
8631a2
+
8631a2
+      sargs.key.tree_id = 1;
8631a2
+      sargs.key.min_objectid = tree_id;
8631a2
+      sargs.key.max_objectid = tree_id;
8631a2
+
8631a2
+      sargs.key.min_offset = 0;
8631a2
+      sargs.key.max_offset = ~0ULL;
8631a2
+      sargs.key.min_transid = 0;
8631a2
+      sargs.key.max_transid = ~0ULL;
8631a2
+      sargs.key.min_type = GRUB_BTRFS_ITEM_TYPE_ROOT_BACKREF;
8631a2
+      sargs.key.max_type = GRUB_BTRFS_ITEM_TYPE_ROOT_BACKREF;
8631a2
+
8631a2
+      sargs.key.nr_items = 1;
8631a2
+
8631a2
+      if (ioctl (fd, BTRFS_IOC_TREE_SEARCH, &sargs) < 0)
8631a2
+	goto error;
8631a2
+
8631a2
+      if (sargs.key.nr_items == 0)
8631a2
+	goto error;
8631a2
+
8631a2
+      search_header = (struct btrfs_ioctl_search_header *)sargs.buf;
8631a2
+      br = (struct grub_btrfs_root_backref *) (search_header + 1);
8631a2
+
8631a2
+      len = grub_le_to_cpu16 (br->n);
8631a2
+      inode_id = grub_le_to_cpu64 (br->inode_id);
8631a2
+      tree_id = search_header->offset;
8631a2
+
8631a2
+      old = ret;
8631a2
+      ret = malloc (len + 1);
8631a2
+      memcpy (ret, br->name, len);
8631a2
+      ret[len] = '\0';
8631a2
+
8631a2
+      if (inode_id != GRUB_BTRFS_TREE_ROOT_OBJECTID)
8631a2
+	{
8631a2
+	  char *s;
8631a2
+
8631a2
+	  memset(&args, 0, sizeof(args));
8631a2
+	  args.treeid = search_header->offset;
8631a2
+	  args.objectid = inode_id;
8631a2
+
8631a2
+	  if (ioctl (fd, BTRFS_IOC_INO_LOOKUP, &args) < 0)
8631a2
+	    goto error;
8631a2
+
8631a2
+	  s = xasprintf ("%s%s", args.name, ret);
8631a2
+	  free (ret);
8631a2
+	  ret = s;
8631a2
+	}
8631a2
+
8631a2
+      if (old)
8631a2
+	{
8631a2
+	  char *s = xasprintf ("%s/%s", ret, old);
8631a2
+	  free (ret);
8631a2
+	  free (old);
8631a2
+	  ret = s;
8631a2
+	}
8631a2
+    }
8631a2
+
8631a2
+  close (fd);
8631a2
+  return ret;
8631a2
+
8631a2
+error:
8631a2
+
8631a2
+  if (fd >= 0)
8631a2
+    close (fd);
8631a2
+  if (ret)
8631a2
+    free (ret);
8631a2
+
8631a2
+  return NULL;
8631a2
+}
8631a2
+
8631a2
+void (*grub_find_root_btrfs_mount_path_hook)(const char *mount_path);
8631a2
+
8631a2
 char **
8631a2
 grub_find_root_devices_from_mountinfo (const char *dir, char **relroot)
8631a2
 {
8631a2
@@ -519,12 +630,15 @@ again:
8631a2
       else if (grub_strcmp (entries[i].fstype, "btrfs") == 0)
8631a2
 	{
8631a2
 	  ret = grub_find_root_devices_from_btrfs (dir);
8631a2
-	  fs_prefix = get_btrfs_fs_prefix (entries[i].enc_path);
8631a2
 	  if (use_relative_path_on_btrfs)
8631a2
 	    {
8631a2
-	      if (fs_prefix)
8631a2
-	        free (fs_prefix);
8631a2
 	      fs_prefix = xstrdup ("/");
8631a2
+	      if (grub_find_root_btrfs_mount_path_hook)
8631a2
+		grub_find_root_btrfs_mount_path_hook (entries[i].enc_path);
8631a2
+	    }
8631a2
+	  else
8631a2
+	    {
8631a2
+	      fs_prefix = get_btrfs_fs_prefix (entries[i].enc_path);
8631a2
 	    }
8631a2
 	}
8631a2
       else if (!retry && grub_strcmp (entries[i].fstype, "autofs") == 0)
8631a2
@@ -1150,6 +1264,34 @@ grub_util_get_grub_dev_os (const char *os_dev)
8631a2
   return grub_dev;
8631a2
 }
8631a2
 
8631a2
+
8631a2
+char *
8631a2
+grub_util_get_btrfs_subvol (const char *path, char **mount_path)
8631a2
+{
8631a2
+  char *mp = NULL;
8631a2
+
8631a2
+  if (mount_path)
8631a2
+    *mount_path = NULL;
8631a2
+
8631a2
+  auto void
8631a2
+  mount_path_hook (const char *m)
8631a2
+  {
8631a2
+    mp = strdup (m);
8631a2
+  }
8631a2
+
8631a2
+  grub_find_root_btrfs_mount_path_hook = mount_path_hook;
8631a2
+  grub_free (grub_find_root_devices_from_mountinfo (path, NULL));
8631a2
+  grub_find_root_btrfs_mount_path_hook = NULL;
8631a2
+
8631a2
+  if (!mp)
8631a2
+    return NULL;
8631a2
+
8631a2
+  if (mount_path)
8631a2
+    *mount_path = mp;
8631a2
+
8631a2
+  return get_btrfs_subvol (mp);
8631a2
+}
8631a2
+
8631a2
 char *
8631a2
 grub_make_system_path_relative_to_its_root_os (const char *path)
8631a2
 {
8631a2
diff --git a/util/grub-install.c b/util/grub-install.c
09e3cc
index 4375c1619..a0ad99729 100644
8631a2
--- a/util/grub-install.c
8631a2
+++ b/util/grub-install.c
8631a2
@@ -1535,6 +1535,55 @@ main (int argc, char *argv[])
8631a2
       prefix_drive = xasprintf ("(%s)", grub_drives[0]);
8631a2
     }
8631a2
 
8631a2
+#ifdef __linux__
8631a2
+
8631a2
+  if (config.is_suse_btrfs_snapshot_enabled
8631a2
+      && grub_strncmp(grub_fs->name, "btrfs", sizeof ("btrfs") - 1) == 0)
8631a2
+    {
8631a2
+      char *subvol = NULL;
8631a2
+      char *mount_path = NULL;
8631a2
+      char **rootdir_devices = NULL;
8631a2
+      char *rootdir_path = grub_util_path_concat (2, "/", rootdir);
8631a2
+
8631a2
+      if (grub_util_is_directory (rootdir_path))
8631a2
+	rootdir_devices = grub_guess_root_devices (rootdir_path);
8631a2
+
8631a2
+      free (rootdir_path);
8631a2
+
8631a2
+      if (rootdir_devices && rootdir_devices[0])
8631a2
+	if (grub_strcmp (rootdir_devices[0], grub_devices[0]) == 0)
8631a2
+	  subvol = grub_util_get_btrfs_subvol (platdir, &mount_path);
8631a2
+
8631a2
+      if (subvol && mount_path)
8631a2
+	{
8631a2
+	  char *def_subvol;
8631a2
+
8631a2
+	  def_subvol = grub_util_get_btrfs_subvol ("/", NULL);
8631a2
+
8631a2
+	  if (def_subvol)
8631a2
+	    {
8631a2
+	      if (!load_cfg_f)
8631a2
+		load_cfg_f = grub_util_fopen (load_cfg, "wb");
8631a2
+	      have_load_cfg = 1;
8631a2
+
8631a2
+	      if (grub_strcmp (subvol, def_subvol) != 0)
8631a2
+		fprintf (load_cfg_f, "btrfs-mount-subvol ($root) %s %s\n", mount_path, subvol);
8631a2
+	      free (def_subvol);
8631a2
+	    }
8631a2
+	}
8631a2
+
8631a2
+      for (curdev = rootdir_devices; *curdev; curdev++)
8631a2
+	free (*curdev);
8631a2
+      if (rootdir_devices)
8631a2
+	free (rootdir_devices);
8631a2
+      if (subvol)
8631a2
+	free (subvol);
8631a2
+      if (mount_path)
8631a2
+	free (mount_path);
8631a2
+    }
8631a2
+
8631a2
+#endif
8631a2
+
8631a2
   char mkimage_target[200];
8631a2
   const char *core_name = NULL;
8631a2
 
8631a2
diff --git a/include/grub/emu/getroot.h b/include/grub/emu/getroot.h
09e3cc
index 73fa2d34a..9c642ae3f 100644
8631a2
--- a/include/grub/emu/getroot.h
8631a2
+++ b/include/grub/emu/getroot.h
8631a2
@@ -53,6 +53,11 @@ char **
8631a2
 grub_find_root_devices_from_mountinfo (const char *dir, char **relroot);
8631a2
 #endif
8631a2
 
8631a2
+#ifdef __linux__
8631a2
+char *
8631a2
+grub_util_get_btrfs_subvol (const char *path, char **mount_path);
8631a2
+#endif
8631a2
+
8631a2
 /* Devmapper functions provided by getroot_devmapper.c.  */
8631a2
 void
8631a2
 grub_util_pull_devmapper (const char *os_dev);