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